Bug 434805 - [imports on paste] unnecessary import pasting class name within String
Summary: [imports on paste] unnecessary import pasting class name within String
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3.1   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2014-05-13 16:34 EDT by Fernando Falci CLA
Modified: 2022-09-06 12:50 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fernando Falci CLA 2014-05-13 16:34:45 EDT
I created an exception: MyCustonErrorExcpetion;
In some part of the code, I throw this exception, and thought "I need to put a default message for constructor without arguments"

So I copied the class name, went up to her, open quotes in default constructor:

public MyCustonErrorExcpetion(){
  super(""); // and paste inside quotes
}

The class name appeared inside the quotation marks, but was made a import for the same class
Comment 1 Stephan Herrmann CLA 2014-05-13 17:19:27 EDT
I assume paste-into-quoted-string is implemented in JDT/UI ...
Comment 2 Dani Megert CLA 2014-05-14 03:42:23 EDT
See also bug 163700.
Comment 3 Stephan Herrmann CLA 2014-11-23 06:03:45 EST
Typical workflow in JDT/Core:

Create a sample program in a scratch project.

When satisfied, create a JUnit test from the sample program, pasting the sample program into an empty string in the test method.

Launch the test.

Be greeted by
  "Errors exist in required project(s):
   org.eclipse.jdt.core.tests.compiler
   ...

Find that the paste added bogus imports to the test class.

I really think that smart paste should make a full switch between:
either: pasting into code, so carry over all information from copy
or: pasting into a string, so escape what needs escaping.

I don't see *any* use of mixing these two modes.

Should I re-open bug 163700 or will _this_ bug be considered?
Comment 4 Dani Megert CLA 2014-11-24 08:28:02 EST
(In reply to Stephan Herrmann from comment #3)
> Should I re-open bug 163700 or will _this_ bug be considered?

This bug is open, but not on the radar. Patches are welcome.
Comment 5 Eclipse Genie CLA 2020-07-24 11:34: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.
Comment 6 Eclipse Genie CLA 2022-09-06 12:50:50 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.