### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java,v retrieving revision 1.23 diff -u -r1.23 ASTConverterBugsTest.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 27 Jun 2008 16:02:37 -0000 1.23 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java 2 Jun 2009 10:00:33 -0000 @@ -1061,4 +1061,70 @@ methodInvocation.resolveMethodBinding() ); } +public void testBug274898a() throws JavaModelException { + ASTResult result = this.buildMarkedAST( + "/Converter15/src/a/X.java", + "package a;\n" + + "public class X {\n"+ + " public void foo() {\n"+ + " [*1*]Object o = new [*1*][*2*]new Object(){}[*2*]; \n"+ + " }\n"+ + "}\n"); + + assertASTResult( + "===== AST =====\n" + + "package a;\n" + + "public class X {\n" + + " public void foo(){\n" + + " [*1*]Object o;[*1*]\n" + + " [*2*]new Object(){\n" + + " }\n" + + ";[*2*]\n" + + " }\n" + + "}\n" + + "\n" + + "===== Details =====\n" + + "1:VARIABLE_DECLARATION_STATEMENT,[72,15],,,[N/A]\n" + + "2:EXPRESSION_STATEMENT,[87,14],,,[N/A]\n" + + "2:CLASS_INSTANCE_CREATION,[87,14],,RECOVERED,[N/A]\n" + + "===== Problems =====\n" + + "1. ERROR in /Converter15/src/a/X.java (at line 4)\n" + + " Object o = new new Object(){}; \n" + + " ^^^\n" + + "Syntax error on token \"new\", delete this token\n", + result); +} +public void testBug274898b() throws JavaModelException { + ASTResult result = this.buildMarkedAST( + "/Converter15/src/a/X.java", + "package a;\n" + + "public class X {\n"+ + " public void foo() {\n"+ + " [*1*]Object o = new # [*1*][*2*]new Object(){}[*2*]; \n"+ + " }\n"+ + "}\n"); + + assertASTResult( + "===== AST =====\n" + + "package a;\n" + + "public class X {\n" + + " public void foo(){\n" + + " [*1*]Object o;[*1*]\n" + + " [*2*]new Object(){\n" + + " }\n" + + ";[*2*]\n" + + " }\n" + + "}\n" + + "\n" + + "===== Details =====\n" + + "1:VARIABLE_DECLARATION_STATEMENT,[72,17],,,[N/A]\n" + + "2:EXPRESSION_STATEMENT,[89,14],,,[N/A]\n" + + "2:CLASS_INSTANCE_CREATION,[89,14],,,[N/A]\n" + + "===== Problems =====\n" + + "1. ERROR in /Converter15/src/a/X.java (at line 4)\n" + + " Object o = new # new Object(){}; \n" + + " ^^^^^\n" + + "Syntax error on tokens, delete these tokens\n", + result); +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.403 diff -u -r1.403 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 7 May 2009 08:49:42 -0000 1.403 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 2 Jun 2009 10:00:36 -0000 @@ -1299,6 +1299,7 @@ anonymousType.name = CharOperation.NO_CHAR; anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType); anonymousType.sourceStart = this.intStack[this.intPtr--]; + anonymousType.declarationSourceStart = anonymousType.sourceStart; anonymousType.sourceEnd = this.rParenPos; // closing parenthesis QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType); alloc.type = getTypeReference(0);