View | Details | Raw Unified | Return to bug 331736 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-1 / +1 lines)
Lines 4403-4409 Link Here
4403
		if (this.currentToken == TokenNameSEMICOLON /*&& !method.isAnnotationMethod()*/){
4403
		if (this.currentToken == TokenNameSEMICOLON /*&& !method.isAnnotationMethod()*/){
4404
			method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
4404
			method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
4405
			method.declarationSourceEnd = this.scanner.currentPosition-1;
4405
			method.declarationSourceEnd = this.scanner.currentPosition-1;
4406
			method.bodyEnd = this.scanner.currentPosition-1;
4406
			method.bodyEnd = this.rParenPos;
4407
			if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
4407
			if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
4408
				this.currentElement = this.currentElement.parent;
4408
				this.currentElement = this.currentElement.parent;
4409
			}
4409
			}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +1 lines)
Lines 3967-3973 Link Here
3967
        Statement statement = (Statement) statements.get(0);
3967
        Statement statement = (Statement) statements.get(0);
3968
        assertEquals("Not a constructor invocation", ASTNode.CONSTRUCTOR_INVOCATION, statement.getNodeType());
3968
        assertEquals("Not a constructor invocation", ASTNode.CONSTRUCTOR_INVOCATION, statement.getNodeType());
3969
        ConstructorInvocation constructorInvocation = (ConstructorInvocation) statement;
3969
        ConstructorInvocation constructorInvocation = (ConstructorInvocation) statement;
3970
        checkSourceRange(constructorInvocation, "x.<String> this();", source);
3970
        checkSourceRange(constructorInvocation, "x.<String> this();", source, true/*expectMalformed*/);
3971
        assertTrue("Node is not malformed", isMalformed(constructorInvocation));
3971
        assertTrue("Node is not malformed", isMalformed(constructorInvocation));
3972
    }
3972
    }
3973
3973
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterAST3Test.java (-3 / +3 lines)
Lines 6943-6949 Link Here
6943
				"public void fails() {\n" + //$NON-NLS-1$
6943
				"public void fails() {\n" + //$NON-NLS-1$
6944
				"		foo()\n" + //$NON-NLS-1$
6944
				"		foo()\n" + //$NON-NLS-1$
6945
				"	}"; //$NON-NLS-1$
6945
				"	}"; //$NON-NLS-1$
6946
		checkSourceRange(methodDeclaration, expectedSource, source);
6946
		checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
6947
		Block block = methodDeclaration.getBody();
6947
		Block block = methodDeclaration.getBody();
6948
		expectedSource =
6948
		expectedSource =
6949
				"{\n" + //$NON-NLS-1$
6949
				"{\n" + //$NON-NLS-1$
Lines 6999-7005 Link Here
6999
				"public void fails() {\n" + //$NON-NLS-1$
6999
				"public void fails() {\n" + //$NON-NLS-1$
7000
				"		foo()\n" + //$NON-NLS-1$
7000
				"		foo()\n" + //$NON-NLS-1$
7001
				"	}"; //$NON-NLS-1$
7001
				"	}"; //$NON-NLS-1$
7002
		checkSourceRange(methodDeclaration, expectedSource, source);
7002
		checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
7003
		Block block = methodDeclaration.getBody();
7003
		Block block = methodDeclaration.getBody();
7004
		expectedSource =
7004
		expectedSource =
7005
				"{\n" + //$NON-NLS-1$
7005
				"{\n" + //$NON-NLS-1$
Lines 8182-8188 Link Here
8182
			"		z\n" +  //$NON-NLS-1$
8182
			"		z\n" +  //$NON-NLS-1$
8183
			"	}\n" +  //$NON-NLS-1$
8183
			"	}\n" +  //$NON-NLS-1$
8184
			"}"; //$NON-NLS-1$
8184
			"}"; //$NON-NLS-1$
8185
		checkSourceRange(node, expectedSource, source);
8185
		checkSourceRange(node, expectedSource, source, true/*expectMalformed*/);
