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

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-3 / +3 lines)
Lines 1369-1375 Link Here
1369
					this.expressionStack[this.expressionPtr],
1369
					this.expressionStack[this.expressionPtr],
1370
					this.expressionStack[this.expressionPtr + 1]);
1370
					this.expressionStack[this.expressionPtr + 1]);
1371
	}
1371
	}
1372
	exp.sourceEnd = this.endPosition;
1372
	exp.sourceEnd = this.endStatementPosition;
1373
}
1373
}
1374
protected void consumeArrayCreationExpressionWithInitializer() {
1374
protected void consumeArrayCreationExpressionWithInitializer() {
1375
	// ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
1375
	// ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
Lines 1392-1398 Link Here
1392
		length);
1392
		length);
1393
	arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1393
	arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1394
	if (arrayAllocation.initializer == null) {
1394
	if (arrayAllocation.initializer == null) {
1395
		arrayAllocation.sourceEnd = this.endPosition;
1395
		arrayAllocation.sourceEnd = this.endStatementPosition;
1396
	} else {
1396
	} else {
1397
		arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1397
		arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1398
	}
1398
	}
Lines 1416-1422 Link Here
1416
		length);
1416
		length);
1417
	arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1417
	arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1418
	if (arrayAllocation.initializer == null) {
1418
	if (arrayAllocation.initializer == null) {
1419
		arrayAllocation.sourceEnd = this.endPosition;
1419
		arrayAllocation.sourceEnd = this.endStatementPosition;
1420
	} else {
1420
	} else {
1421
		arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1421
		arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1422
	}
1422
	}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (-1 / +145 lines)
Lines 7801-7805 Link Here
7801
			if (workingCopy != null)
7801
			if (workingCopy != null)
7802
				workingCopy.discardWorkingCopy();
7802
				workingCopy.discardWorkingCopy();
7803
		}
7803
		}
7804
	}	
7804
	}
7805
	
7806
	/**
7807
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877
7808
	 */
7809
	public void test0648() throws JavaModelException {
7810
		ICompilationUnit workingCopy = null;
7811
		try {
7812
			String contents =
7813
				"public class X {\n" + 
7814
				"    public void foo(int[] a) {\n" + 
7815
				"        int i = a[0];\n" + 
7816
				"    }\n" + 
7817
				"}";
7818
			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
7819
			ASTNode node = buildAST(
7820
				contents,
7821
				workingCopy,
7822
				false,
7823
				true);
7824
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7825
			CompilationUnit unit = (CompilationUnit) node;
7826
			assertProblemsSize(unit, 0);
7827
			node = getASTNode(unit, 0, 0, 0);
7828
			assertEquals("Not a vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
7829
			VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
7830
			List fragments = statement.fragments();
7831
			assertEquals("Wrong size", 1, fragments.size());
7832
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
7833
			Expression expression = fragment.getInitializer();
7834
			assertNotNull("No initializer", expression);
7835
			checkSourceRange(expression, "a[0]", contents);
7836
		} finally {
7837
			if (workingCopy != null)
7838
				workingCopy.discardWorkingCopy();
7839
		}
7840
	}
7841
	
7842
	/**
7843
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877
7844
	 */
7845
	public void test0649() throws JavaModelException {
7846
		ICompilationUnit workingCopy = null;
7847
		try {
7848
			String contents =
7849
				"public class X {\n" + 
7850
				"    public void foo(int[] a) {\n" + 
7851
				"        int i = a[0\\u005D;\n" + 
7852
				"    }\n" + 
7853
				"}";
7854
			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
7855
			ASTNode node = buildAST(
7856
				contents,
7857
				workingCopy,
7858
				false,
7859
				true);
7860
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7861
			CompilationUnit unit = (CompilationUnit) node;
7862
			assertProblemsSize(unit, 0);
7863
			node = getASTNode(unit, 0, 0, 0);
7864
			assertEquals("Not a vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
7865
			VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
7866
			List fragments = statement.fragments();
7867
			assertEquals("Wrong size", 1, fragments.size());
7868
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
7869
			Expression expression = fragment.getInitializer();
7870
			assertNotNull("No initializer", expression);
7871
			checkSourceRange(expression, "a[0\\u005D", contents);
7872
		} finally {
7873
			if (workingCopy != null)
7874
				workingCopy.discardWorkingCopy();
7875
		}
7876
	}
7877
	
7878
	/**
7879
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877
7880
	 */
7881
	public void test0650() throws JavaModelException {
7882
		ICompilationUnit workingCopy = null;
7883
		try {
7884
			String contents =
7885
				"public class X {\n" + 
7886
				"    public void foo(int[] a) {\n" + 
7887
				"        int[] i = new int[0];\n" + 
7888
				"    }\n" + 
7889
				"}";
7890
			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
7891
			ASTNode node = buildAST(
7892
				contents,
7893
				workingCopy,
7894
				false,
7895
				true);
7896
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7897
			CompilationUnit unit = (CompilationUnit) node;
7898
			assertProblemsSize(unit, 0);
7899
			node = getASTNode(unit, 0, 0, 0);
7900
			assertEquals("Not a vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
7901
			VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
7902
			List fragments = statement.fragments();
7903
			assertEquals("Wrong size", 1, fragments.size());
7904
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
7905
			Expression expression = fragment.getInitializer();
7906
			assertNotNull("No initializer", expression);
7907
			checkSourceRange(expression, "new int[0]", contents);
7908
		} finally {
7909
			if (workingCopy != null)
7910
				workingCopy.discardWorkingCopy();
7911
		}
7912
	}
7913
	
7914
	/**
7915
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=147877
7916
	 */
7917
	public void test0651() throws JavaModelException {
7918
		ICompilationUnit workingCopy = null;
7919
		try {
7920
			String contents =
7921
				"public class X {\n" + 
7922
				"    public void foo(int[] a) {\n" + 
7923
				"        int[] i = new int[0\\u005D;\n" + 
7924
				"    }\n" + 
7925
				"}";
7926
			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
7927
			ASTNode node = buildAST(
7928
				contents,
7929
				workingCopy,
7930
				false,
7931
				true);
7932
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7933
			CompilationUnit unit = (CompilationUnit) node;
7934
			assertProblemsSize(unit, 0);
7935
			node = getASTNode(unit, 0, 0, 0);
7936
			assertEquals("Not a vaviable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType());
7937
			VariableDeclarationStatement statement = (VariableDeclarationStatement) node;
7938
			List fragments = statement.fragments();
7939
			assertEquals("Wrong size", 1, fragments.size());
7940
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
7941
			Expression expression = fragment.getInitializer();
7942
			assertNotNull("No initializer", expression);
7943
			checkSourceRange(expression, "new int[0\\u005D", contents);
7944
		} finally {
7945
			if (workingCopy != null)
7946
				workingCopy.discardWorkingCopy();
7947
		}
7948
	}
7805
}
7949
}

Return to bug 147877