Community
Participate
Working Groups
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;
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
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.
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.
You're right that's not so difficult.
*** This bug has been marked as a duplicate of 71763 ***