### Eclipse Workspace Patch 1.0 #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.421 diff -u -r1.421 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 27 Oct 2010 02:55:30 -0000 1.421 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 2 Dec 2010 23:29:49 -0000 @@ -4403,7 +4403,7 @@ if (this.currentToken == TokenNameSEMICOLON /*&& !method.isAnnotationMethod()*/){ method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; method.declarationSourceEnd = this.scanner.currentPosition-1; - method.bodyEnd = this.scanner.currentPosition-1; + method.bodyEnd = this.rParenPos; if (this.currentElement.parseTree() == method && this.currentElement.parent != null) { this.currentElement = this.currentElement.parent; } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v retrieving revision 1.298 diff -u -r1.298 ASTConverter15Test.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 2 Nov 2010 16:14:02 -0000 1.298 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 2 Dec 2010 23:30:20 -0000 @@ -3967,7 +3967,7 @@ Statement statement = (Statement) statements.get(0); assertEquals("Not a constructor invocation", ASTNode.CONSTRUCTOR_INVOCATION, statement.getNodeType()); ConstructorInvocation constructorInvocation = (ConstructorInvocation) statement; - checkSourceRange(constructorInvocation, "x. this();", source); + checkSourceRange(constructorInvocation, "x. this();", source, true/*expectMalformed*/); assertTrue("Node is not malformed", isMalformed(constructorInvocation)); } Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java,v retrieving revision 1.29 diff -u -r1.29 ASTConverterAST3Test.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java 18 Jan 2010 12:53:41 -0000 1.29 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java 2 Dec 2010 23:30:45 -0000 @@ -6943,7 +6943,7 @@ "public void fails() {\n" + //$NON-NLS-1$ " foo()\n" + //$NON-NLS-1$ " }"; //$NON-NLS-1$ - checkSourceRange(methodDeclaration, expectedSource, source); + checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/); Block block = methodDeclaration.getBody(); expectedSource = "{\n" + //$NON-NLS-1$ @@ -6999,7 +6999,7 @@ "public void fails() {\n" + //$NON-NLS-1$ " foo()\n" + //$NON-NLS-1$ " }"; //$NON-NLS-1$ - checkSourceRange(methodDeclaration, expectedSource, source); + checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/); Block block = methodDeclaration.getBody(); expectedSource = "{\n" + //$NON-NLS-1$ @@ -8182,7 +8182,7 @@ " z\n" + //$NON-NLS-1$ " }\n" + //$NON-NLS-1$ "}"; //$NON-NLS-1$ - checkSourceRange(node, expectedSource, source); + checkSourceRange(node, expectedSource, source, true/*expectMalformed*/); int methodEndPosition = node.getStartPosition() + node.getLength(); node = getASTNode(compilationUnit, 0); assertNotNull("not null", node); //$NON-NLS-1$ Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java,v retrieving revision 1.87 diff -u -r1.87 ASTConverterTest.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java 18 Jan 2010 12:53:41 -0000 1.87 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java 2 Dec 2010 23:31:09 -0000 @@ -7116,7 +7116,7 @@ "public void fails() {\n" + //$NON-NLS-1$ " foo()\n" + //$NON-NLS-1$ " }"; //$NON-NLS-1$ - checkSourceRange(methodDeclaration, expectedSource, source); + checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/); Block block = methodDeclaration.getBody(); expectedSource = "{\n" + //$NON-NLS-1$ @@ -7171,7 +7171,7 @@ "public void fails() {\n" + //$NON-NLS-1$ " foo()\n" + //$NON-NLS-1$ " }"; //$NON-NLS-1$ - checkSourceRange(methodDeclaration, expectedSource, source); + checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/); Block block = methodDeclaration.getBody(); expectedSource = "{\n" + //$NON-NLS-1$ @@ -8350,7 +8350,7 @@ " z\n" + //$NON-NLS-1$ " }\n" + //$NON-NLS-1$ "}"; //$NON-NLS-1$ - checkSourceRange(node, expectedSource, source); + checkSourceRange(node, expectedSource, source, true /*expectMalformed*/); int methodEndPosition = node.getStartPosition() + node.getLength(); node = getASTNode(compilationUnit, 0); assertNotNull("not null", node); //$NON-NLS-1$ Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java,v retrieving revision 1.198 diff -u -r1.198 ASTConverterTest2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 26 Oct 2010 17:24:12 -0000 1.198 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 2 Dec 2010 23:31:22 -0000 @@ -1908,7 +1908,7 @@ assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration methodDeclaration = (MethodDeclaration) node; assertTrue("Is a constructor", !methodDeclaration.isConstructor()); - checkSourceRange(methodDeclaration, "private void foo(){", source); + checkSourceRange(methodDeclaration, "private void foo(){", source, true/*expectMalformed*/); node = getASTNode(compilationUnit, 0, 1); assertNotNull("No node", node); assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ @@ -3125,7 +3125,7 @@ assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration declaration = (MethodDeclaration) node; assertTrue("A constructor", !declaration.isConstructor()); - checkSourceRange(declaration, "public method(final int parameter);", source); + checkSourceRange(declaration, "public method(final int parameter);", source, true/*expectMalformed*/); } /** @@ -3143,7 +3143,7 @@ assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration declaration = (MethodDeclaration) node; assertTrue("A constructor", !declaration.isConstructor()); - checkSourceRange(declaration, "public method(final int parameter) { }", source); + checkSourceRange(declaration, "public method(final int parameter) { }", source, true/*expectMalformed*/); } /** @@ -3280,7 +3280,7 @@ assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration declaration = (MethodDeclaration) node; assertTrue("Not a constructor", declaration.isConstructor()); - checkSourceRange(declaration, "public A();", source); + checkSourceRange(declaration, "public A();", source, true/*expectMalformed*/); } /** Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v retrieving revision 1.177 diff -u -r1.177 ASTConverterTestAST3_2.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 26 Oct 2010 17:24:11 -0000 1.177 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 2 Dec 2010 23:31:42 -0000 @@ -1988,7 +1988,7 @@ assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration methodDeclaration = (MethodDeclaration) node; assertTrue("Is a constructor", !methodDeclaration.isConstructor()); - checkSourceRange(methodDeclaration, "private void foo(){", source); + checkSourceRange(methodDeclaration, "private void foo(){", source, true/*expectMalformed*/); node = getASTNode(compilationUnit, 0, 1); assertNotNull("No node", node); assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ @@ -3203,7 +3203,7 @@ assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration declaration = (MethodDeclaration) node; assertTrue("A constructor", !declaration.isConstructor()); - checkSourceRange(declaration, "public method(final int parameter);", source); + checkSourceRange(declaration, "public method(final int parameter);", source, true/*expectMalformed*/); } /** @@ -3221,7 +3221,7 @@ assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration declaration = (MethodDeclaration) node; assertTrue("A constructor", !declaration.isConstructor()); - checkSourceRange(declaration, "public method(final int parameter) { }", source); + checkSourceRange(declaration, "public method(final int parameter) { }", source, true/*expectMalformed*/); } /** @@ -3358,7 +3358,7 @@ assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$ MethodDeclaration declaration = (MethodDeclaration) node; assertTrue("Not a constructor", declaration.isConstructor()); - checkSourceRange(declaration, "public A();", source); + checkSourceRange(declaration, "public A();", source, true/*expectMalformed*/); } /** @@ -5493,7 +5493,7 @@ node = getASTNode(compilationUnit, 0, 0); assertEquals("wrong type", ASTNode.FIELD_DECLARATION, node.getNodeType()); FieldDeclaration fieldDeclaration = (FieldDeclaration) node; - checkSourceRange(fieldDeclaration, "d String[][]", source.toCharArray()); + checkSourceRange(fieldDeclaration, "d String[][]", source.toCharArray(), true/*expectMalformed*/); Type type = fieldDeclaration.getType(); assertTrue("Not a simple type", type.isSimpleType()); List fragments = fieldDeclaration.fragments(); @@ -7243,7 +7243,7 @@ List fragments = fieldDeclaration.fragments(); assertEquals("wrong size", 1, fragments.size()); VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); - checkSourceRange(fragment, "s = {\"\",,,", source); + checkSourceRange(fragment, "s = {\"\",,,", source, true/*expectMalformed*/); assertTrue("Not initializer", fragment.getInitializer() == null); assertTrue("Not a malformed node", isMalformed(fragment)); } Index: src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java,v retrieving revision 1.62 diff -u -r1.62 ConverterTestSetup.java --- src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java 26 Aug 2009 22:56:37 -0000 1.62 +++ src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java 2 Dec 2010 23:31:43 -0000 @@ -559,6 +559,9 @@ } protected void checkSourceRange(ASTNode node, String expectedContents, char[] source) { + checkSourceRange(node, expectedContents, source, false); + } + protected void checkSourceRange(ASTNode node, String expectedContents, char[] source, boolean expectMalformed) { assertNotNull("The node is null", node); //$NON-NLS-1$ assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1); //$NON-NLS-1$ @@ -568,6 +571,10 @@ System.arraycopy(source, start, actualContents, 0, length); String actualContentsString = new String(actualContents); assertSourceEquals("Unexpected source", Util.convertToIndependantLineDelimiter(expectedContents), Util.convertToIndependantLineDelimiter(actualContentsString)); + if (expectMalformed) + assertTrue("Is not malformed", isMalformed(node)); + else + assertFalse("Is malformed", isMalformed(node)); } protected boolean isMalformed(ASTNode node) {