Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 232252

Summary: [create on paste] Heuristic for pasting text into package explorer needs to better handle comments
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Philipe Mulet CLA 2008-05-15 05:15:35 EDT
Build 3.4M7

When pasting the following text (from bug 232174), you can see that trailing line comments are not properly handled.

It should deal with them in similar way to JDTCore, in term of how mapping comments to constructs.

e.g.

//---------- com.b.p1.A.java -------------------------
package com.b.p1;
public class A<K> {
    protected final class Inner {}
}
//---------- com.b.p1.ADerivedSamePkg.java ------------
package com.b.p1;
import java.util.Map;
public class ADerivedSamePkg extends A<Object> {
    protected void someMethod() {
        Map.Entry<String, Inner> some = null;
        Inner x = some.getValue();
    }
}
//---------- com.b.p2.ADerivedDifferentPkg.java ----------
package com.b.p2;
import java.util.Map;
import com.b.p1.A;
public class ADerivedDifferentPkg extends A<Object> {
    protected void someMethod()     {
        Map.Entry<String, Inner> some = null;
        Inner x = some.getValue(); // <-- error in this line
    }
}



produces a file (amongst others):

//---------- com.b.p1.A.java -------------------------
package com.b.p1;
public class A<K> {
    protected final class Inner {}
}
//---------- com.b.p1.ADerivedSamePkg.java ------------
Comment 1 Markus Keller CLA 2008-05-15 05:21:38 EDT
Hard to do right. What if text looks like this?

//---------- com.b.p1.A.java -------------------------
package com.b.p1;
public class A<K> {
    protected final class Inner {}
}
//---------- END com.b.p1.A.java -------------------------
//---------- com.b.p1.ADerivedSamePkg.java ------------
package com.b.p1;
import java.util.Map;
public class ADerivedSamePkg extends A<Object> {
}
//---------- END com.b.p1.ADerivedSamePkg.java ------------

But I guess adding comments to the following CU would indeed be better in more cases.
Comment 2 Philipe Mulet CLA 2008-05-15 09:21:10 EDT
Yes, indeed. I think aligning on the Java model strategy would be the best.

//---------- com.b.p1.A.java -------------------------
package com.b.p1;
public class A<K> {
    protected final class Inner {}
}//---------- END com.b.p1.A.java -------------------------
//---------- com.b.p1.ADerivedSamePkg.java ------------
package com.b.p1;
import java.util.Map;
public class ADerivedSamePkg extends A<Object> {
}//---------- END com.b.p1.ADerivedSamePkg.java ------------

I would expect this one to work.
Comment 3 Eclipse Genie CLA 2019-06-05 18:41:31 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.