ASTParser p= ASTParser.newParser(AST.JLS3); p.setSource(newCuSource.toCharArray()); p.setUnitName(compilationUnit.getElementName()); p.setProject(compilationUnit.getJavaProject()); p.setCompilerOptions(RefactoringASTParser.getCompilerOptions(compilationUnit)); p.setResolveBindings(true); CompilationUnit newCUNode= (CompilationUnit) p.createAST(null);
CompilationUnit newCUNode= new RefactoringASTParser(AST.JLS3).parse(newCuSource, compilationUnit, true, null);
	public static RefactoringStatus analyzeLocalRenames(LocalAnalyzePackage[] analyzePackages, TextChange cuChange, CompilationUnit oldCUNode) throws CoreException {		RefactoringStatus result= new RefactoringStatus();		ICompilationUnit compilationUnit= (ICompilationUnit) oldCUNode.getJavaElement();		String newCuSource= cuChange.getPreviewContent(new NullProgressMonitor());		// note: although bindings are not explicitly requested,		// they will be resolved during parsing anyway		ASTParser p= ASTParser.newParser(AST.JLS3);		p.setSource(newCuSource.toCharArray());		p.setUnitName(compilationUnit.getElementName());		p.setProject(compilationUnit.getJavaProject());		p.setCompilerOptions(RefactoringASTParser.getCompilerOptions(compilationUnit));		p.setResolveBindings(true);		CompilationUnit newCUNode= (CompilationUnit) p.createAST(null);		result.merge(analyzeCompileErrors(newCuSource, newCUNode, oldCUNode));		if (result.hasError())			return result;		for (int i= 0; i < analyzePackages.length; i++) {			ASTNode enclosing= getEnclosingBlockOrMethod(analyzePackages[i].fDeclarationEdit, cuChange, newCUNode);			// get new declaration			IRegion newRegion= RefactoringAnalyzeUtil.getNewTextRange(analyzePackages[i].fDeclarationEdit, cuChange);			ASTNode newDeclaration= NodeFinder.perform(newCUNode, newRegion.getOffset(), newRegion.getLength());			Assert.isTrue(newDeclaration instanceof Name);			VariableDeclaration declaration= getVariableDeclaration((Name) newDeclaration);			Assert.isNotNull(declaration);			SimpleName[] problemNodes= ProblemNodeFinder.getProblemNodes(enclosing, declaration, analyzePackages[i].fOccurenceEdits, cuChange);			result.merge(RefactoringAnalyzeUtil.reportProblemNodes(newCuSource, problemNodes));		}		return result;	}