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 213297 - Using Fix import doesn't work correctly in some cases
Summary: Using Fix import doesn't work correctly in some cases
Status: RESOLVED FIXED
Alias: None
Product: groovy
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-31 11:59 UTC by Martin Janicek
Modified: 2013-02-13 01:53 UTC (History)
1 user (show)

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 Martin Janicek 2012-05-31 11:59:01 UTC
This bug has been created in relation to the issue 155567, comment 6. In some cases there is a problem with Fix Imports action.

Configuration:
- Create Maven based project
- Add JUnit 4.10 dependency in pom.xml (you should seen it in the Test Dependencies node)
- Create Groovy file with a following content:

class MyGroovyTest {
    @Test
    void succeed() {
        Assert.assertEquals(4, 2+2);
    }
}

- Use Fix Imports action --> org.junit.Assert isn't imported at all and there isn't correct org.juni.Test import as well (only different Test types are offered)

..might be related to annotation + static methods, but can't say for sure now - have to investigate a little bit more
Comment 1 cellux 2012-06-01 13:42:07 UTC
One more case: fix import suggestion doesn't appear on Whatever.class either. So issue is not specific to static methods only.

Also these problems are not marked as issues in the editor.
Comment 2 ijakobs 2012-08-15 09:26:47 UTC
I just stumbled on an annoying bug with the 'fix imports' functionality: it doesn't know about java's own classes! I tried with java.sql, java.io and java.util classes, it didn't find any them. Some classes I tried with: ResultSet, Connection, ArrayList, IOException. It seems to work with the other non-jdk classes though: I made a test and removed all the import rows of my class, and then pressed ctrl+shift+I, all the other classes were found except those that are part of jdk, in those rows "<cannot be resolved>" message is shown.

Is this the same bug as this one?
Comment 3 Martin Janicek 2012-08-15 10:15:12 UTC
Not really. Could you please open another ticket with the same description?
Comment 4 ijakobs 2012-08-15 11:01:30 UTC
Ok, I did that. It is now ticket #216913.
Comment 5 Martin Janicek 2012-08-15 11:43:32 UTC
Mm, the issue 216913 was created for java. Do you have those troubles on groovy files or on java files?
Thanks in advance
Comment 6 Martin Janicek 2013-02-12 13:50:04 UTC
Most of the issue fixed in: web-main #7a2b2b48990e

One thing that remain is that Assert is not recognized by editor (resp. groovy parser) as a incorrect line and thus the import mechanism isn't looking for Assert in source and compilation classpath.

I'm going to fill another issue to track this. Anyway imports should work correctly now for everything that is marked as incorrect line..
Comment 7 Martin Janicek 2013-02-12 14:04:00 UTC
I have created issue 226016 to track the problem with parsing groovy file
Comment 8 Quality Engineering 2013-02-13 01:53:48 UTC
Integrated into 'main-golden', will be available in build *201302122300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/7a2b2b48990e
User: Martin Janicek <mjanicek@netbeans.org>
Log: #213297 - Using Fix import doesnt work correctly in some cases