Bug 21924 - createMethod on inner class puts method in outer class
Summary: createMethod on inner class puts method in outer class
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-25 18:40 EDT by Richard Kulp CLA
Modified: 2003-03-23 12:11 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Kulp CLA 2002-07-25 18:40:46 EDT
If you do a create method on an inner class, the method in the text is actually 
added to the outer class, though the model thinks it is in the inner class.

Take class:

public class TestChangesClass {
	public static class InnerTestChangesClass {
	}
}

and do:

IType type = jProject.findType("TestChangesClass.InnerTestChangesClass"); 
type.createMethod("public boolean isNew() {}", null, true, monitor); 

and the saved text file becomes:

public class TestChangesClass {
	public static class InnerTestChangesClass {
	}

public boolean isNew() {}}

But, if you go against the IType type right after you did the create, "isNew" 
will be a method within the inner class.

Thanks,
Rich Kulp
Comment 1 Richard Kulp CLA 2002-07-25 18:49:21 EDT
Never mind, I just saw what I did wrong. Everything is correct.
Comment 2 Philipe Mulet CLA 2002-07-26 06:17:24 EDT
What was it ?
Comment 3 Richard Kulp CLA 2002-07-26 14:57:19 EDT
Really stupid! :-) I was looking at the wrong class. I had two classes that 
were almost identical and I didn't notice the name was slightly different!