Bug 118897 ASTParser resolves bindings without request
I20051130-1215 ASTParser resolves bindings without request when certain conditions hold, although setResolveBindings(true) has not been called. The following extract from internalCreateAST(IProgressMonitor) looks suspicios: if (this.rawSource != null) { needToResolveBindings = this.unitName != null && this.project != null && this.compilerOptions != null; ... I would not expect to get bindings unless I explicitly requested them. This can be a serious performance hit for clients that only need lightweight ASTs.
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/TypeRulesTest.java
ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null);
		ASTParser parser= ASTParser.newParser(AST.JLS3);
		parser.setSource(cu1);
		parser.setResolveBindings(true);
		
		CompilationUnit astRoot= (CompilationUnit) parser.createAST(null);
		IProblem[] problems= astRoot.getProblems();
		assertNumberOf("problems", problems.length, 0);
		
		TypeDeclaration type= (TypeDeclaration) astRoot.types().get(0);
		FieldDeclaration[] fields= type.getFields();
		
		VariableDeclarationFragment[] targets= new VariableDeclarationFragment[fields.length];
		for (int i= 0; i < fields.length; i++) {
			targets[i]= (VariableDeclarationFragment) fields[i].fragments().get(0);
		}
		return targets;
	}
	
	
	public void testIsAssignmentCompatible() throws Exception {
		VariableDeclarationFragment[] targets= createVariables();
		
		StringBuffer errors= new StringBuffer();
		for (int k= 0; k < targets.length; k++) {
			for (int n= 0; n < targets.length; n++) {
				VariableDeclarationFragment f1= targets[k];
				VariableDeclarationFragment f2= targets[n];
				String line= f2.getName().getIdentifier() + "= " + f1.getName().getIdentifier();