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.

Bug 128815 - Static imports are not stored in index.
Summary: Static imports are not stored in index.
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks: 90769 125573
  Show dependency tree
 
Reported: 2008-02-29 12:58 UTC by Daniel Prusa
Modified: 2008-03-01 09:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Prusa 2008-02-29 12:58:57 UTC
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.
Comment 1 Tomas Zezula 2008-02-29 13:36:05 UTC
Seems a bug in SourceAnalyser
Comment 2 Tomas Zezula 2008-02-29 14:44:31 UTC
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.
Comment 3 Tomas Zezula 2008-02-29 15:14:24 UTC
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 :-)
Comment 4 Daniel Prusa 2008-02-29 15:31:50 UTC
The first solution sounds good to me. What about fields, are they covered by the same flag as methods or have they
another flag?
Comment 5 Tomas Zezula 2008-02-29 15:37:47 UTC
Good question, well I don't remember. I will check and if needed I will also add this flag.
Comment 6 Tomas Zezula 2008-03-01 09:43:48 UTC
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.