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

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (+4 lines)
Lines 9722-9727 Link Here
9722
	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9722
	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9723
	if(this.options.performMethodsFullRecovery) {
9723
	if(this.options.performMethodsFullRecovery) {
9724
		this.methodRecoveryActivated = true;
9724
		this.methodRecoveryActivated = true;
9725
		// we should not relocate bodyStart if there is a block within the statements
9726
		this.ignoreNextOpeningBrace = true;
9725
	}
9727
	}
9726
9728
9727
	initialize();
9729
	initialize();
Lines 9971-9976 Link Here
9971
9973
9972
	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9974
	boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9973
	if(this.options.performMethodsFullRecovery) {
9975
	if(this.options.performMethodsFullRecovery) {
9976
		// we should not relocate bodyStart if there is a block within the statements
9977
		this.ignoreNextOpeningBrace = true;
9974
		this.methodRecoveryActivated = true;
9978
		this.methodRecoveryActivated = true;
9975
		this.rParenPos = md.sourceEnd;
9979
		this.rParenPos = md.sourceEnd;
9976
	}
9980
	}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST4_2.java (-1 / +44 lines)
Lines 122-128 Link Here
122
	static {
122
	static {
123
//		TESTS_NAMES = new String[] {"test0602"};
123
//		TESTS_NAMES = new String[] {"test0602"};
124
//		TESTS_RANGE = new int[] { 721, -1 };
124
//		TESTS_RANGE = new int[] { 721, -1 };
125
//		TESTS_NUMBERS =  new int[] { 721, 722, 723, 724, 725 };
125
//		TESTS_NUMBERS =  new int[] { 723, 724 };
126
	}
126
	}
127
	public static Test suite() {
127
	public static Test suite() {
128
		return buildModelTestSuite(ASTConverterTestAST4_2.class);
128
		return buildModelTestSuite(ASTConverterTestAST4_2.class);
Lines 10641-10644 Link Here
10641
			}
10641
			}
10642
		}
10642
		}
10643
	}
10643
	}
10644
	/**
10645
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=347396
10646
	 */
10647
	public void test0723() {
10648
		ASTParser parser = ASTParser.newParser(AST.JLS4);
10649
		parser.setKind (ASTParser.K_STATEMENTS);
10650
		String src = "int j;\nfor {};\nj=1000;";
10651
		char[] source = src.toCharArray();
10652
		parser.setStatementsRecovery(true);
10653
		parser.setSource(source);
10654
		ASTNode result = parser.createAST (null);
10655
		assertNotNull("no result", result);
10656
		assertEquals("Wrong type", ASTNode.BLOCK, result.getNodeType());
10657
		Block block = (Block) result;
10658
		List statements = block.statements();
10659
		assertNotNull("No statements", statements);
10660
		assertEquals("Wrong size", 3, statements.size());
10661
		assertFalse(isRecovered((ASTNode) statements.get(0)));
10662
		assertFalse(isRecovered((ASTNode) statements.get(1)));
10663
		assertFalse(isRecovered((ASTNode) statements.get(2)));
10664
	}
10665
10666
	/**
10667
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=347396
10668
	 */
10669
	public void test0724() {
10670
		ASTParser parser = ASTParser.newParser(AST.JLS4);
10671
		parser.setKind (ASTParser.K_COMPILATION_UNIT);
10672
		String src = "public class X { void foo() {int j;\nfor {};\nj=1000;}}";
10673
		char[] source = src.toCharArray();
10674
		parser.setStatementsRecovery(true);
10675
		parser.setSource(source);
10676
		ASTNode result = parser.createAST (null);
10677
		assertNotNull("no result", result);
10678
		assertEquals("Wrong type", ASTNode.COMPILATION_UNIT, result.getNodeType());
10679
		Block block = ((MethodDeclaration) getASTNode((CompilationUnit) result, 0, 0)).getBody();
10680
		List statements = block.statements();
10681
		assertNotNull("No statements", statements);
10682
		assertEquals("Wrong size", 3, statements.size());
10683
		assertFalse(isRecovered((ASTNode) statements.get(0)));
10684
		assertFalse(isRecovered((ASTNode) statements.get(1)));
10685
		assertFalse(isRecovered((ASTNode) statements.get(2)));
10686
	}
10644
}
10687
}

Return to bug 347396