This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Usecase: - I had Class with static method - static method is used in big project using static import - Class was split into Base and Derived and static method was moved into base -- all is compiled and works just fine PROBLEM: now static method can not be found by FindUsages and if try to Rename calls are not renamed I will attach simplified test project
Created attachment 159144 [details] sample project usage in callDerived is not visible by FindUsages and Refactoring
Derived extends Base which contains { static void foo(){} } import static Derived.*; and calling foo() is not indexed as Base.foo(), but as Derived.foo(). While debugging I got as far as Resolve.java:1896 for (Symbol currentSym : env.toplevel.starImportScope.getSymbolsByName(name)) { Symbol origin = env.toplevel.starImportScope.getOrigin(currentSym).owner; if (currentSym.kind == MTH) { if (currentSym.owner.type != origin.type) currentSym = currentSym.clone(origin); where the origin of the symbol gets changed from Base to Derived. Reassigning to hopefully the right component and adding Jan Lahoda to CC as he changed the code as part of JDK-8031569.
(In reply to Ralph Ruijs from comment #2) > Derived extends Base which contains { static void foo(){} } > > import static Derived.*; and calling foo() is not indexed as Base.foo(), but > as Derived.foo(). > > > > While debugging I got as far as Resolve.java:1896 > > for (Symbol currentSym : > env.toplevel.starImportScope.getSymbolsByName(name)) { > Symbol origin = > env.toplevel.starImportScope.getOrigin(currentSym).owner; > if (currentSym.kind == MTH) { > if (currentSym.owner.type != origin.type) > currentSym = currentSym.clone(origin); > > > where the origin of the symbol gets changed from Base to Derived. I believe it was always the case - this is needed as the classfile should refer to the method in terms of Derived, not Base. This usually does not propagate to the API, as TreeInfo.symbolFor (used by Trees.getElement) does: public static Symbol symbolFor(JCTree node) { Symbol sym = symbolForImpl(node); return sym != null ? sym.baseSymbol() : null; } I see SourceAnalyzerFactory accesses JCIdent/JCFieldAcces/JCMemberReference.sym directly - I'd suggest to change that to use TreeInfo.symbolFor, which should produce a reasonable Symbol for the IDE's pruposes.
Reassinging to java.source. Thanks Honza!
Fixed jet-main e1d3c69d5f09
Forgot to mention: You need to reindex the sources to make the fix work.
Excellent! Verified! Thanks!