try { CompilationUnit root= (CompilationUnit)parser.createAST(progressMonitor);  ASTNodes.setFlagsToAST(root, ASTNode.PROTECT);  return root; } catch (IllegalStateException ex) { return null; }
final CompilationUnit root[]= new CompilationUnit[1];  Platform.run(new ISafeRunnable() { public void run() { root[0]= (CompilationUnit)parser.createAST(progressMonitor); } public void handleException(Throwable ex) { IStatus status= new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.OK, "Error in JDT Core during AST creation", ex); JavaPlugin.getDefault().getLog().log(status); } });   if (root[0] != null) ASTNodes.setFlagsToAST(root[0], ASTNode.PROTECT);  return root[0];
	private CompilationUnit createAST(IJavaElement je, IProgressMonitor progressMonitor) {		ASTParser parser = ASTParser.newParser(AST_LEVEL);		parser.setResolveBindings(true);		if (je.getElementType() == IJavaElement.COMPILATION_UNIT)			parser.setSource((ICompilationUnit)je);		else if (je.getElementType() == IJavaElement.CLASS_FILE)			parser.setSource((IClassFile)je);		if (progressMonitor != null && progressMonitor.isCanceled())			return null;		try {			CompilationUnit root= (CompilationUnit)parser.createAST(progressMonitor);			// mark as unmodifiable			ASTNodes.setFlagsToAST(root, ASTNode.PROTECT);			return root;		} catch (IllegalStateException ex) {			return null;		}	}