Bug 83828 - Smart paste: should not add imports for types declared in the copied source range
Summary: Smart paste: should not add imports for types declared in the copied source r...
Status: RESOLVED DUPLICATE of bug 71763
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Aeschlimann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-27 09:54 EST by Markus Keller CLA
Modified: 2005-05-22 16:41 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-01-27 09:54:33 EST
Smart paste should not add imports for types declared in the copied source
range. Example:

package xy;
public class Try {
	class X {}
	class Y {}
	void useBoth(X x, Y y) {}
}

- copy whole body of class Try
- paste into another file
-> unwanted import statements are generated:
import xy.Try.X;
import xy.Try.Y;
Comment 1 Martin Aeschlimann CLA 2005-01-27 10:20:03 EST
This would require an AST to be build on the target side as well. There's one
build on the copy source side, so I'm afraid that's too expensive.

Not planed for 3.1
Comment 2 Markus Keller CLA 2005-01-27 10:44:22 EST
So how do you determine that X is a reference to xy.Try.X and needs an import? I
guess this is already done at the source side. It would be sufficient to just
filter out those types which are declared in the copied range and not generate
an import statement for them.
Comment 3 Markus Keller CLA 2005-01-29 07:39:42 EST
This is not expensive and does not require an AST of the target!
The problem is just that the ImportReferencesCollector also collects references
to types declared inside the processed range.

The ImportReferencesCollector could easily collect declared types and the
ClipboardOperationAction could then choose to not add imports for those types.

I think this bug should be fixed, since it makes copy-paste of code with nested
classes a royal pain.
Comment 4 Martin Aeschlimann CLA 2005-01-31 03:40:23 EST
You're right that's not so difficult.
Comment 5 Martin Aeschlimann CLA 2005-05-22 16:41:11 EDT

*** This bug has been marked as a duplicate of 71763 ***