Bug 91091 - [quick assist] Cannot rename type name in file
Summary: [quick assist] Cannot rename type name in file
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-12 05:44 EDT by Philipe Mulet CLA
Modified: 2005-05-11 09:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2005-04-12 05:44:03 EDT
3.1m6

In unit X.java, had the following source:

public class CI {
	Comparable<?> x;
	void put(Comparable<?> x) {
		this.x = x;
	}
	Comparable<?> get() {
		return x;
	}
	void test() {
		CI ci = new CI();
		ci.put(new Integer(3));
		Integer x = (Integer) ci.get();
	}
}


I wanted to rename CI into X for all occurrences in file.
Selected CI in class declaration header
Pressed ctrl-1 > rename in file
It did not toggle to linked mode, and edits did not affect other references in file.
Comment 1 Martin Aeschlimann CLA 2005-04-12 06:31:41 EDT
the problem in this scenario is that the AST does not contain any bindings as
the main type does not correspond to the CU name.

However, instead of 'rename in file' use the quick fix offered on 'CI': Rename
to 'X'. The quick fix correctly renames the file and all references in code. It
does does by creating an AST with the name 'CI.java' and so gets bindings again.

The only thing I can do here is to ask jdt.core to be more tollerant when CU and
type name do not match and return bindings anyways. Philippe, is that a possibility?




Comment 2 Philipe Mulet CLA 2005-04-12 07:52:59 EDT
Kent - the check is located inside CompilationUnitScope#buildTypeBindings(...)

what if removing the "continue" statement after reporting the problem (line 116) ?
Comment 3 Philipe Mulet CLA 2005-04-12 07:56:23 EDT
I checked that with this one change, the quick assist operates fine.
Readopting the problem.
Comment 4 Kent Johnson CLA 2005-04-12 16:37:52 EDT
I don't think we should change this.

What happens when there is a file CI.java that defines the type CI?

CI.java should not be tagged with the duplicate type error since its the only 
file that can correctly define the type CI.
Comment 5 Philipe Mulet CLA 2005-04-21 09:10:34 EDT
That isn't much different from a non-public case where a duplicate type would be
reported. One thing we could do then, is probably losing the public modifier in
this scenario.
Comment 6 Philipe Mulet CLA 2005-04-21 09:13:32 EDT
Released, as it improves greatly some refactoring scenario.
Comment 7 Kent Johnson CLA 2005-04-21 16:57:42 EDT
We now complain against the file CI when it defines the type CI.
Comment 8 Kent Johnson CLA 2005-04-25 14:27:03 EDT
Will leave as is.

Before the change it was still possible for a secondary type to be accepted & 
the public type in the correct file to be tagged as a duplicate.
Comment 9 Olivier Thomann CLA 2005-05-11 09:21:40 EDT
Verified in I20050510-0010