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 164764 - Very annoying duplication of includes when change method parameters
Summary: Very annoying duplication of includes when change method parameters
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Max Sauer
URL:
Keywords: REGRESSION
Depends on:
Blocks: 138303
  Show dependency tree
 
Reported: 2009-05-08 12:53 UTC by Vladimir Voskresensky
Modified: 2009-05-14 07:56 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 Vladimir Voskresensky 2009-05-08 12:53:11 UTC
Create sample project
add dummy method
    private void foo(JLabel label) {
        
    }
=> import javax.swing.JLabel;
is added to file => OK

use Change Method Parameter to add one more boolean parameter. Refactor
=> one more
import javax.swing.JLabel;
is added

When method has N parameters with not built-in types => any manipulation through Change Method Parameter doubles imports
Comment 1 Vladimir Voskresensky 2009-05-08 12:53:34 UTC
P2 due to regression
Comment 2 Vladimir Voskresensky 2009-05-08 12:54:04 UTC
Product Version: NetBeans IDE Dev (Build 090508)
Java: 1.6.0_11; Java HotSpot(TM) Client VM 11.0-b16
System: SunOS version 5.10 running on x86; UTF-8; en_US (nb)
Comment 3 Jan Pokorsky 2009-05-11 13:22:06 UTC
Reproducible. Regression caused by fixing issue 138303.
Comment 4 Jan Pokorsky 2009-05-11 17:50:49 UTC
msauer: I suggest to remove your patch at least for the Change Parameters refactoring. SourceUtils.addImports does not
fit to this case. E.g. it expects that existing imports are sorted. More suitable would be SourceUtils.resolveImport IMO.

But your patch also ignores cases like array types, varargs and generics. This will require to add more sophisticated code.
Comment 5 Max Sauer 2009-05-12 16:06:20 UTC
Fixed the import issue. I'll leave the rest of the patch there, since it is better to support at least simple parameters than nothing. We can consider adding 
some better logic similar to java.editor's fix imports for next release.
---
http://hg.netbeans.org/jet-main/rev/6cee45ca664f
Comment 6 Quality Engineering 2009-05-14 07:56:04 UTC
Integrated into 'main-golden', will be available in build *200905140201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6cee45ca664f
User: Max Sauer <msauer@netbeans.org>
Log: #164764: Very annoying duplication of includes when change method parameters