/*
(non-Javadoc)

@see javax.annotation.processing.AbstractProcessor#process(java.util.Set,
javax.annotation.processing.RoundEnvironment)
167103
@Override
	public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
		model = new M2MModel();

		for (Element daoItem : roundEnv.getElementsAnnotatedWith(BindDaoMany2Many.class)) {
			if (daoItem.getKind() != ElementKind.INTERFACE) {
				String msg = String.format("%s %s, only interface can be annotated with @%s annotation",
						daoItem.getKind(), daoItem, BindDaoMany2Many.class.getSimpleName());
				throw (new InvalidKindForAnnotationException(msg));
			}

			M2MEntity entity = M2MEntity.extractEntityManagedByDAO((TypeElement) daoItem);

			model.entityAdd(entity);
		}

		result = BindM2MBuilder.generate(filer, model);

		return true;
	}
592665
private void writeReactionSet(IReactionSet reactions) throws CDKException {

        for (IReaction iReaction : reactions.reactions()) {
            writeReaction(iReaction);
        }
    }
970025
@Override
	public synchronized void init(ProcessingEnvironment processingEnv) {
		super.init(processingEnv);

		KriptonProcessor.trees = Trees.instance(processingEnv);

		KriptonOptions.init(this, processingEnv);

		typeProcessor.init(processingEnv);
		many2ManyProcessor.init(processingEnv);
		sharedPreferencesProcessor.init(processingEnv);
		dataSourceProcessor.init(processingEnv);

		count = 0;
	}
1002718
@Override public boolean process(Set<? extends TypeElement> types, RoundEnvironment env) {
    if (!env.processingOver()) {
      // Storing module names for later retrieval as the element instance is invalidated across
      // passes.
      for (Element e : env.getElementsAnnotatedWith(Module.class)) {
        if (!(e instanceof TypeElement)) {
          error("@Module applies to a type, " + e.getSimpleName() + " is a " + e.getKind(), e);
          continue;
        }
        delayedModuleNames.add(((TypeElement) e).getQualifiedName().toString());
      }
      return false;
    }

    Set<Element> modules = new LinkedHashSet<Element>();
    for (String moduleName : delayedModuleNames) {
      modules.add(elements().getTypeElement(moduleName));
    }

    for (Element element : modules) {
      Map<String, Object> annotation = null;
      try {
        annotation = getAnnotation(Module.class, element);
      } catch (CodeGenerationIncompleteException e) {
        continue; // skip this element. An up-stream compiler error is in play.
      }

      TypeElement moduleType = (TypeElement) element;
      if (annotation == null) {
        error("Missing @Module annotation.", moduleType);
        continue;
      }
      if (annotation.get("complete").equals(Boolean.TRUE)) {
        Map<String, Binding<?>> bindings;
        try {
          bindings = processCompleteModule(moduleType, false);
          new ProblemDetector().detectCircularDependencies(bindings.values());
        } catch (ModuleValidationException e) {
          error("Graph validation failed: " + e.getMessage(), e.source);
          continue;
        } catch (InvalidBindingException e) {
          error("Graph validation failed: " + e.getMessage(), elements().getTypeElement(e.type));
          continue;
        } catch (RuntimeException e) {
          if (ERROR_NAMES_TO_PROPAGATE.contains(e.getClass().getName())) {
            throw e;
          }
          error("Unknown error " + e.getClass().getName() + " thrown by javac in graph validation: "
              + e.getMessage(), moduleType);
          continue;
        }
        try {
          writeDotFile(moduleType, bindings);
        } catch (IOException e) {
          StringWriter sw = new StringWriter();
          e.printStackTrace(new PrintWriter(sw));
          processingEnv.getMessager()
              .printMessage(Diagnostic.Kind.WARNING,
                  "Graph visualization failed. Please report this as a bug.\n\n" + sw, moduleType);
        }
      }

      if (annotation.get("library").equals(Boolean.FALSE)) {
        Map<String, Binding<?>> bindings = processCompleteModule(moduleType, true);
        try {
          new ProblemDetector().detectUnusedBinding(bindings.values());
        } catch (IllegalStateException e) {
          error("Graph validation failed: " + e.getMessage(), moduleType);
        }
      }
    }
    return false;
  }
742526
private void processJsonPropertyAnnotations(final RoundEnvironment roundEnv) {
    final Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(JsonProperty.class);
    for (final Element e : elements) {
      if (e.getEnclosingElement() == null) {
        continue;
      }
      final Element parentElement = e.getEnclosingElement().getEnclosingElement();
      if (parentElement == null) {
        continue;
      }
      if (!(parentElement instanceof TypeElement)) {
        continue;
      }
      final TypeElement parent = (TypeElement) parentElement;
      final String parentJavaDoc = processingEnv.getElementUtils().getDocComment(parent);
      final String parentName = parent.getQualifiedName().toString();

      final TransferClass klass = getOrCreateTransferClass(parentName, parentJavaDoc);

      klass.add(e.toString(), makeTypeDescriptor(e.asType()));
    }
  }
270700
public void setProcessing(final boolean processing) {
        final boolean old = this.processing;
        this.processing = processing;

        this.pcs.firePropertyChange("processing", old, this.processing);
    }
379425
public void setEnvironmentVariables(Map<String, String> environment) {
    for (Map.Entry<String, String> entry : environment.entrySet()) {
      setEnvironmentVariable(entry.getKey(), entry.getValue());
    }
  }
582217
public void setEnvironments(java.util.Collection<Environment> environments) {
        if (environments == null) {
            this.environments = null;
            return;
        }

        this.environments = new java.util.ArrayList<Environment>(environments);
    }
1035259
private void process(ImmutableSetMultimap<Class<? extends Annotation>, Element> validElements) {
    for (ProcessingStep step : steps) {
      ImmutableSetMultimap<Class<? extends Annotation>, Element> stepElements =
          new ImmutableSetMultimap.Builder<Class<? extends Annotation>, Element>()
              .putAll(indexByAnnotation(elementsDeferredBySteps.get(step), step.annotations()))
              .putAll(filterKeys(validElements, Predicates.<Object>in(step.annotations())))
              .build();
      if (stepElements.isEmpty()) {
        elementsDeferredBySteps.removeAll(step);
      } else {
        Set<? extends Element> rejectedElements = step.process(stepElements);
        elementsDeferredBySteps.replaceValues(
            step,
            transform(
                rejectedElements,
                new Function<Element, ElementName>() {
                  @Override
                  public ElementName apply(Element element) {
                    return ElementName.forAnnotatedElement(element);
                  }
                }));
      }
    }
  }
460479
public boolean doProcessing(List<JCCompilationUnit> roots,
                                List<ClassSymbol> classSymbols,
                                Iterable<? extends PackageSymbol> pckSymbols,
                                Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
        final Set<JCCompilationUnit> treesToClean =
                Collections.newSetFromMap(new IdentityHashMap<JCCompilationUnit, Boolean>());

        //fill already attributed implicit trees:
        for (Env<AttrContext> env : enter.getEnvs()) {
            treesToClean.add(env.toplevel);
        }

        Set<PackageSymbol> specifiedPackages = new LinkedHashSet<>();
        for (PackageSymbol psym : pckSymbols)
            specifiedPackages.add(psym);
        this.specifiedPackages = Collections.unmodifiableSet(specifiedPackages);

        Round round = new Round(roots, classSymbols, treesToClean, deferredDiagnosticHandler);

        boolean errorStatus;
        boolean moreToDo;
        do {
            // Run processors for round n
            round.run(false, false);

            // Processors for round n have run to completion.
            // Check for errors and whether there is more work to do.
            errorStatus = round.unrecoverableError();
            moreToDo = moreToDo();

            round.showDiagnostics(errorStatus || showResolveErrors);

            // Set up next round.
            // Copy mutable collections returned from filer.
            round = round.next(
                    new LinkedHashSet<>(filer.getGeneratedSourceFileObjects()),
                    new LinkedHashMap<>(filer.getGeneratedClasses()));

             // Check for errors during setup.
            if (round.unrecoverableError())
                errorStatus = true;

        } while (moreToDo && !errorStatus);

        // run last round
        round.run(true, errorStatus);
        round.showDiagnostics(true);

        filer.warnIfUnclosedFiles();
        warnIfUnmatchedOptions();

        /*
         * If an annotation processor raises an error in a round,
         * that round runs to completion and one last round occurs.
         * The last round may also occur because no more source or
         * class files have been generated.  Therefore, if an error
         * was raised on either of the last *two* rounds, the compile
         * should exit with a nonzero exit code.  The current value of
         * errorStatus holds whether or not an error was raised on the
         * second to last round; errorRaised() gives the error status
         * of the last round.
         */
        if (messager.errorRaised()
                || werror && round.warningCount() > 0 && round.errorCount() > 0)
            errorStatus = true;

        Set<JavaFileObject> newSourceFiles =
                new LinkedHashSet<>(filer.getGeneratedSourceFileObjects());
        roots = round.roots;

        errorStatus = errorStatus || (compiler.errorCount() > 0);

        round.finalCompiler();

        if (newSourceFiles.size() > 0)
            roots = roots.appendList(compiler.parseFiles(newSourceFiles));

        errorStatus = errorStatus || (compiler.errorCount() > 0);

        // Free resources
        this.close();

        if (errorStatus && compiler.errorCount() == 0) {
            compiler.log.nerrors++;
        }

        compiler.enterTreesIfNeeded(roots);

        if (!taskListener.isEmpty())
            taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));

        return true;
    }
