### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.91 diff -u -r1.91 ASTConverterTestAST3_2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 10 Apr 2006 14:02:58 -0000 1.91 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 18 Apr 2006 13:11:31 -0000 @@ -7686,4 +7686,53 @@ workingCopy.discardWorkingCopy(); } } + /** + * http://dev.eclipse.org/bugs/show_bug.cgi?id=135997 + */ + public void test0645() throws JavaModelException { + ICompilationUnit workingCopy = null; + try { + String contents = + "public class X {\n" + + " {\n" + + " new Object();\n" + + " Object.equ;\n" + + " }\n" + + "}"; + workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/); + ASTNode node = buildAST( + contents, + workingCopy, + false, + true); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize( + unit, + 2, + "Object.equ cannot be resolved\n" + + "Syntax error, insert \"AssignmentOperator Expression\" to complete Expression"); + node = getASTNode(unit, 0, 0); + assertEquals("Not a field declaration statement", ASTNode.INITIALIZER, node.getNodeType()); + Initializer initializer = (Initializer) node; + checkSourceRange( + initializer, + "{\n" + + " new Object();\n" + + " Object.equ;\n" + + " }", + contents); + Block block = initializer.getBody(); + checkSourceRange( + block, + "{\n" + + " new Object();\n" + + " Object.equ;\n" + + " }", + contents); + } finally { + if (workingCopy != null) + workingCopy.discardWorkingCopy(); + } + } } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java,v retrieving revision 1.37 diff -u -r1.37 RecoveredBlock.java --- compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java 29 Mar 2006 02:47:34 -0000 1.37 +++ compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java 18 Apr 2006 13:11:34 -0000 @@ -276,7 +276,11 @@ } if (this.blockDeclaration.sourceEnd == 0) { - this.blockDeclaration.sourceEnd = lastEnd; + if(lastEnd < bodyEndValue) { + this.blockDeclaration.sourceEnd = bodyEndValue; + } else { + this.blockDeclaration.sourceEnd = lastEnd; + } } return this.blockDeclaration;