Example usage for javax.annotation.processing Messager printMessage

List of usage examples for javax.annotation.processing Messager printMessage

Introduction

In this page you can find the example usage for javax.annotation.processing Messager printMessage.

Prototype

void printMessage(Diagnostic.Kind kind, CharSequence msg);

Source Link

Document

Prints a message of the specified kind.

Usage

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

private boolean processRuleExtension(final Element e) throws Exception {
    final Messager messager = processingEnv.getMessager();
    final boolean isIface = e.getKind() == ElementKind.INTERFACE;
    final boolean isClass = e.getKind() == ElementKind.CLASS;
    if (isIface || isClass) {
        TypeElement classElement = (TypeElement) e;
        PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
        messager.printMessage(Diagnostic.Kind.NOTE,
                "Discovered rule extension for class [" + classElement.getSimpleName() + "]");
        final String classNameActivity = classElement.getSimpleName() + RULE_EXTENSION_SUFFIX_CLASSNAME;
        generateRuleCode(extensionRuleGenerator, messager, classElement, packageElement, classNameActivity);
    }// w  ww.j  a v a2  s  . c o  m
    return true;
}

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

private boolean processDockingRules(final Element e) throws Exception {
    final Messager messager = processingEnv.getMessager();
    final boolean isIface = e.getKind() == ElementKind.INTERFACE;
    final boolean isClass = e.getKind() == ElementKind.CLASS;
    if (isIface || isClass) {
        TypeElement classElement = (TypeElement) e;
        PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
        messager.printMessage(Diagnostic.Kind.NOTE,
                "Discovered docking rule for class [" + classElement.getSimpleName() + "]");
        final String classNameActivity = classElement.getSimpleName() + RULE_DOCKING_SUFFIX_CLASSNAME;
        generateRuleCode(dockingRuleGenerator, messager, classElement, packageElement, classNameActivity);
    }/* w  w w  .  j  av  a  2 s .com*/
    return true;
}

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

private boolean processEdgeCardinalityRules(final Element e) throws Exception {
    final Messager messager = processingEnv.getMessager();
    final boolean isIface = e.getKind() == ElementKind.INTERFACE;
    final boolean isClass = e.getKind() == ElementKind.CLASS;
    if (isIface || isClass) {
        TypeElement classElement = (TypeElement) e;
        PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
        messager.printMessage(Diagnostic.Kind.NOTE,
                "Discovered edge cardinality rule for class [" + classElement.getSimpleName() + "]");
        final String classNameActivity = classElement.getSimpleName() + RULE_EDGE_CARDINALITY_SUFFIX_CLASSNAME;
        generateRuleCode(edgeCardinalityRuleGenerator, messager, classElement, packageElement,
                classNameActivity);/*ww  w .j a  va 2s. c  o m*/
    }
    return true;
}

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

private boolean processCardinalityRules(final Element e) throws Exception {
    final Messager messager = processingEnv.getMessager();
    final boolean isIface = e.getKind() == ElementKind.INTERFACE;
    final boolean isClass = e.getKind() == ElementKind.CLASS;
    if (isIface || isClass) {
        TypeElement classElement = (TypeElement) e;
        PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
        messager.printMessage(Diagnostic.Kind.NOTE,
                "Discovered cardinality rule for class [" + classElement.getSimpleName() + "]");
        final String classNameActivity = classElement.getSimpleName() + RULE_CARDINALITY_SUFFIX_CLASSNAME;
        generateRuleCode(cardinalityRuleGenerator, messager, classElement, packageElement, classNameActivity);
    }//from  w  ww . j  a  v a2 s  .  c om
    return true;
}

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

