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

Bug 429835

Summary: [quick fix] Missing quick fix to rename CU when name of public type != name of CU
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: manju656, markus.kell.r
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Srikanth Sankaran CLA 2014-03-06 22:23:11 EST
Using Kepler SR1 +   
Eclipse Java Development Tools Patch for Java 8 Support (BETA)
1.0.0.v20140306-1935

I don't see a quick fix to rename CU or type at the error:
Description	Resource	Path	Location	Type
The public type X must be defined in its own file	I.java	/P/src	line 7	Java Problem


// --
interface I { 
	int thrice(int x);
}
interface J {
	int twice(int x);
}
public class X {
	I i = (x) /* field */ -> {return x * 3;}; 
	X x = null;
	static void goo(I i) {} 
	public static void main(String[] args) { 
			goo((x) /*call*/ -> { 
				int y = 3;
				return x * y; 
			});
		I i2 = (x) /* local */ -> {
			int y = 3; 
			return x * y;
		};
		J j1 = (x) -> { 
			int y = 2;  
			return x * y;
		};  
	}
}
Comment 1 Srikanth Sankaran CLA 2014-03-06 22:23:38 EST
The file is named I.java if that matters.
Comment 2 Martin Mathew CLA 2014-03-12 02:23:09 EDT
This is not particular to Java 8.
The CU is already named I.java and there is a type defined in the file named 'I'. So even though 'X' is the public type defined in the file we cannot provide a clean quick fix to 'Rename type to I' as this will conflict with the existing type named 'I'. We could check the feasibility of providing the quick fix 'Rename the CU to X'. But the problem with this quick fix in this particular case is that when the CU is renamed the type associated with the CU(in this case 'I') will also be renamed.

So as said earlier i am not finding a clean quick fix to apply in this case.
Comment 3 Markus Keller CLA 2014-03-14 12:39:14 EDT
We should offer the "Rename CU to X.java" quick fix, which should just rename I.java into X.java and not do anything else. For the non-public type I, it doesn't matter how the CU is called.

If X.java already exists in the package, we can't help.
Comment 4 Eclipse Genie CLA 2020-01-30 14:54:26 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.