655952
@Override
	public boolean process(final File inFile, final File outFile, final Dimensions outDims, final Logger logger) {
		return ExternalProcessUtils.executeProcess(getProcessBuilder(inFile, outFile, outDims), logger) == 0;
	}
456936
public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties)
        throws RemoteException
    {
        String strCommand = this.getProperty(REMOTE_COMMAND, properties);
        try {
            if (CLOSE.equals(strCommand))
            {
                ((RemoteDatabase)m_remoteObject).close();
            }
            else if (GET_DB_PROPERTIES.equals(strCommand))
            {
                Map<String,Object> propIn = ((RemoteDatabase)m_remoteObject).getDBProperties();
                this.setReturnObject(out, propIn);
            }
            else if (SET_DB_PROPERTIES.equals(strCommand))
            {
                Map<String,Object> propIn = this.getNextPropertiesParam(in, PROPERTIES, properties);
                if (propIn != null)
                    properties.putAll(propIn);
                ((RemoteDatabase)m_remoteObject).setDBProperties(properties);
            }
            else if (COMMIT.equals(strCommand))
            {
                ((RemoteDatabase)m_remoteObject).commit();
            }
            else if (ROLLBACK.equals(strCommand))
            {
                ((RemoteDatabase)m_remoteObject).rollback();
            }
            else
                super.doProcess(in, out, properties);
        } catch (DBException ex)    {
            this.setReturnObject(out, ex);
        } catch (Exception ex)    {
            this.setReturnObject(out, ex);
        }
    }
