View | Details | Raw Unified | Return to bug 287701
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-4 / +5 lines)
Lines 1657-1673 Link Here
1657
	int op = this.intStack[this.intPtr--] ; //<--the encoded operator
1657
	int op = this.intStack[this.intPtr--] ; //<--the encoded operator
1658
1658
1659
	this.expressionPtr -- ; this.expressionLengthPtr -- ;
1659
	this.expressionPtr -- ; this.expressionLengthPtr -- ;
1660
	Expression expression = this.expressionStack[this.expressionPtr+1];
1660
	this.expressionStack[this.expressionPtr] =
1661
	this.expressionStack[this.expressionPtr] =
1661
		(op != EQUAL ) ?
1662
		(op != EQUAL ) ?
1662
			new CompoundAssignment(
1663
			new CompoundAssignment(
1663
				this.expressionStack[this.expressionPtr] ,
1664
				this.expressionStack[this.expressionPtr] ,
1664
				this.expressionStack[this.expressionPtr+1],
1665
				expression,
1665
				op,
1666
				op,
1666
				this.scanner.startPosition - 1)	:
1667
				expression.sourceEnd):
1667
			new Assignment(
1668
			new Assignment(
1668
				this.expressionStack[this.expressionPtr] ,
1669
				this.expressionStack[this.expressionPtr] ,
1669
				this.expressionStack[this.expressionPtr+1],
1670
				expression,
1670
				this.scanner.startPosition - 1);
1671
				expression.sourceEnd);
1671
1672
1672
	if (this.pendingRecoveredType != null) {
1673
	if (this.pendingRecoveredType != null) {
1673
		// Used only in statements recovery.
1674
		// Used only in statements recovery.
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java (-2 / +3 lines)
Lines 325-334 Link Here
325
		finallyBlock.sourceEnd = end;
325
		finallyBlock.sourceEnd = end;
326
		finallyBlock.statements = new Statement[varCount];
326
		finallyBlock.statements = new Statement[varCount];
327
		for (int i = 0; i < varCount; i++){
327
		for (int i = 0; i < varCount; i++){
328
			SingleNameReference nameRef = new SingleNameReference(this.evaluationContext.localVariableNames[i], position);
328
			finallyBlock.statements[i] = new Assignment(
329
			finallyBlock.statements[i] = new Assignment(
329
				new SingleNameReference(CharOperation.concat(LOCAL_VAR_PREFIX, this.evaluationContext.localVariableNames[i]), position),
330
				new SingleNameReference(CharOperation.concat(LOCAL_VAR_PREFIX, this.evaluationContext.localVariableNames[i]), position),
330
				new SingleNameReference(this.evaluationContext.localVariableNames[i], position),
331
				nameRef,
331
				(int) position);
332
				nameRef.sourceEnd);
332
		}
333
		}
333
		tryStatement.finallyBlock = finallyBlock;
334
		tryStatement.finallyBlock = finallyBlock;
334
335
(-)src/org/eclipse/jdt/core/tests/dom/ConverterTestSetup.java (+7 lines)
Lines 541-546 Link Here
541
		return (ASTNode) unit.types().get(typeIndex);
541
		return (ASTNode) unit.types().get(typeIndex);
542
	}
542
	}
543
543
544
	protected void checkSourceRange(int start, int length, String expectedContents, String source) {
545
		assertTrue("length == 0", length != 0); //$NON-NLS-1$ //$NON-NLS-2$
546
		assertTrue("start == -1", start != -1); //$NON-NLS-1$
547
		String actualContentsString = source.substring(start, start + length);
548
		assertSourceEquals("Unexpected source", Util.convertToIndependantLineDelimiter(expectedContents), Util.convertToIndependantLineDelimiter(actualContentsString));
549
	}
550
544
	protected void checkSourceRange(ASTNode node, String expectedContents, String source) {
551
	protected void checkSourceRange(ASTNode node, String expectedContents, String source) {
545
		assertNotNull("The node is null", node); //$NON-NLS-1$
552
		assertNotNull("The node is null", node); //$NON-NLS-1$
546
		assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); //$NON-NLS-1$ //$NON-NLS-2$
553
		assertTrue("The node(" + node.getClass() + ").getLength() == 0", node.getLength() != 0); //$NON-NLS-1$ //$NON-NLS-2$
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +42 lines)
Lines 47-53 Link Here
47
	}
47
	}
48
48
49
	static {
49
	static {
50
//		TESTS_NUMBERS = new int[] { 334 };
50
//		TESTS_NUMBERS = new int[] { 337 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
52
//		TESTS_NAMES = new String[] {"test0204"};
52
//		TESTS_NAMES = new String[] {"test0204"};
53
	}
53
	}
Lines 10802-10805 Link Here
10802
		IVariableBinding variableBinding = (IVariableBinding) memberValuePair.getValue();
10802
		IVariableBinding variableBinding = (IVariableBinding) memberValuePair.getValue();
10803
		assertEquals("Wrong field", "CLASS", variableBinding.getName());
10803
		assertEquals("Wrong field", "CLASS", variableBinding.getName());
10804
	}
10804
	}
10805
	/*
10806
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=287701
10807
	 */
10808
	public void test0337() throws JavaModelException {
10809
		String contents =
10810
			"public class X {\n" + 
10811
			"        void m() {\n" + 
10812
			"                int x= 1      ;\n" + 
10813
			"                int y= - 1  , z=0   ;\n" + 
10814
			"                // Assignment nodes too long:\n" + 
10815
			"                int a= x = 2      ;\n" + 
10816
			"                System.out.print(    x=1     );\n" + 
10817
			"                java.util.Arrays.asList(    x = 1    /*bla*/  , x= 2\n" + 
10818
			"                        // comment      \n" + 
10819
			"                );\n" + 
10820
			"        }\n" + 
10821
			"}\n" + 
10822
			"";
10823
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
10824
		CompilationUnit unit= (CompilationUnit) buildAST(
10825
			contents,
10826
			this.workingCopy,
10827
			true,
10828
			true,
10829
			true);
10830
		ASTNode node = getASTNode(unit, 0, 0, 2);
10831
		checkSourceRange(node, "int a= x = 2      ;", contents);
10832
		VariableDeclarationFragment fragment = (VariableDeclarationFragment) ((VariableDeclarationStatement) node).fragments().get(0);
10833
		checkSourceRange(fragment, "a= x = 2", contents);
10834
		node = getASTNode(unit, 0, 0, 3);
10835
		Expression expression = (Expression) ((MethodInvocation) ((ExpressionStatement) node).getExpression()).arguments().get(0);
10836
		checkSourceRange(expression, "x=1", contents);
10837
		node = getASTNode(unit, 0, 0, 4);
10838
		List arguments = ((MethodInvocation) ((ExpressionStatement) node).getExpression()).arguments();
10839
		ASTNode node2 = (ASTNode) arguments.get(0);
10840
		checkSourceRange(node2, "x = 1", contents);
10841
		checkSourceRange((ASTNode) arguments.get(1), "x= 2", contents);
10842
		int extendedLength = unit.getExtendedLength(node2);
10843
		int extendedStartPosition = unit.getExtendedStartPosition(node2);
10844
		checkSourceRange(extendedStartPosition, extendedLength, "x = 1    /*bla*/", contents);
10845
	}
10805
}
10846
}

Return to bug 287701