/** This should create an AST without imports or method-body statements */
  public static CompilationUnit createAST(
      IJavaProject javaProject, final ICompilationUnit compilationUnit) {
    if (compilationUnit == null) return null;

    class CompilationUnitRequestor extends ASTRequestor {
      CompilationUnit domUnit = EMPTY_AST_UNIT;

      public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
        if (source == compilationUnit) domUnit = ast;
      }
    }

    CompilationUnitRequestor requestor = new CompilationUnitRequestor();
    ASTParser p = ASTParser.newParser(AST.JLS3);
    p.setResolveBindings(true);
    p.setBindingsRecovery(true);
    p.setProject(javaProject);
    p.setKind(ASTParser.K_COMPILATION_UNIT);
    p.setIgnoreMethodBodies(true);
    p.createASTs(new ICompilationUnit[] {compilationUnit}, NO_KEYS, requestor, null);
    if (AptPlugin.DEBUG) {
      AptPlugin.trace("created DOM AST for " + compilationUnit.getElementName()); // $NON-NLS-1$
    }
    return requestor.domUnit;
  }
 public IdeProcessingEnvImpl(
     IdeAnnotationProcessorManager dispatchManager, IJavaProject jproject, Compiler compiler) {
   _dispatchManager = dispatchManager;
   _javaProject = jproject;
   _compiler = compiler;
   _aptProject = AptPlugin.getAptProject(jproject);
   _filer = new IdeFilerImpl(_dispatchManager, this);
   _messager = new IdeMessagerImpl(_dispatchManager, this);
 }
 public BaseProcessorEnv(
     CompilationUnit astCompilationUnit, IFile file, IJavaProject javaProj, Phase phase) {
   _astRoot = astCompilationUnit;
   _file = file;
   _javaProject = javaProj;
   _phase = phase;
   _options = initOptions(javaProj);
   _modelCompUnit2astCompUnit = new HashMap<ICompilationUnit, CompilationUnit>();
   _typeBinding2ModelCompUnit = new HashMap<ITypeBinding, ICompilationUnit>();
   _aptProject = AptPlugin.getAptProject(javaProj);
 }
  // does not generate dependencies
  public TypeDeclaration getTypeDeclaration(String name) {
    if (name == null || name.length() == 0) return null;

    // get rid of the generics parts.
    final int index = name.indexOf('<');
    if (index != -1) name = name.substring(0, index);

    ITypeBinding typeBinding = null;
    try {
      typeBinding = getTypeDefinitionBindingFromName(name);
    } catch (ArrayIndexOutOfBoundsException e) {
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=133947
      // if the name is invalid, JDT can throw an ArrayIndexOutOfBoundsException
      // We'll ignore this and return null to the user
      AptPlugin.log(e, "Unable to get type definition binding for: " + name); // $NON-NLS-1$
    }

    return Factory.createReferenceType(typeBinding, this);
  }