Bug 10699 - ast: nothing in anonymous inner classes is created
Summary: ast: nothing in anonymous inner classes is created
Status: RESOLVED WORKSFORME
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.0 M4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-04 13:19 EST by Adam Kiezun CLA
Modified: 2002-03-05 11:51 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 Adam Kiezun CLA 2002-03-04 13:19:20 EST
//rename to j
package p;
class A{
	void m(final int i){
		A a= new A(){
			void m(int k){
				k= i;
			}
		};
	}
}

the ClassInstanceCreation node has missing subnodes.
that is: optionalAnonymousClassDeclaration.bodyDeclarations list is empty!
so the assignment, for instance is simply not present
Comment 1 Olivier Thomann CLA 2002-03-04 13:33:07 EST
Reproduced. I am working on it.
Comment 2 Olivier Thomann CLA 2002-03-04 14:08:18 EST
Could not reproduced. My previous message is an error. I typed into the wrong PR.
Are you using 
latest code?
Comment 3 Olivier Thomann CLA 2002-03-04 14:11:40 EST
Could you please provide me the code you are using?
Comment 4 Olivier Thomann CLA 2002-03-05 09:47:37 EST
I used your test case as is and I got what I wanted. Here is my test case for this PR:
/**
 * 
http://dev.eclipse.org/bugs/show_bug.cgi?id=10699
 */
public void test0264() throws 
JavaModelException {
ICompilationUnit sourceUnit = getCompilationUnit("Converter" , "", 
"test0264", "Test.java");
char[] source = 
sourceUnit.getSource().toCharArray();
ASTNode result = runConversion(sourceUnit, 
true);
assertNotNull("No compilation unit", result);
assertTrue("result is not a 
compilation unit", result instanceof CompilationUnit);
CompilationUnit compilationUnit 
= (CompilationUnit) result;
ASTNode node = getASTNode(compilationUnit, 0, 0, 
0);
assertTrue("Not a VariableDeclarationStatement", node instanceof 
VariableDeclarationStatement);
VariableDeclarationStatement 
variableDeclarationStatement = (VariableDeclarationStatement) node;
List fragments = 
variableDeclarationStatement.fragments();
assertEquals("Wrong fragment size", 1, 
fragments.size());
VariableDeclarationFragment variableDeclarationFragment = 
(VariableDeclarationFragment) fragments.get(0);
Expression expression = 
variableDeclarationFragment.getInitializer();
assertTrue("Not a 
classinstancecreation", expression instanceof 
ClassInstanceCreation);
ClassInstanceCreation classInstanceCreation = 
(ClassInstanceCreation) expression;
AnonymousClassDeclaration 
anonymousClassDeclaration = 
classInstanceCreation.getAnonymousClassDeclaration();
assertNotNull("No 
anonymousclassdeclaration", anonymousClassDeclaration);
List bodyDeclarations = 
anonymousClassDeclaration.bodyDeclarations();
assertEquals("Wrong size", 1, 
bodyDeclarations.size());
BodyDeclaration bodyDeclaration = (BodyDeclaration) 
bodyDeclarations.get(0);
assertTrue("Not a method declaration", bodyDeclaration 
instanceof MethodDeclaration);
MethodDeclaration methodDeclaration = 
(MethodDeclaration) bodyDeclaration;
assertEquals("Wrong name", "m", 
methodDeclaration.getName().getIdentifier());
}
And the source code is:
package 
test0264;
import java.util.*;
public class Test {
	void m(final int i){
		Test a= new 
Test(){
			void m(int k){
				k= i;
			}
		};
	}
}

If you see anything wrong 
compare to what you do, let me know. I cannot resolve this problem if I cannot reproduce it.
Comment 5 Adam Kiezun CLA 2002-03-05 11:11:33 EST
works with the latest jcore code 
ok to close
Comment 6 Olivier Thomann CLA 2002-03-05 11:51:40 EST
Closed.