8186
		int methodEndPosition = node.getStartPosition() + node.getLength();
8186
		int methodEndPosition = node.getStartPosition() + node.getLength();
8187
		node = getASTNode(compilationUnit, 0);
8187
		node = getASTNode(compilationUnit, 0);
8188
		assertNotNull("not null", node); //$NON-NLS-1$
8188
		assertNotNull("not null", node); //$NON-NLS-1$
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTest.java (-3 / +3 lines)
Lines 7116-7122 Link Here
7116
				"public void fails() {\n" + //$NON-NLS-1$
7116
				"public void fails() {\n" + //$NON-NLS-1$
7117
				"		foo()\n" + //$NON-NLS-1$
7117
				"		foo()\n" + //$NON-NLS-1$
7118
				"	}"; //$NON-NLS-1$
7118
				"	}"; //$NON-NLS-1$
7119
		checkSourceRange(methodDeclaration, expectedSource, source);
7119
		checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
7120
		Block block = methodDeclaration.getBody();
7120
		Block block = methodDeclaration.getBody();
7121
		expectedSource =
7121
		expectedSource =
7122
				"{\n" + //$NON-NLS-1$
7122
				"{\n" + //$NON-NLS-1$
Lines 7171-7177 Link Here
7171
				"public void fails() {\n" + //$NON-NLS-1$
7171
				"public void fails() {\n" + //$NON-NLS-1$
7172
				"		foo()\n" + //$NON-NLS-1$
7172
				"		foo()\n" + //$NON-NLS-1$
7173
				"	}"; //$NON-NLS-1$
7173
				"	}"; //$NON-NLS-1$
7174
		checkSourceRange(methodDeclaration, expectedSource, source);
7174
		checkSourceRange(methodDeclaration, expectedSource, source, true/*expectMalformed*/);
7175
		Block block = methodDeclaration.getBody();
7175
		Block block = methodDeclaration.getBody();
7176
		expectedSource =
7176
		expectedSource =
7177
				"{\n" + //$NON-NLS-1$
7177
				"{\n" + //$NON-NLS-1$
Lines 8350-8356 Link Here
8350
			"		z\n" +  //$NON-NLS-1$
8350
			"		z\n" +  //$NON-NLS-1$
8351
			"	}\n" +  //$NON-NLS-1$
8351
			"	}\n" +  //$NON-NLS-1$
8352
			"}"; //$NON-NLS-1$
8352
			"}"; //$NON-NLS-1$
8353
		checkSourceRange(node, expectedSource, source);
8353
		checkSourceRange(node, expectedSource, source, true /*expectMalformed*/);
8354
		int methodEndPosition = node.getStartPosition() + node.getLength();
8354
		int methodEndPosition = node.getStartPosition() + node.getLength();
8355
		node = getASTNode(compilationUnit, 0);
8355
		node = getASTNode(compilationUnit, 0);
8356
		assertNotNull("not null", node); //$NON-NLS-1$
8356
		assertNotNull("not null", node); //$NON-NLS-1$
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java (-4 / +4 lines)
Lines 1908-1914 Link Here
1908
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
1908
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
1909
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
1909
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
1910
		assertTrue("Is a constructor", !methodDeclaration.isConstructor());
1910
		assertTrue("Is a constructor", !methodDeclaration.isConstructor());
1911
		checkSourceRange(methodDeclaration, "private void foo(){", source);
1911
		checkSourceRange(methodDeclaration, "private void foo(){", source, true/*expectMalformed*/);
1912
		node = getASTNode(compilationUnit, 0, 1);
1912
		node = getASTNode(compilationUnit, 0, 1);
1913
		assertNotNull("No node", node);
1913
		assertNotNull("No node", node);
1914
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
1914
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
Lines 3125-3131 Link Here
3125
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3125
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3126
		MethodDeclaration declaration = (MethodDeclaration) node;
3126
		MethodDeclaration declaration = (MethodDeclaration) node;
3127
		assertTrue("A constructor", !declaration.isConstructor());
