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.
If there is a static import in a java source file and no usages of the imported element, visitCompilationUnit() is not called on the source file when performing refactoring related to the element (rename, find usages, etc.). It seems that static imports are not stored in index.
Seems a bug in SourceAnalyser
Seems strange I did the following small test: Java fille: package javaapplication5; import static java.lang.Math.abs; public class Main { public static void main(String[] args) { // TODO code application logic here } } Using Luke I've dump the index entry for it: 1 ciName main 1 packageName javaapplication5 1 references java.lang.Math----+ 1 references java.lang.Object---+- 1 references java.lang.String----+ 1 references javaapplication5.Main----+ 1 resName / 1 simpleName Main 1 binaryName MainC The reference to java.lang.Math is stored there.
Also find usages on the Math or rename Math (I did my Math not the JDK in this test - foo.Math) correctly finds, rename the class. The problem if if I look at the usages of the method, it's not found. The problem may be in the fact that in the index says that only the type Math is used (not its methods, since they are not actually used). There are 2 possible solutions - 1) SourceAnalyser should automatically add method usage flag for static imports 2) Refactoring will process both method usages an type usages. You can choose :-)
The first solution sounds good to me. What about fields, are they covered by the same flag as methods or have they another flag?
Good question, well I don't remember. I will check and if needed I will also add this flag.
Fixed in: c1433706a28e Find usages on unused static import works fine, but rename doesn't work - this seems as a problem in refactoring since the method (field) is found in usages.