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


Java RoundEnvironment类代码示例

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


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

示例1: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

    try {
        ToolingProvider.setTooling(processingEnv);

        Set<? extends Element> set = roundEnv.getElementsAnnotatedWith(TestAnnotation.class);

        if (set.size() == 1) {
            testCase((TypeElement) set.iterator().next());
        }

    } finally {
        ToolingProvider.clearTooling();
    }
    return false;
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:18,代码来源:AbstractUnitTestAnnotationProcessorClass.java

示例2: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> typeElements, RoundEnvironment env) {
    List<ValidationClass> validationClasses = findAndParseValidations(env);

    // Generate validation classes source code
    for (ValidationClass validationClass : validationClasses) {
        try {
            JavaFile javaFile = JavaFiler.cookJava(validationClass);
            javaFile.writeTo(this.filer);
        } catch (IOException e) {
            error(validationClass.getTypeElement(), "Unable to write validation for type %s: %s", validationClass.getTypeElement(), e.getMessage());
        }
    }

    return false;
}
 
开发者ID:WellingtonCosta,项目名称:convalida,代码行数:17,代码来源:ConvalidaProcessor.java

示例3: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

  if (roundEnv.processingOver()) {
    return false;
  }

  Set<? extends Element> elementsAnnotatedWith =
      roundEnv.getElementsAnnotatedWith(Annotation1.class);

  if (elementsAnnotatedWith.size() != 1) {
    throw new IllegalStateException(
        "There must be exactly one element to process. Actual=" + elementsAnnotatedWith.size());
  }

  for (Element element : elementsAnnotatedWith) {
    inputTypeForElement = inputTypeFinder.findInputTypeForElement(element);
  }

  return false;
}
 
开发者ID:gradle,项目名称:incap,代码行数:22,代码来源:InputTypeFinderAnnotationTestProcessor.java

示例4: processRound

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
private void processRound(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
	loop: for (TypeElement annotation : annotations) {
		for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
			if (element.getAnnotation(Activator.class).extension()) {
				extensionActivator = element.asType().toString();
			} else {
				activator = element.asType().toString();
			}
			if (activator != null && extensionActivator != null) {
				break loop;
			}
		}
	}
	try {
		generateFile();
	} catch (IOException e) {
		messager.printMessage(Kind.ERROR, "IOException while generating file with contracts! " + e.getMessage());
		e.printStackTrace();
	}
}
 
开发者ID:commsen,项目名称:EM,代码行数:21,代码来源:ActivatorAnnotationProcessor.java

示例5: getMethodToFieldNameMap

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
private Map<ExecutableElement, String> getMethodToFieldNameMap(RoundEnvironment roundEnvironment) {
    final Map<ExecutableElement, String> methodToFieldNameMap = new HashMap<>();

    for (Element byElement : roundEnvironment.getElementsAnnotatedWith(By.class)) {
        if (byElement.getKind() != ElementKind.FIELD) {
            continue;
        }
        VariableElement byField = (VariableElement) byElement;
        for (Element element : typeUtils.asElement(byField.asType()).getEnclosedElements()) {
            if (element.getKind() != ElementKind.METHOD) {
                continue;
            }
            ExecutableElement method = (ExecutableElement) element;
            methodToFieldNameMap.put(method, byField.getSimpleName().toString());
        }
    }

    return methodToFieldNameMap;
}
 
开发者ID:srym,项目名称:cuckoo,代码行数:20,代码来源:DelegationProcessor.java

示例6: incrementalProcess

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean incrementalProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  for (TypeElement annotation : annotations) {
    System.out.println("Processing annotation:" + annotation);
  }

  if (isProcessingDone) {
    return false;
  }

  // generates a class with a constant that contains the name of all classes containing an annotation.
  Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(Annotation1.class);
  Map<String, Set<? extends Element>> mapGeneratedFileNameToOriginatingElements = processElements(annotatedElements);
  generateFiles(incrementalProcessingEnvironment.getFiler(), mapGeneratedFileNameToOriginatingElements);
  isProcessingDone = true;
  return false;
}
 
开发者ID:gradle,项目名称:incap,代码行数:18,代码来源:M1_OneToOneAP.java

