Bug 221750 - [imports on paste] copying from outline view does not add import statements
Summary: [imports on paste] copying from outline view does not add import statements
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 428197 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-06 16:17 EST by Raj Mandayam CLA
Modified: 2014-02-20 01:51 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raj Mandayam CLA 2008-03-06 16:17:31 EST
Build ID: 3.3.2

Steps To Reproduce:
I performed a search in bugzilla and was surprised/unable to find an already existing bug report for this common problem.
and since this bug is still happening in 3.3.2 but fixed for 3.4 (see minor issue below)
Create a java class example Test1.java extending any interface, I chose the javax.swing.Icon interface.

notice that it adds a method called paintIcon

Now create another java class Test2.java. Do not implement any interface.

Go back to Test1.java
now from the outline view 
select the method paintIcon and Ctrl C to copy it
Go to Test2.java
now in outline view select Test2.java and hit Ctrl V to paste the method

Notice the method gets pasted but the required import statements do not get added to the Test2.java file.

the required import stmts are 

import java.awt.Component;
import java.awt.Graphics;

Note that if one were to copy the entire method from the Editor itself (not outline view) from Test1.java to Test2.java, then the import statements are added.

Wondering if this is some kind of intentional behavior.
Please dup this bug because I am pretty sure this has been reported somewhere, I just cant find it.

Now I have noticed that this is fixed in 3.4 but there is still the minor issue where the Test2.java is saved after the copy even though I expect it to remain dirty after the method is copy-pasted.

More information:
Comment 1 Martin Aeschlimann CLA 2008-03-07 04:34:03 EST
The 'import on paste' feature only works on text selections.

This has to do with the fact that an AST is required on the source element. For elements in the outline, we would have the AST, but for all other elements normally not.

So for consistency, we only support 'import on paste' on text selection.

Nothing has changed in this area in 3.4. So maybe you're seeing a different bug. If you have reproducable steps, please file a separate bug against JDT/Text
Comment 2 Dani Megert CLA 2014-02-20 01:51:32 EST
*** Bug 428197 has been marked as a duplicate of this bug. ***