private boolean processConnectionRules(final Element element) throws Exception {
    final Messager messager = processingEnv.getMessager();
    final boolean isIface = element.getKind() == ElementKind.INTERFACE;
    final boolean isClass = element.getKind() == ElementKind.CLASS;
    if (isIface || isClass) {
        TypeElement classElement = (TypeElement) element;
        PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
        messager.printMessage(Diagnostic.Kind.NOTE,
                "Discovered connection rule for class [" + classElement.getSimpleName() + "]");
        final String classNameActivity = classElement.getSimpleName() + RULE_CONNECTION_SUFFIX_CLASSNAME;
        generateRuleCode(connectionRuleGenerator, messager, classElement, packageElement, classNameActivity);
    }/*from  w w  w .  j  a va 2  s . co m*/
    return true;
}

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

private void generateRuleCode(final AbstractGenerator generator, final Messager messager,
        final TypeElement classElement, final PackageElement packageElement, final String classNameActivity) {
    try {//ww w.  j a v  a  2  s .co  m
        final String packageName = packageElement.getQualifiedName().toString();
        //Try generating code for each required class
        messager.printMessage(Diagnostic.Kind.NOTE, "Generating ryke code for [" + classNameActivity + "]");
        generator.generate(packageName, packageElement, classNameActivity, classElement, processingEnv);
    } catch (GenerationException ge) {
        final String msg = ge.getMessage();
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg, classElement);
    }
}

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

private boolean processLastRoundMorphing(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv)
        throws Exception {
    final Messager messager = processingEnv.getMessager();
    try {//w w  w .j a  v  a2  s.  co m
        // Ensure visible on both backend and client sides.
        final String packageName = getGeneratedPackageName() + ".definition.morph";
        final Set<String> generatedDefinitionClasses = new LinkedHashSet<>();
        // MORPH DEFINITIONS GENERATION.
        Map<String, Set<String>> baseTargets = processingContext.getMorphingAnnotations().getBaseTargets();
        if (null != baseTargets && !baseTargets.isEmpty()) {
            for (Map.Entry<String, Set<String>> entry : baseTargets.entrySet()) {
                String baseType = entry.getKey();
                Set<String> targets = entry.getValue();
                final String className = getMorphDefinitionClassName(packageName, baseType,
                        MORPH_DEFINITION_CLASSNAME)[0];
                final String classFQName = getMorphDefinitionClassName(packageName, baseType,
                        MORPH_DEFINITION_CLASSNAME)[1];
                String defaultType = processingContext.getMorphingAnnotations().getBaseDefaultTypes()
                        .get(baseType);
                messager.printMessage(Diagnostic.Kind.NOTE,
                        "Starting MorphDefinition adf for class named " + classFQName);
                final StringBuffer ruleClassCode = morphDefinitionGenerator.generate(packageName, className,
                        baseType, targets, defaultType, messager);
                writeCode(packageName, className, ruleClassCode);
                generatedDefinitionClasses.add(classFQName);
            }
        }
        // MORPH PROPERTY DEFINITIONS GENERATION.
        Map<String, List<ProcessingMorphProperty>> morphProperties = processingContext.getMorphingAnnotations()
                .getBaseMorphProperties();
        if (null != morphProperties && !morphProperties.isEmpty()) {
            for (Map.Entry<String, List<ProcessingMorphProperty>> entry : morphProperties.entrySet()) {
                String baseType = entry.getKey();
                List<ProcessingMorphProperty> properties = entry.getValue();
                final String className = getMorphDefinitionClassName(packageName, baseType,
                        MORPH_PROPERTY_DEFINITION_CLASSNAME)[0];
                final String classFQName = getMorphDefinitionClassName(packageName, baseType,
                        MORPH_PROPERTY_DEFINITION_CLASSNAME)[1];
                String defaultType = processingContext.getMorphingAnnotations().getBaseDefaultTypes()
                        .get(baseType);
                messager.printMessage(Diagnostic.Kind.NOTE,
                        "Starting MorphPropertyDefinition adf for class named " + classFQName);
                final StringBuffer ruleClassCode = morphPropertyDefinitionGenerator.generate(packageName,
                        className, baseType, properties, defaultType, messager);
                writeCode(packageName, className, ruleClassCode);
                generatedDefinitionClasses.add(classFQName);
            }
        }
        // MORPH DEFINITIONS PROVIDER GENERATION.
        if (!generatedDefinitionClasses.isEmpty()) {
            final String className = getSetClassPrefix() + MORPH_PROVIDER_CLASSNAME;
            final String classFQName = packageName + "." + className;
            messager.printMessage(Diagnostic.Kind.NOTE,
                    "Starting MorphDefinitionProvider adf for class named " + classFQName);
            final StringBuffer ruleClassCode = morphDefinitionProviderGenerator.generate(packageName, className,
                    generatedDefinitionClasses, messager);
            writeCode(packageName, className, ruleClassCode);
        }
    } catch (GenerationException ge) {
        final String msg = ge.getMessage();
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
    }
    return true;
}

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

