Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 14655 - Class copy should fix references to constructor
Summary: Class copy should fix references to constructor
Status: RESOLVED DUPLICATE of bug 5219
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC other
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Erich Gamma CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-25 13:46 EDT by David Whiteman CLA
Modified: 2002-04-26 04:41 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 David Whiteman CLA 2002-04-25 13:46:28 EDT
When copying a class, and pasting to a new class, internal references should be 
renamed to the new name.  

For instance, if I copy the following class and paste it in the same package, 
it will create a new class called CopyOfTestSwt.java.  However, I will have a 
compiler error since the main() method references the TestSwt() constructor, 
which is private.  I believe the constructor call in the main() method should 
be changed on the copy/paste to match the new class name (especially if the 
constructor is in the main() method, but arguably anywhere in the class).

Here's the example:

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.events.*;
 
//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
public class TestSwt {
	private Display	display;
	private Shell	shell;

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
static public void main(String[] args) {
	new TestSwt().runMain(args);
}

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
private void runMain(String[] args) {

	display = new Display();
	
	shell = new Shell(display);
	shell.setText(getClass().getName());
	shell.setLayout(new FillLayout());

	Button button = new Button(shell, 0);
	button.setText("H&ello World");
	
	shell.setSize(300, 300);
	shell.open();

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}

}
Comment 1 Adam Kiezun CLA 2002-04-26 04:41:23 EDT

*** This bug has been marked as a duplicate of 5219 ***