Community
Participate
Working Groups
Build Identifier: I20100608-0911 F3 doesn't jump to method or property declared inside object literals. var ol = { prop1: 'prop1val', prop2: 'prop2val', method: function() { return this.prop1 + this.prop2; } }; ol.prop1; //F3 doesn't work ol.prop2; //F3 doesn't work ol.method(); //F3 doesn't work ol.toString(); //F3 works Reproducible: Always
Created attachment 215687 [details] proposed patch This patch changes the hashCode() and equals() of anonymous type so that element info can be found correctly from model cache. Anonymous types are implicitly generated from object literals and their parents are set to the variable that the object is assigned to. Unlike anonymous types, parents of other types(generated by constructors) are just compilation units. Open Declaration checks whether the type exists by searching element from model cache(HashMap) with element(SourceType) as the key. But parent object of the SourceType is set to compilation unit not the variable element and it fails to find element info. Current hashCode() and equals() compares two elements by comparing all parents. But at least anonymous types, only comparing type name is enough because their names are determined uniquely like __anonymous_xxx. This patch fixes this and searching model cache succeeds. After applying this patch, open declaration for fields will be worked due to the method binding problem of #378432. The proposed patch for #378432 will also fix open declaration of methods. #325377 is also related with this bug. This patch will fix some part(maybe hover) of #325377.
Created attachment 215688 [details] testcase The patch includes testcases for open declarations. This zip file is required to run the tests.
This is working now in WTP 3.5.1, without having to apply the attached patch. Checked against the 7/18 build.