当前位置: 首页>>代码示例>>Java>>正文


Java Messager.printMessage方法代码示例

本文整理汇总了Java中javax.annotation.processing.Messager.printMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Messager.printMessage方法的具体用法?Java Messager.printMessage怎么用?Java Messager.printMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.annotation.processing.Messager的用法示例。


在下文中一共展示了Messager.printMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectSubscribers

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
private void collectSubscribers(Set<? extends TypeElement> annotations, RoundEnvironment env, Messager messager) {
    for (TypeElement annotation : annotations) {
        Set<? extends Element> elements = env.getElementsAnnotatedWith(annotation);
        for (Element element : elements) {
            if (element instanceof ExecutableElement) {
                ExecutableElement method = (ExecutableElement) element;
                if (checkHasNoErrors(method, messager)) {
                    TypeElement classElement = (TypeElement) method.getEnclosingElement();
                    methodsByClass.putElement(classElement, method);
                }
            } else {
                messager.printMessage(Diagnostic.Kind.ERROR, "@Subscribe is only valid for methods", element);
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:EventBusAnnotationProcessor.java

示例2: process

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (processingEnv.getElementUtils().getModuleElement("m1x") == null) {
        throw new AssertionError("No m1x module found.");
    }

    Messager messager = processingEnv.getMessager();

    for (TypeElement clazz : ElementFilter.typesIn(roundEnv.getRootElements())) {
        for (VariableElement field : ElementFilter.fieldsIn(clazz.getEnclosedElements())) {
            messager.printMessage(Kind.NOTE, "field: " + field.getSimpleName());
        }
    }

    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:AnnotationProcessing.java

示例3: generateClass

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
/**
 * Generates the code for the Barricade configuration based on the annotations found.
 *
 * @param processingEnv Processing environment
 * @param configs Configuration detected by annotation processing
 * @param messager Messager to print logs
 * @throws IOException
 */
static void generateClass(ProcessingEnvironment processingEnv,
    HashMap<String, BarricadeResponseSet> configs, Messager messager) throws IOException {

  messager.printMessage(Diagnostic.Kind.NOTE, "Generating configuration code...");

  TypeSpec.Builder classBuilder = classBuilder(CLASS_NAME).addModifiers(PUBLIC, FINAL);

  FieldSpec valuesField = FieldSpec.builder(TYPE_CONFIG, "configs").addModifiers(PRIVATE).build();
  FieldSpec instanceField =
      FieldSpec.builder(ClassName.get(PACKAGE_NAME, CLASS_NAME), "barricadeConfig")
          .addModifiers(PRIVATE, STATIC)
          .build();

  MethodSpec.Builder instanceMethodBuilder = generateGetInstanceMethodBuilder();
  MethodSpec.Builder constructorMethodBuilder = generateConstructorBuilder(configs, messager);
  MethodSpec.Builder valuesMethod = generateGetConfigsMethodBuilder();
  MethodSpec.Builder getResponseMethodBuilder = generateGetResponseMethodBuilder();

  classBuilder.addType(generateEndpointsInnerClass(configs.keySet()));
  classBuilder.addType(generateResponsesInnerClass(configs));
  classBuilder.addField(instanceField);
  classBuilder.addField(valuesField);
  classBuilder.addMethod(instanceMethodBuilder.build());
  classBuilder.addMethod(constructorMethodBuilder.build());
  classBuilder.addMethod(valuesMethod.build());
  classBuilder.addMethod(getResponseMethodBuilder.build());

  classBuilder.addSuperinterface(IBarricadeConfig.class);

  JavaFile.Builder javaFileBuilder = builder(PACKAGE_NAME, classBuilder.build());
  JavaFile javaFile = javaFileBuilder.build();
  javaFile.writeTo(processingEnv.getFiler());

  messager.printMessage(Diagnostic.Kind.NOTE, "Code generation complete!");
}
 
开发者ID:mutualmobile,项目名称:Barricade,代码行数:44,代码来源:CodeGenerator.java

示例4: handleBadDirExistsBehavior

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
private static Settings handleBadDirExistsBehavior(Messager messager, String onDirExistsStr) {
    String legalValues = Arrays.stream(AlreadyExistsBehavior.values())
            .map(Enum::name)
            .reduce((a,b) -> a+", "+b)
            .orElse("(No known values)");
    messager.printMessage(ERROR, "Bad value for "+DIR_EXISTS_BEHAVIOR_KEY+" '"+onDirExistsStr+"', "+
            "legal values are "+legalValues);
    return illegalInstance("initialization failed; bad "+DIR_EXISTS_BEHAVIOR_KEY);
}
 
开发者ID:dleppik,项目名称:EgTest,代码行数:10,代码来源:Settings.java

示例5: process

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Messager messager = processingEnv.getMessager();
    for (Element element : roundEnv.getElementsAnnotatedWith(BindView.class)) {
        if (element.getKind() == ElementKind.FIELD) {;
            messager.printMessage(Diagnostic.Kind.NOTE, "printMessage:" + element.toString());
        }
    }
    return true;
}
 
开发者ID:henrymorgen,项目名称:android-advanced-light,代码行数:11,代码来源:ClassProcessor.java

示例6: process

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {
  Filer filer = processingEnv.getFiler();
  Messager messager = processingEnv.getMessager();

  for (Element element : roundEnvironment.getElementsAnnotatedWith(DataEnum.class)) {
    try {

      Spec spec = SpecParser.parse(element, processingEnv);
      if (spec == null) {
        continue;
      }

      OutputSpec outputSpec = OutputSpecFactory.create(spec);
      TypeSpec outputTypeSpec = SpecTypeFactory.create(outputSpec);

      JavaFile.Builder javaFileBuilder =
          JavaFile.builder(outputSpec.outputClass().packageName(), outputTypeSpec);
      if (needsCheckNotNull(spec)) {
        javaFileBuilder.addStaticImport(DataenumUtils.class, "checkNotNull");
      }
      if (needsNullSafeEquals(spec)) {
        javaFileBuilder.addStaticImport(DataenumUtils.class, "equal");
      }

      JavaFile javaFile = javaFileBuilder.build();
      javaFile.writeTo(filer);

    } catch (IOException | ParserException e) {
      messager.printMessage(Diagnostic.Kind.ERROR, e.getMessage());
    }
  }

  return false;
}
 
开发者ID:spotify,项目名称:dataenum,代码行数:36,代码来源:DataEnumProcessor.java

示例7: emitError

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
public void emitError(final Messager messager) {
	if (troubleMaker.isPresent()) {
		messager.printMessage(ERROR, getMessage(), troubleMaker.get());
	} else {
		messager.printMessage(ERROR, getMessage());
	}
}
 
开发者ID:FermioCloud,项目名称:java-code-templates,代码行数:8,代码来源:ProcessorException.java

示例8: execElementDependency

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
/**
 * This method is called on {@link ExecutableElement}.
 * Bean methods on an @Configuration bean, or Constructors on @Component classes.
 * This method parses the @Qualifier, or @Value annotations if a @Verified=root, and reads the types of each parameter.
 * That data is used to build a list of {@link InstanceDependencyModel}'s which are part of an {@link InstanceModel}.
 * All parameters must have an @Qualifier or @Value, and the annotations can not be mixed, errors will result otherwise.
 * 
 * @param messager APT messager that will receive error messages.
 * @param model the DefinitionModel being parse, which may be a @Configuration or @Component annotated entity.
 * @param execelement the bean method if an @Configuration, or the constructor if an @Component.
 * @return the dependencies of the to be constructed {@link InstanceModel}
 */
private List<InstanceDependencyModel> execElementDependency(Messager messager, DefinitionModel model,
    ExecutableElement execelement) {
  List<InstanceDependencyModel> dependencies = new ArrayList<>();
  boolean hasValues = false;
  boolean hasQualifiers = false;
  for (VariableElement varelement : execelement.getParameters()) {
    
    String[] qualifierNames = AnnotationValueExtractor
        .getAnnotationValue(varelement, QUALIFIER_TYPE, DEFAULT_ANNOTATION_VALUE);
    String[] valueNames = AnnotationValueExtractor
        .getAnnotationValue(varelement, VALUE_TYPE, DEFAULT_ANNOTATION_VALUE);
    
    if (qualifierNames == null && valueNames == null) {
      messager.printMessage(Kind.ERROR, "All parameters must have an @Qualifier or a @Value annotation", varelement);
    } 
    if (qualifierNames != null) {
      dependencies.add(new InstanceDependencyModel(qualifierNames[0], varelement.asType().toString()));
      hasQualifiers = true;
    }
    if (valueNames != null) {
      //ignore values as they will be used to build beans and pass the data on, and
      //are not beans themselves... and cannot be intermingled with @Qualifiers.
      hasValues = true;
    }
  }
  if (hasValues && hasQualifiers) {
    messager.printMessage(Kind.ERROR, "No method may define both @Qualifier or a @Value annotations,"
        + " keep property values in there own beans", execelement);
  }
  if (hasValues &&  !model.isRootNode()) {
    messager.printMessage(Kind.ERROR, "Only @Verified(root=true) nodes may use @Value annotations to create beans,"
        + " decouples spring graph from environment", execelement);
  }
  return dependencies;
}
 
开发者ID:salesforce,项目名称:AptSpring,代码行数:48,代码来源:SpringAnnotationParser.java

示例9: addModelsFromComponent

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
/**
 * Builds an instance model by finding the autowired constructor of an @Component model as well as 
 * 
 * @param te the TypeElement corresponding to the @Component class.
 * @param dm the definitionModel built from the @Component.
 * @param names the list if names in an @Component annotation.  Users must explicitly define one.
 * @param messager errors are added to this APT messager.
 */
private void addModelsFromComponent(TypeElement te, DefinitionModel dm, String[] names, Messager messager) {
  List<InstanceDependencyModel> dependencies = new ArrayList<>();
  ExecutableElement chosenConstructor = findAutowiredConstructor(extractConstructorsFromComponent(te));
  if (chosenConstructor == null) {
    messager.printMessage(Kind.ERROR, "No single default constructor or single @Autowired constructor", te);
  } else {
    dependencies = execElementDependency(messager, dm, chosenConstructor);
    //dm.getExpectedDefinitions()
  }
  te.getEnclosedElements().stream()
      .filter(el -> el instanceof VariableElement)
      .map(el -> (VariableElement) el)
      .filter(ve -> !staticPrivateFinalLiteralField.test(ve) && !privateFinalField.test(ve))
      .forEach(ve -> messager
          .printMessage(Kind.ERROR, "@Component classes my only have static final constant fields or final private fields", ve));
  
  InstanceModel model = new InstanceModel(names[0],
      dm.getIdentity(), 
      chosenConstructor, 
      te.getQualifiedName().toString(),
      dependencies, 
      new ArrayList<>());
  
  dm.addDefinition(model);
  for (InstanceDependencyModel dep : dependencies) {
    ExpectedModel expectedModel = new ExpectedModel(dep.getIdentity());
    expectedModel.addDefinitionReferenceToType(model.getIdentity(), dep.getType());
    dm.addDefinition(expectedModel);
  }
}
 
开发者ID:salesforce,项目名称:AptSpring,代码行数:39,代码来源:SpringAnnotationParser.java

示例10: outputErrors

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
/**
 * Gives user feedback as info/warnings/errors during compilation (works in m2e with takari-lifecycle).
 * 
 * @param messager APT round handler for user messages
 */
public void outputErrors(Messager messager) {
  Iterable<ErrorModel> errors = checkAndStoreValid();
  for (ErrorModel error : errors) {
    for (AbstractModel model : error.getInvolved()) {
      if (model.getSourceElement().isPresent()) {
        messager.printMessage(Kind.ERROR, error.getMessageOn(model, k -> getMessageFormats().getMessage(k)),
            getCorrespondingElement(elementUtils, model.getSourceElement().get()));
      } 
    }
  }
}
 
开发者ID:salesforce,项目名称:AptSpring,代码行数:17,代码来源:AptParsingContext.java

示例11: getIlluminatiProperties

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
public static IlluminatiProperties getIlluminatiProperties(final Class<? extends IlluminatiProperties> clazz, Messager messager, final String configPropertiesFileName) {
    IlluminatiProperties illuminatiProperties = null;

    for (String extension : CONFIG_FILE_EXTENSTIONS) {
        String dotBeforeExtension = ".";

        if (StringObjectUtils.isValid(PROFILES_PHASE)) {
            dotBeforeExtension = "-" + PROFILES_PHASE + ".";
        }

        final String fullFileName = configPropertiesFileName + dotBeforeExtension + extension;
        illuminatiProperties = getIlluminatiPropertiesByFile(clazz, messager, fullFileName);

        if (illuminatiProperties != null) {
            break;
        }
    }

    if (illuminatiProperties == null) {
        illuminatiProperties = getIlluminatiPropertiesFromBasicFiles(clazz, messager);
    }

    if (illuminatiProperties == null) {
        if (messager != null) {
            messager.printMessage(Diagnostic.Kind.WARNING, "Sorry, unable to find " + configPropertiesFileName);
        }

        IlluminatiPropertiesHelper.FILEUTIL_LOGGER.debug("Sorry, unable to find " + configPropertiesFileName);
    }

    return illuminatiProperties;
}
 
开发者ID:LeeKyoungIl,项目名称:illuminati,代码行数:33,代码来源:IlluminatiPropertiesHelper.java

示例12: process

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
    Messager messager = processingEnv.getMessager();
    try {
        String index = processingEnv.getOptions().get(OPTION_EVENT_BUS_INDEX);
        if (index == null) {
            messager.printMessage(Diagnostic.Kind.ERROR, "No option " + OPTION_EVENT_BUS_INDEX +
                    " passed to annotation processor");
            return false;
        }
        verbose = Boolean.parseBoolean(processingEnv.getOptions().get(OPTION_VERBOSE));
        int lastPeriod = index.lastIndexOf('.');
        String indexPackage = lastPeriod != -1 ? index.substring(0, lastPeriod) : null;

        round++;
        if (verbose) {
            messager.printMessage(Diagnostic.Kind.NOTE, "Processing round " + round + ", new annotations: " +
                    !annotations.isEmpty() + ", processingOver: " + env.processingOver());
        }
        if (env.processingOver()) {
            if (!annotations.isEmpty()) {
                messager.printMessage(Diagnostic.Kind.ERROR,
                        "Unexpected processing state: annotations still available after processing over");
                return false;
            }
        }
        if (annotations.isEmpty()) {
            return false;
        }

        if (writerRoundDone) {
            messager.printMessage(Diagnostic.Kind.ERROR,
                    "Unexpected processing state: annotations still available after writing.");
        }
        collectSubscribers(annotations, env, messager);
        checkForSubscribersToSkip(messager, indexPackage);

        if (!methodsByClass.isEmpty()) {
            createInfoIndexFile(index);
        } else {
            messager.printMessage(Diagnostic.Kind.WARNING, "No @Subscribe annotations found");
        }
        writerRoundDone = true;
    } catch (RuntimeException e) {
        // IntelliJ does not handle exceptions nicely, so log and print a message
        e.printStackTrace();
        messager.printMessage(Diagnostic.Kind.ERROR, "Unexpected error in EventBusAnnotationProcessor: " + e);
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:51,代码来源:EventBusAnnotationProcessor.java

示例13: error

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
public static void error(Messager messager, Element e, String msg, Object... args) {
    messager.printMessage(Kind.ERROR, String.format(msg, args), e);
}
 
开发者ID:stechy1,项目名称:drd,代码行数:4,代码来源:ProcessorUtils.java

示例14: other

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
public static void other(Messager messager, Element e, String msg, Object... args) {
    messager.printMessage(Kind.OTHER, String.format(msg, args), e);
}
 
开发者ID:stechy1,项目名称:drd,代码行数:4,代码来源:ProcessorUtils.java

示例15: logError

import javax.annotation.processing.Messager; //导入方法依赖的package包/类
private void logError(final Messager pMessager, final Element pElement, final String pMessage, final Object... pArgs) {
    pMessager.printMessage(Diagnostic.Kind.ERROR, String.format(pMessage, pArgs), pElement);
}
 
开发者ID:RoRoche,项目名称:AnnotationProcessorStarter,代码行数:4,代码来源:AnnotatedClass.java


注:本文中的javax.annotation.processing.Messager.printMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。