java - Eclipse - `open call hierarchy` got wrong result -
here sample java code:
public class test { public static void foo() { foo.innerkey key = new foo.innerkey(); getinstance().query(key); } public static void bar() { bar.innerkey key = new bar.innerkey(); getinstance().query(key); } public static myif getinstance(){ // todo code instance return null; } } interface myif { public void query(foo.innerkey key); // method open call hierarchy public void query(bar.innerkey key); } class foo { static class innerkey {} } class bar { static class innerkey {} } when open call hierarchy of method query(foo.innerkey key) eclipse(kepler), got both foo & bar methods, bar not expected.

but in netbeans(7.3.1), result of call hierarchy ok:

is bug of eclipse? thanks.
this jdt bug should reported. , bug not directly related call hierarchy, instead org.eclipse.jdt.core search api, when searching method references, parameter member type of type (as e.g. foo.innerkey). therefore bug manifests every jdt functionality, relies on finding method references using jdt search engine. example wrong results when showing references myif#query(foo.innerkey) or when using java search, search methodmyif#query(foo.innerkey). in these cases search engine not return references myif#query(foo.innerkey), expected, myif#query(bar.innerkey).
the relevant code, bug occurs, in org.eclipse.jdt.internal.core.search.matching.methodlocator#matchmethod(methodbinding, boolean). , seems, bug introduced fixing jdt bug 41018.
here snippet of relevant code in class methodlocator:
protected int matchmethod(methodbinding method, boolean skipimpossiblearg) { [...] // verify each parameter (int = 0; < parametercount; i++) { typebinding argtype = method.parameters[i]; int newlevel = impossible_match; if (argtype.ismembertype()) { // compare source name member type (bug 41018) newlevel = charoperation.match(this.pattern.parametersimplenames[i], argtype.sourcename(), this.iscasesensitive) ? accurate_match : impossible_match; } else { // todo (frederic) use call refine accuracy on parameter types // newlevel = resolvelevelfortype(this.pattern.parametersimplenames[i], this.pattern.parameterqualifications[i], this.pattern.parameterstypearguments[i], 0, argtype); newlevel = resolvelevelfortype(this.pattern.parametersimplenames[i], this.pattern.parameterqualifications[i], argtype); [...] } } [...] } the problem here if (argtype.ismembertype()) statement, introduced fix bug 41018. comment states member types only source name gets compared. if if-statement removed, bug goes away , call hierarchy shows correct references (but guess of course re-introduce bug 41018 - didn't test this).
edit
on side note, there seems bug when displaying source codes javadoc myif#query(bar.innerkey) - both when using javadoc-hover on method or when showing method in javadoc view.
public interface myif { /** * javadoc for: query(foo.innerkey key) */ public void query(foo.innerkey key); // method open call hierarchy /** * javadoc for: query(bar.innerkey key) */ public void query(bar.innerkey key); } when hovering on query method reference in test class (e.g. getinstance().query(key)), both methods found , 1 able select 1 (without ability differentiate between two).
when opening javadoc view , selecting any of query method references in test class, javadoc view always displays javadoc of first found method in source class (i.e. myif#query(foo.innerkey)).
this doesn't seem directly related bug described above, , not resolved, when removing if-statement mentioned above...
Comments
Post a Comment