3127
		assertTrue("A constructor", !declaration.isConstructor());
3128
		checkSourceRange(declaration, "public method(final int parameter);", source);
3128
		checkSourceRange(declaration, "public method(final int parameter);", source, true/*expectMalformed*/);
3129
	}
3129
	}
3130
3130
3131
	/**
3131
	/**
Lines 3143-3149 Link Here
3143
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3143
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3144
		MethodDeclaration declaration = (MethodDeclaration) node;
3144
		MethodDeclaration declaration = (MethodDeclaration) node;
3145
		assertTrue("A constructor", !declaration.isConstructor());
3145
		assertTrue("A constructor", !declaration.isConstructor());
3146
		checkSourceRange(declaration, "public method(final int parameter) {     }", source);
3146
		checkSourceRange(declaration, "public method(final int parameter) {     }", source, true/*expectMalformed*/);
3147
	}
3147
	}
3148
3148
3149
	/**
3149
	/**
Lines 3280-3286 Link Here
3280
		assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3280
		assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3281
		MethodDeclaration declaration = (MethodDeclaration) node;
3281
		MethodDeclaration declaration = (MethodDeclaration) node;
3282
		assertTrue("Not a constructor", declaration.isConstructor());
3282
		assertTrue("Not a constructor", declaration.isConstructor());
3283
		checkSourceRange(declaration, "public A();", source);
3283
		checkSourceRange(declaration, "public A();", source, true/*expectMalformed*/);
3284
	}
3284
	}
3285
3285
3286
	/**
3286
	/**
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-6 / +6 lines)
Lines 1988-1994 Link Here
1988
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
1988
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
1989
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
1989
		MethodDeclaration methodDeclaration = (MethodDeclaration) node;
1990
		assertTrue("Is a constructor", !methodDeclaration.isConstructor());
1990
		assertTrue("Is a constructor", !methodDeclaration.isConstructor());
1991
		checkSourceRange(methodDeclaration, "private void foo(){", source);
1991
		checkSourceRange(methodDeclaration, "private void foo(){", source, true/*expectMalformed*/);
1992
		node = getASTNode(compilationUnit, 0, 1);
1992
		node = getASTNode(compilationUnit, 0, 1);
1993
		assertNotNull("No node", node);
1993
		assertNotNull("No node", node);
1994
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
1994
		assertTrue("not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
Lines 3203-3209 Link Here
3203
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3203
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3204
		MethodDeclaration declaration = (MethodDeclaration) node;
3204
		MethodDeclaration declaration = (MethodDeclaration) node;
3205
		assertTrue("A constructor", !declaration.isConstructor());
3205
		assertTrue("A constructor", !declaration.isConstructor());
3206
		checkSourceRange(declaration, "public method(final int parameter);", source);
3206
		checkSourceRange(declaration, "public method(final int parameter);", source, true/*expectMalformed*/);
3207
	}
3207
	}
3208
3208
3209
	/**
3209
	/**
Lines 3221-3227 Link Here
3221
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3221
		assertTrue("Not a constructor declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3222
		MethodDeclaration declaration = (MethodDeclaration) node;
3222
		MethodDeclaration declaration = (MethodDeclaration) node;
3223
		assertTrue("A constructor", !declaration.isConstructor());
3223
		assertTrue("A constructor", !declaration.isConstructor());
3224
		checkSourceRange(declaration, "public method(final int parameter) {     }", source);
3224
		checkSourceRange(declaration, "public method(final int parameter) {     }", source, true/*expectMalformed*/);
3225
	}
3225
	}
3226
3226
3227
	/**
3227
	/**
Lines 3358-3364 Link Here
3358
		assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3358
		assertTrue("Not a method declaration", node.getNodeType() == ASTNode.METHOD_DECLARATION); //$NON-NLS-1$
3359
		MethodDeclaration declaration = (MethodDeclaration) node;
3359
		MethodDeclaration declaration = (MethodDeclaration) node;
3360
		assertTrue("Not a constructor", declaration.isConstructor());
3360
		assertTrue("Not a constructor", declaration.isConstructor());
3361
		checkSourceRange(declaration, "public A();", source);
3361
		checkSourceRange(declaration, "public A();", source, true/*expectMalformed*/);
