Bug 487247 - [actions] "Add Import" on static method invocation removes qualifier and causes semantic change
Summary: [actions] "Add Import" on static method invocation removes qualifier and caus...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: bugday, helpwanted
Depends on:
Blocks:
 
Reported: 2016-02-04 10:44 EST by Markus Keller CLA
Modified: 2023-03-02 08:05 EST (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 Markus Keller CLA 2016-02-04 10:44:18 EST
"Add Import" on a static method invocation wrongly removes the qualifier even if this causes a semantic change.

Steps:
- open ProjectionDocumentTest from http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=805de570454ef7bb1d956a147cdc9bc6b8faa0b9
- put caret into "assertEquals" of one of the "Assert.assertEquals(...)" calls
- Source > Add Import (Ctrl+Shift+M)

=> Was: Compile error, because the method resolves to the conflicting
    private void assertEquals(DocumentEvent expected, DocumentEvent received)

=> Expected: No import added, and source not touched. Show an error in the status line "Import could not be added because a conflicting method is in scope".


Add Import should not only be blocked when it causes a compile error, but also when it redirects the method call to a different method.

Example with JUnit4:

public class FileCharSequenceTests {
	@Test
	public void test1() throws Exception {
		Assert.assertEquals("msg", "a", "b"); // Add Import
		assertEquals("msg", "a", "b");
	}
	
	private void assertEquals(String desc, CharSequence actual, CharSequence expected) {
	}
}
Comment 1 Eclipse Genie CLA 2020-09-14 10:12:38 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 2 Eclipse Genie CLA 2023-03-02 08:05:08 EST
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.