1318139
@Override
	public void process(Node externs, Node root) {
		this.expandedDepsList.clear();
		List<DependencyList> enclosingDependencies = new LinkedList<DependencyList>();
		try {
			processChildren(root, enclosingDependencies);
		} catch (ProcessingDependenciesException e) {
			throw new RuntimeProcessingDependenciesException(e);
		} catch (DependencyVerificationException e) {
			throw new RuntimeDependencyVerificationException(e);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		appendConsoleLogging(root);
	}
354138
public boolean process(Context context) throws NestingException {
        for(ProcPattern pattern: patterns){
            Context codeContext = new Context(context);
            if (pattern.parse(codeContext)) {
                if(transparent) {
                    codeContext.mergeWithParent();
                }
                template.generate(codeContext);

                if(logContext.isTraceEnabled()){
                    for(Map.Entry<String, CharSequence> entry:context.getAttributes().entrySet()){
                        logContext.trace("Context: {} = {}", entry.getKey(), entry.getValue());
                    }
                }

                if(logGenerate.isTraceEnabled()){
                    logGenerate.trace("Generated text: {}", codeContext.getTarget());
                }

                return true;
            }
        }

        return false;
    }
627624
void process() {
        fixImports();
        if (insertRegion != null) {
            data.ensureImport(BeanDefinition.class);
            if (properties.size() > 0) {
                data.ensureImport(PropertyDefinition.class);
            }
            removeOld();
            if (data.isRootClass() && data.isExtendsDirectBean()) {
                data.ensureImport(DirectBean.class);
            }
            generateMeta();
            generateSerializationVersionId();
            generatePropertyChangeSupportField();
            generateHashCodeField();
            generateFactory();
            generateImmutableBuilderMethod();
            generateArgBasedConstructor();
            generateBuilderBasedConstructor();
            generateMetaBean();
            generateGettersSetters();
            generateSeparator();
            generateImmutableToBuilder();
            generateClone();
            generateEquals();
            generateHashCode();
            generateToString();
            generateMetaClass();
            generateBuilderClass();
            resolveImports();
            resolveIndents();
        }
    }
881757
@Override
  protected void setProcessed(int processed) throws IllegalArgumentException {
    if(processed > total) {
      throw new IllegalArgumentException(processed + " exceeds total: " + total);
    }
    if(processed < 0) {
      throw new IllegalArgumentException("Negative number of processed: " + processed);
    }
    super.setProcessed(processed);
  }
117123
@Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (!roundEnv.processingOver()) {
      for (TypeElement te : annotations) {
        for (Element elt : roundEnv.getElementsAnnotatedWith(te)) {
          if (!elt.toString().startsWith("org.apache.heron")) {
            env.getMessager().printMessage(
                Kind.WARNING,
                String.format("%s extends from a class annotated with %s", elt, te),
                elt);
          }
        }
      }
    }
    return true;
  }