Example usage for javax.annotation.processing RoundEnvironment errorRaised

List of usage examples for javax.annotation.processing RoundEnvironment errorRaised

Introduction

In this page you can find the example usage for javax.annotation.processing RoundEnvironment errorRaised.

Prototype

boolean errorRaised();

Source Link

Document

Returns true if an error was raised in the prior round of processing; returns false otherwise.

Usage

From source file:com.github.pellaton.jazoon2012.JazoonProcessor.java

/**
 * @see AbstractProcessor#process(Set, RoundEnvironment)
 *//*from   w w w.ja  va 2s .c o m*/
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (!roundEnv.errorRaised() && !roundEnv.processingOver()) {
        processRound(annotations, roundEnv);
    }
    return false;
}

From source file:com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessor.java

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (!roundEnv.errorRaised() && !roundEnv.processingOver()) {
        processRound(annotations, roundEnv);
    }/*from   w w  w.  ja  va 2s .c o  m*/
    return false;
}

From source file:org.kie.workbench.common.forms.adf.processors.FormDefinitionsProcessor.java

@Override
protected boolean processWithExceptions(Set<? extends TypeElement> annotations,
        RoundEnvironment roundEnvironment) throws Exception {
    processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Searching FormDefinitions on project");

    //If prior processing threw an error exit
    if (roundEnvironment.errorRaised()) {
        return false;
    }/* w w  w  .  ja  v  a  2s . c om*/

    this.elementUtils = processingEnv.getElementUtils();
    this.roundEnvironment = roundEnvironment;

    context = new SourceGenerationContext();

    processFieldDefinitions();

    processFormDefinitions();

    if (!context.getForms().isEmpty() || !context.getFieldDefinitions().isEmpty()) {
        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
                "Generating sources for [" + context.getForms().size() + "] FormDefinitions & ["
                        + context.getFieldDefinitions().size() + "] FieldDefinitions");
        String packageName = context.getForms().get(0).get("package") + ".formBuilder.provider";
        Map<String, Object> templateContext = new HashMap<>();

        templateContext.put("package", packageName);
        templateContext.put("generatedByClassName", this.getClass().getName());
        templateContext.put("forms", context.getForms());
        templateContext.put("fieldModifiers", context.getFieldDefinitions());
        templateContext.put("fieldDefinitions", context.getFieldDefinitions());

        StringBuffer code = writeTemplate("templates/FormGenerationResourcesProvider.ftl", templateContext);

        // If code is successfully created write files, or send generated code to callback.
        // The callback function is used primarily for testing when we don't necessarily want
        // the generated code to be stored as a compilable file for javac to process.
        if (callback == null) {
            writeCode(packageName, "ModuleFormGenerationResourcesProvider", code);
        } else {
            callback.generationComplete(code.toString());
        }
        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE,
                "Succesfully Generated sources for [" + context.getForms().size() + "] FormDefinitions & ["
                        + context.getFieldDefinitions().size() + "] FieldDefinitions");
    } else {
        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "No FormDefinitions found on module");
    }

    return true;
}

From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java

@Override
protected boolean processWithExceptions(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv)
        throws Exception {
    if (roundEnv.processingOver()) {
        return processLastRound(set, roundEnv);
    }// w  w w .  ja  v a  2 s. co  m
    //If prior processing threw an error exit
    if (roundEnv.errorRaised()) {
        return false;
    }
    final Elements elementUtils = processingEnv.getElementUtils();
    // Process Definition Sets types found on the processing environment.
    for (Element e : roundEnv
            .getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_DEFINITION_SET))) {
        processDefinitionSets(set, e, roundEnv);
    }
    // Process Definition types found on the processing environment.
    for (Element e : roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_DEFINITION))) {
        processDefinitions(set, e, roundEnv);
    }
    // Process Property Sets types found on the processing environment
    // AND
    // Process Property Sets types identified as dependant types for the annotated Defininitions. Note that
    // those types cannot be directly found on the processing environment if the classes are in a third party
    // dependency and not directly on the module sources.
    final Set<? extends Element> propertySetElements = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_PROPERTY_SET)));
            addAll(processingContext.getPropertySetElements());
        }
    };
    for (Element e : propertySetElements) {
        processPropertySets(set, e, roundEnv);
    }
    // Process Property types found on the processing environment
    // AND
    // Process PropertySets types identified as dependant types for the annotated Defininitions or Property Sets.
    // Note that // those types cannot be directly found on the processing environment if the classes are in a
    // third party dependency and not directly on the module sources.
    final Set<? extends Element> propertyElements = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_PROPERTY)));
            addAll(processingContext.getPropertyElements());
        }
    };
    for (Element e : propertyElements) {
        processProperties(set, e, roundEnv);
    }
    final Set<? extends Element> containRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_CAN_CONTAIN)));
            addAll(processingContext.getDefinitionElements());
            removeAll(processingContext.getContainmentRuleElementsProcessed());
        }
    };
    for (Element e : containRules) {
        processContainmentRules(e);
    }
    final Set<? extends Element> dockRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_CAN_DOCK)));
            addAll(processingContext.getDefinitionElements());
            removeAll(processingContext.getDockingRuleElementsProcessed());
        }
    };
    for (Element e : dockRules) {
        processDockingRules(e);
    }

    final Set<? extends Element> extRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_EXTENSIONS)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_EXTENSION)));
        }
    };
    for (Element e : extRules) {
        processRuleExtension(e);
    }
    final Set<? extends Element> occRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv
                    .getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_ALLOWED_OCCS)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_OCCS)));
        }
    };
    for (Element e : occRules) {
        processCardinalityRules(e);
    }
    final Set<? extends Element> edgeOccRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv.getElementsAnnotatedWith(
                    elementUtils.getTypeElement(ANNOTATION_RULE_ALLOWED_EDGE_OCCURRS)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_EDGE_OCCS)));
        }
    };
    for (Element e : edgeOccRules) {
        processEdgeCardinalityRules(e);
    }
    final Set<? extends Element> cRules = new LinkedHashSet<Element>() {
        {
            addAll(roundEnv
                    .getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_ALLOWED_CONNECTION)));
            addAll(roundEnv.getElementsAnnotatedWith(elementUtils.getTypeElement(ANNOTATION_RULE_CAN_CONNECT)));
        }
    };
    for (Element e : cRules) {
        processConnectionRules(e);
    }
    return true;
}