3362
	}
3362
	}
3363
3363
3364
	/**
3364
	/**
Lines 5493-5499 Link Here
5493
			node = getASTNode(compilationUnit, 0, 0);
5493
			node = getASTNode(compilationUnit, 0, 0);
5494
			assertEquals("wrong type", ASTNode.FIELD_DECLARATION, node.getNodeType());
5494
			assertEquals("wrong type", ASTNode.FIELD_DECLARATION, node.getNodeType());
5495
			FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
5495
			FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
5496
			checkSourceRange(fieldDeclaration, "d String[][]", source.toCharArray());
5496
			checkSourceRange(fieldDeclaration, "d String[][]", source.toCharArray(), true/*expectMalformed*/);
5497
			Type type = fieldDeclaration.getType();
5497
			Type type = fieldDeclaration.getType();
5498
			assertTrue("Not a simple type", type.isSimpleType());
5498
			assertTrue("Not a simple type", type.isSimpleType());
5499
			List fragments = fieldDeclaration.fragments();
5499
			List fragments = fieldDeclaration.fragments();
Lines 7243-7249 Link Here
7243
		List fragments = fieldDeclaration.fragments();
7243
		List fragments = fieldDeclaration.fragments();
7244
		assertEquals("wrong size", 1, fragments.size());
7244
		assertEquals("wrong size", 1, fragments.size());
7245
		VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
7245
		VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
7246
		checkSourceRange(fragment, "s =  {\"\",,,", source);
7246
		checkSourceRange(fragment, "s =  {\"\",,,", source, true/*expectMalformed*/);
7247
		assertTrue("Not initializer", fragment.getInitializer() == null);
7247
		assertTrue("Not initializer", fragment.getInitializer() == null);
7248
		assertTrue("Not a malformed node", isMalformed(fragment));
7248
		assertTrue("Not a malformed node", isMalformed(fragment));
7249
	}
7249
	}
(-)src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java (+7 lines)
Lines 559-564 Link Here
559
	}
559
	}
560
560
561
	protected void checkSourceRange(ASTNode node, String expectedContents, char[] source) {
561
	protected void checkSourceRange(ASTNode node, String expectedContents, char[] source) {
562
		checkSourceRange(node, expectedContents, source, false);
563
	}
564
	protected void checkSourceRange(ASTNode node, String expectedContents, char[] source, boolean expectMalformed) {
562
		assertNotNull("The node is null", node); //$NON-NLS-1$
565
		assertNotNull("The node is null", node); //$NON-NLS-1$
563
		assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); //$NON-NLS-1$ //$NON-NLS-2$
566
		assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); //$NON-NLS-1$ //$NON-NLS-2$
564
		assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1); //$NON-NLS-1$
567
		assertTrue("The node.getStartPosition() == -1", node.getStartPosition() != -1); //$NON-NLS-1$
Lines 568-573 Link Here
568
		System.arraycopy(source, start, actualContents, 0, length);
571
		System.arraycopy(source, start, actualContents, 0, length);
569
		String actualContentsString = new String(actualContents);
572
		String actualContentsString = new String(actualContents);
570
		assertSourceEquals("Unexpected source", Util.convertToIndependantLineDelimiter(expectedContents), Util.convertToIndependantLineDelimiter(actualContentsString));
573
		assertSourceEquals("Unexpected source", Util.convertToIndependantLineDelimiter(expectedContents), Util.convertToIndependantLineDelimiter(actualContentsString));
574
		if (expectMalformed)
575
			assertTrue("Is not malformed", isMalformed(node));
576
		else
577
			assertFalse("Is malformed", isMalformed(node));
571
	}
578
	}
572
579
573
	protected boolean isMalformed(ASTNode node) {
580
	protected boolean isMalformed(ASTNode node) {

Return to bug 331736