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

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java (+49 lines)
Lines 7686-7689 Link Here
7686
				workingCopy.discardWorkingCopy();
7686
				workingCopy.discardWorkingCopy();
7687
		}
7687
		}
7688
	}
7688
	}
7689
	/**
7690
	 * http://dev.eclipse.org/bugs/show_bug.cgi?id=135997
7691
	 */
7692
	public void test0645() throws JavaModelException {
7693
		ICompilationUnit workingCopy = null;
7694
		try {
7695
			String contents =
7696
				"public class X {\n" +
7697
				"	{\n" + 
7698
				"	   new Object();\n" + 
7699
				"	   Object.equ;\n" + 
7700
				"	}\n" +
7701
				"}";
7702
			workingCopy = getWorkingCopy("/Converter/src/X.java", true/*resolve*/);
7703
			ASTNode node = buildAST(
7704
				contents,
7705
				workingCopy,
7706
				false,
7707
				true);
7708
			assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
7709
			CompilationUnit unit = (CompilationUnit) node;
7710
			assertProblemsSize(
7711
					unit,
7712
					2,
7713
					"Object.equ cannot be resolved\n" + 
7714
					"Syntax error, insert \"AssignmentOperator Expression\" to complete Expression");
7715
			node = getASTNode(unit, 0, 0);
7716
			assertEquals("Not a field declaration statement", ASTNode.INITIALIZER, node.getNodeType());
7717
			Initializer initializer = (Initializer) node;
7718
			checkSourceRange(
7719
					initializer,
7720
					"{\n" + 
7721
					"	   new Object();\n" + 
7722
					"	   Object.equ;\n" + 
7723
					"	}",
7724
					contents);
7725
			Block block = initializer.getBody();
7726
			checkSourceRange(
7727
					block,
7728
					"{\n" + 
7729
					"	   new Object();\n" + 
7730
					"	   Object.equ;\n" + 
7731
					"	}",
7732
					contents);
7733
		} finally {
7734
			if (workingCopy != null)
7735
				workingCopy.discardWorkingCopy();
7736
		}
7737
	}
7689
}
7738
}
(-)compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java (-1 / +5 lines)
Lines 276-282 Link Here
276
	}
276
	}
277
277
278
	if (this.blockDeclaration.sourceEnd == 0) {
278
	if (this.blockDeclaration.sourceEnd == 0) {
279
		this.blockDeclaration.sourceEnd = lastEnd;
279
		if(lastEnd < bodyEndValue) {
280
			this.blockDeclaration.sourceEnd = bodyEndValue;
281
		} else {
282
			this.blockDeclaration.sourceEnd = lastEnd;
283
		}
280
	}
284
	}
281
	
285
	
282
	return this.blockDeclaration;
286
	return this.blockDeclaration;

Return to bug 135997