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.
Summary: | Organize Imports hint fails within the same package | ||
---|---|---|---|
Product: | java | Reporter: | fsttesla <fsttesla> |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 8.0 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
fsttesla
2014-04-08 17:50:27 UTC
Can you please attach sample code? I've tried to create it according to your description but it my case the organize import hint works fine. Probably the code was not same as yours. Please also attach build number and version. Thanks NB 8.0 Build 201403101706 Maybe this bug (partly) depends on the formatting settings (Options > Editor > Formatting > Category: Imports), so I write them here for easier reproducibility: - Use Single Class Imports - Class Count To Use Star Import: 3 - Members Count To Use Static Star Import: 3 - Separate Static Imports All other radios/checkboxes are not selected. ### File pkg/Scanner.java ### package pkg; public class Scanner { public void doSomething() { } } ### File pkg/User.java (1st case) ### package pkg; import java.util.*; public class User { // The next 3 lines serve to keep the star import Date date; Formatter formatter; Random random; public void method(Scanner scanner) { scanner.doSomething(); } } ### File pkg/User.java (2nd case) ### package pkg; import java.util.*; import java.util.Scanner; public class User { // The next 3 lines serve to keep the star import Date date; Formatter formatter; Random random; public void method(Scanner scanner) { scanner.hasNext(); } } Renamings from the initial bug report: anotherpkg -> java.util, A -> Scanner, B -> User. In the 1st case, the simple name "Scanner" refers to pkg.Scanner and I receive an Organize Imports hint which adds a useless "import pkg.Scanner;". Of course, a Remove import from the same package hint appears afterwards. In the 2nd case, the simple name "Scanner" refers to java.util.Scanner (by virtue of the explicit import); if I apply the Organize Imports hint, such explicit import is removed and the code gets broken. reproducible thanks for code sample Fixed in jet-main#c958f8142610 Integrated into 'main-silver', will be available in build *201408100001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/c958f8142610 User: Svata Dedic <sdedic@netbeans.org> Log: #243667: fixed precedence of star/named/same-package imports |