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 expands "import static xxx.*" but it shouldn't | ||
---|---|---|---|
Product: | java | Reporter: | err <err> |
Component: | Editor | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kalaider, sdedic |
Priority: | P3 | Keywords: | REGRESSION |
Version: | 8.0 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 243435 |
Description
err
2013-11-10 19:45:49 UTC
I confirm that "organize import" expanding static import with star into lots of lines is dumb. Scenario: 1) import static mypack.*; 2) auto completion on case/switch works fine 3) organize import. (removes star import) 4) auto completion does not work anymore when adding new cases in switch (majority of static import is for constant lists) This is even more frustrating when "organize import" is turned on automatically on save Thanks to let the star live its life! IMHO the described behavior is correct, if the 'use single class' is selected and Member Count To Use Static Star Import is not checked the IDE tries to removed all star imports. The problem is that the 'Packages to use star import' does not work for static imports, e.g. when entering mypack.MyClass the star static imports from MyClass is replaced. This should be improvedWe can discuss the correct/expected behavior here, to get most user friendly UI There are two issues here. 1) Broken feature When "member count to use static star imports" was introduced in NB-7.1 over two and a half years ago, it had a feature that allowed the rewrite logic to be disabled. This "disable rewrite" feature was broken/removed in 8.0 (thus it's a regression). As described in Bug 203007 comment 6 and mentioned in comment 1, if a user "disable rewrite" by unchecking "Member Count" and adds "import static xxx.*" then code completion works for the statics from xxx. Note that before this change to get "the IDE tries to removed all star imports" you could check the box, and set the count to a huge number. The change in behavior added no new feature, it removed one. 2) UI issue (should probably be filed as a separate issue, then the regression could be fixed while a better UI is worked out) I'm not suggesting the following for a UI, but I think it shows all the possible configurations. [X] Allow static import rewrite |X| Allow import static star Member Count To Use Static Star Import Integer-Slider So if "Allow rewrite" is unchecked, then "import static xxx.*" is left alone and code completion works and the following 2 lines are grayed and their settings don't matter. If "Allow rewrite" is checked then "Allow Star" controls whether the "Member Count" slider is used. *** Bug 246010 has been marked as a duplicate of this bug. *** Partially fixed by jet-main#3b40fe020d38 Additional fix in jet-main#ebe618db4e18 I didn't want to rewrite the code, so I added some adjustments which will (I hope) cause these changes: * if the Count is unchecked, the IDE will not convert star import into named imports * if the Count is checked, and the actual number of used (imported) symbols is below the threshold, the star import is expanded * if the Count is checked, and the actual number of used symbols from a certain scope exceeds threshold, a star import is created The above should apply equally to both type imports and static imports. I am not 100% sure that the "Packages to use star import" should be expanded to apply to static imports as well (e.g. not only packages, but types as well could be listed). Integrated into 'main-silver', will be available in build *201408160001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/3b40fe020d38 User: Svata Dedic <sdedic@netbeans.org> Log: #238208: partial fix - comparator properly inserts static star imports |