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 201818 - Import section does not correspond to the specified code style rules
Summary: Import section does not correspond to the specified code style rules
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-08 14:01 UTC by gualtiero65
Modified: 2012-03-02 15:49 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
First screen shot with the hint message (189.88 KB, image/png)
2011-09-08 14:02 UTC, gualtiero65
Details
Second screensot after removing empty line (188.48 KB, image/png)
2011-09-08 14:02 UTC, gualtiero65
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gualtiero65 2011-09-08 14:01:16 UTC
[ BUILD # : 201109060600 ]
[ JDK VERSION : 1.6.27 ]

Hi,

the "Import section does not correspond to the specified code style rules" hint
is shown (see picture 1) but no clue about the problem or any solution is given
by "Alt-Enter".

Running "Organize Import" does not solve the problem.

On the same file Netbeans 7.0.1 does not give any message.

I think the cause is an empty line in between the import lines. When I manually
remove the empty line, the message disappears. See picture 2

Unfortunately the hint is on the first line and not on the empty line.
I suggest:
* to have the hint message on the import which gives the problem and not on the
first one.
* to have "Remove all imports and run Organize Import" as "ALT+Enter" option

Thanks
Comment 1 gualtiero65 2011-09-08 14:02:09 UTC
Created attachment 110533 [details]
First screen shot with the hint message
Comment 2 gualtiero65 2011-09-08 14:02:47 UTC
Created attachment 110534 [details]
Second screensot after removing empty line
Comment 3 Jiri Prox 2011-09-08 14:18:33 UTC
Yes, you're right the problem is empty line, which does not match formatting criteria (Tools -> Options -> Editor -> Formatting -> Language:Java -> category: Imports)

This is new feature in 7.1, so 7.0.1 does not provide this hint
Comment 4 MackSix 2011-11-10 10:21:05 UTC
If the imports are not in alphabetical order the hint is shown with no indication they are not in alphabetical order.

Product Version: NetBeans IDE Dev (Build 201111090600)
Java: 1.7.0_01; Java HotSpot(TM) Client VM 21.1-b02
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)
User directory: C:\Users\Mark\.netbeans\dev
Cache directory: C:\Users\Mark\.netbeans\dev\var\cache
Comment 5 ralphlevan 2012-01-11 14:32:59 UTC
The problem is not just with empty lines.  I get the same warning message.  I tried deleting all my imports and letting the editor recreate them.  I noticed that my individual java.io imports were replaced with java.io.*

I undid those changes and manually replaced my java.io imports with java.io.*.  This eliminated the warning message.

Personally, I don't the '*' imports.

Ralph
Comment 6 Dusan Balek 2012-01-11 15:11:56 UTC
OrganizeImports hint should now show its message on the import which gives the problem.

http://hg.netbeans.org/jet-main/rev/b3596221487e

Please note that the import section formatting criteria can be changed via Tools -> Options -> Editor -> Formatting -> Language:Java -> category: Imports
or the hint can be disabled at all.
Comment 7 Quality Engineering 2012-01-12 16:01:30 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/b3596221487e
User: Dusan Balek <dbalek@netbeans.org>
Log: OrganizeImports hint modified to show its message on the import which gives the problem and not on the first one (see issue #201818).