示例7: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override public boolean process(Set<? extends TypeElement> elements, RoundEnvironment env) {
  Map<TypeElement, BindingSet> bindingMap = findAndParseTargets(env);

  for (Map.Entry<TypeElement, BindingSet> entry : bindingMap.entrySet()) {
    TypeElement typeElement = entry.getKey();
    BindingSet binding = entry.getValue();

    JavaFile javaFile = binding.brewJava(sdk);
    try {
      javaFile.writeTo(filer);
    } catch (IOException e) {
      error(typeElement, "Unable to write binding for type %s: %s", typeElement, e.getMessage());
    }
  }

  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:ButterKnifeProcessor.java

示例8: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (roundEnv.processingOver() || written++ > 0) {
        return false;
    }
    messager.printMessage(Diagnostic.Kind.NOTE, "writing Generated.java");
    try {
        Writer w = processingEnv.getFiler().createSourceFile("p.Generated").openWriter();
        try {
            w.write("package p; public class Generated { public static void m() { } }");
        } finally {
            w.close();
        }
    } catch (IOException x) {
        messager.printMessage(Diagnostic.Kind.ERROR, x.toString());
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:T7159016.java

示例9: prepareGlobalConfig

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
/**
 * Prepare global config
 *
 * @param roundEnv annotation processor environment
 */
private Element prepareGlobalConfig(RoundEnvironment roundEnv) {
    Element sqlFirstApcConfigElement = null;

    //TODO read with filer for the case of partial compilation
    Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(SqlFirstApcConfig.class);
    for (Element element : annotatedElements) {
        if (sqlFirstApcConfigElement == null) {
            sqlFirstApcConfigElement = element;
        } else {
            processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "SqlFirstApcConfig annotation must be declared only once ", element);
        }
    }
    return sqlFirstApcConfigElement;
    
}
 
开发者ID:nds842,项目名称:sql-first-mapper,代码行数:21,代码来源:SqlFirstAnnotationProcessor.java

示例10: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
	if (annotations.isEmpty()) {
		return false;
	}

	try {
		return throwableProcess(roundEnv);
	} catch (RuntimeException e) {
		getMessager().printMessage(Diagnostic.Kind.OTHER, "Moxy compilation failed. Could you copy stack trace above and write us (or make issue on Githhub)?");
		e.printStackTrace();
		getMessager().printMessage(Diagnostic.Kind.ERROR, "Moxy compilation failed; see the compiler error output for details (" + e + ")");
	}

	return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MvpCompiler.java

示例11: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的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

示例12: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (round++ == 0) {
        try (Writer out = processingEnv.getFiler()
                                             .createSourceFile("Anno.java")
                                             .openWriter()) {
            String target = processingEnv.getOptions().get("target");
            String code = "import java.lang.annotation.ElementType;\n" +
                          "import java.lang.annotation.Target;\n" +
                          "@Target(ElementType." + target + ")\n" +
                          "@interface Anno { public String value(); }\n";
            out.write(code);
        } catch (IOException exc) {
            throw new IllegalStateException(exc);
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Processor.java

示例13: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {

    try {
        if (!findAnnotatedViewModels(roundEnvironment)) {
            return true;
        }

        for (TypeElement viewModelElement : viewModels) {
            generateViewModelFactory(viewModelElement);
        }

    } catch (IOException e) {
        error("An error has occurred.");
        e.printStackTrace();
    }

    return true;
}
 
开发者ID:kakai248,项目名称:AutoViewModelFactory,代码行数:20,代码来源:AutoViewModelFactoryProcessor.java

示例14: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
@Override
public final boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

  if (roundEnv.processingOver()) {
    return false;
  }

  for (ProcessorPipeline processorPipeline : processorPipelines) {
    try {
      processorPipeline.process(annotations, roundEnv);
    } catch (Throwable e) {
      errorReporter.reportError(
          String.format(
              Locale.getDefault(),
              "Fatal error running %s processor: %s",
              processorPipeline.getAnnotationType().getSimpleName(),
              e.getMessage()));
    }
  }
  return false;
}
 
开发者ID:uber,项目名称:RIBs,代码行数:22,代码来源:RibProcessor.java

示例15: process

import javax.annotation.processing.RoundEnvironment; //导入依赖的package包/类
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
    try {
        if (renv.processingOver())
            createSymbols();
    } catch (IOException e) {
        processingEnv.getMessager()
                .printMessage(Diagnostic.Kind.ERROR, e.getLocalizedMessage());
    } catch (Throwable t) {
        Throwable cause = t.getCause();
        if (cause == null)
            cause = t;
        processingEnv.getMessager()
                .printMessage(Diagnostic.Kind.ERROR, cause.getLocalizedMessage());
    }
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:CreateSymbols.java


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