private boolean processLastRoundRuleAdapter(final Set<? extends TypeElement> set,
        final RoundEnvironment roundEnv) throws Exception {
    final Messager messager = processingEnv.getMessager();
    try {/*from   ww w.  j a  v a 2 s.c  o  m*/
        // Ensure visible on both backend and client sides.
        final String packageName = getGeneratedPackageName() + ".definition.adapter.binding";
        final String className = getSetClassPrefix() + RULE_ADAPTER_CLASSNAME;
        final String classFQName = packageName + "." + className;
        messager.printMessage(Diagnostic.Kind.NOTE, "Starting RuleAdapter adf for class named " + classFQName);
        final StringBuffer ruleClassCode = ruleAdapterGenerator.generate(packageName, className,
                processingContext.getDefinitionSet().getClassName(), processingContext.getRules(), messager);
        writeCode(packageName, className, ruleClassCode);
    } catch (GenerationException ge) {
        final String msg = ge.getMessage();
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
    }
    return true;
}

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

private boolean processLastRoundDefinitionSetAdapter(final Set<? extends TypeElement> set,
        final RoundEnvironment roundEnv) throws Exception {
    final Messager messager = processingEnv.getMessager();
    try {/*from  w  w  w .j a v  a2s . c o m*/
        // Ensure visible on both backend and client sides.
        final String packageName = getGeneratedPackageName() + ".definition.adapter.binding";
        final String className = getSetClassPrefix() + DEFINITIONSET_ADAPTER_CLASSNAME;
        final String classFQName = packageName + "." + className;
        messager.printMessage(Diagnostic.Kind.NOTE, "Starting ErraiBinderAdapter adf named " + classFQName);
        final StringBuffer ruleClassCode = definitionSetAdapterGenerator.generate(packageName, className,
                processingContext.getDefSetAnnotations(), messager);
        writeCode(packageName, className, ruleClassCode);
    } catch (GenerationException ge) {
        final String msg = ge.getMessage();
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
    }
    return true;
}

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

private boolean processLastRoundDefinitionSetProxyAdapter(final Set<? extends TypeElement> set,
        final RoundEnvironment roundEnv) throws Exception {
    final Messager messager = processingEnv.getMessager();
    try {/* w  ww  .j av a  2s .c o  m*/
        // Ensure visible on both backend and client sides.
        final String packageName = getGeneratedPackageName() + ".definition.adapter.binding";
        final String className = getSetClassPrefix() + DEFINITIONSET_PROXY_CLASSNAME;
        final String classFQName = packageName + "." + className;
        messager.printMessage(Diagnostic.Kind.NOTE,
                "Starting DefinitionSetProxyAdapter adf for class named " + classFQName);
        final StringBuffer ruleClassCode = definitionSetProxyGenerator.generate(packageName, className,
                processingContext.getDefinitionSet(),
                processingContext.getDefSetAnnotations().getBuilderFieldNames(), messager);
        writeCode(packageName, className, ruleClassCode);
    } catch (GenerationException ge) {
        final String msg = ge.getMessage();
        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
    }
    return true;
}