本文整理汇总了Java中javax.annotation.processing.ProcessingEnvironment类的典型用法代码示例。如果您正苦于以下问题:Java ProcessingEnvironment类的具体用法?Java ProcessingEnvironment怎么用?Java ProcessingEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessingEnvironment类属于javax.annotation.processing包,在下文中一共展示了ProcessingEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
protected ExecutableElement doGet(ProcessingEnvironment env) {
TypeElement typeElt = env.getElementUtils().getTypeElement(fqn.getName());
if (typeElt != null) {
next:
for (ExecutableElement executableElement : ElementFilter.methodsIn(typeElt.getEnclosedElements())) {
if (executableElement.getSimpleName().toString().equals(name)) {
List<? extends TypeMirror> parameterTypes = ((ExecutableType)executableElement.asType()).getParameterTypes();
int len = parameterTypes.size();
if (len == this.parameterTypes.size()) {
for (int i = 0;i < len;i++) {
if (!parameterTypes.get(i).toString().equals(this.parameterTypes.get(i))) {
continue next;
}
}
return executableElement;
}
}
}
}
return null;
}
示例2: dataflow
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
/**
* Run the {@code transfer} dataflow analysis over the method, lambda or initializer which is the
* leaf of the {@code path}.
*
* <p>For caching, we make the following assumptions: - if two paths to methods are {@code equal},
* their control flow graph is the same. - if two transfer functions are {@code equal}, and are
* run over the same control flow graph, the analysis result is the same. - for all contexts, the
* analysis result is the same.
*/
private <A extends AbstractValue<A>, S extends Store<S>, T extends TransferFunction<A, S>>
Result<A, S, T> dataflow(TreePath path, Context context, T transfer) {
final ProcessingEnvironment env = JavacProcessingEnvironment.instance(context);
final ControlFlowGraph cfg = cfgCache.getUnchecked(CfgParams.create(path, env));
final AnalysisParams aparams = AnalysisParams.create(transfer, cfg, env);
@SuppressWarnings("unchecked")
final Analysis<A, S, T> analysis = (Analysis<A, S, T>) analysisCache.getUnchecked(aparams);
return new Result<A, S, T>() {
@Override
public Analysis<A, S, T> getAnalysis() {
return analysis;
}
@Override
public ControlFlowGraph getControlFlowGraph() {
return cfg;
}
};
}
示例3: RequestManagerGenerator
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
RequestManagerGenerator(ProcessingEnvironment processingEnv, ProcessorUtil processorUtil) {
this.processingEnv = processingEnv;
this.processorUtil = processorUtil;
Elements elementUtils = processingEnv.getElementUtils();
requestManagerType = elementUtils.getTypeElement(REQUEST_MANAGER_QUALIFIED_NAME);
requestManagerClassName = ClassName.get(requestManagerType);
lifecycleType = elementUtils.getTypeElement(LIFECYCLE_QUALIFIED_NAME);
requestManagerTreeNodeType =
elementUtils.getTypeElement(REQUEST_MANAGER_TREE_NODE_QUALIFIED_NAME);
requestBuilderType =
elementUtils.getTypeElement(RequestBuilderGenerator.REQUEST_BUILDER_QUALIFIED_NAME);
glideType = elementUtils.getTypeElement(GLIDE_QUALIFIED_NAME);
}
示例4: write_withIOException
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Test
public void write_withIOException() throws Exception {
final ProcessingEnvironment env = mock(ProcessingEnvironment.class);
final Messager messager = mock(Messager.class);
final Filer filer = mock(Filer.class);
when(env.getMessager()).thenReturn(messager);
when(env.getFiler()).thenReturn(filer);
compiler.init(env);
final JavaFile javaFile = mock(JavaFile.class);
doThrow(IOException.class).when(javaFile).writeTo(any(Filer.class));
compiler.writeSource(javaFile);
verify(messager, times(1)).printMessage(eq(Diagnostic.Kind.ERROR), any());
}
示例5: init
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override public synchronized void init(ProcessingEnvironment env) {
super.init(env);
String sdk = env.getOptions().get(OPTION_SDK_INT);
if (sdk != null) {
try {
this.sdk = Integer.parseInt(sdk);
} catch (NumberFormatException e) {
env.getMessager()
.printMessage(Kind.WARNING, "Unable to parse supplied minSdk option '"
+ sdk
+ "'. Falling back to API 1 support.");
}
}
elementUtils = env.getElementUtils();
typeUtils = env.getTypeUtils();
filer = env.getFiler();
try {
trees = Trees.instance(processingEnv);
} catch (IllegalArgumentException ignored) {
}
}
示例6: validate
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public List<ImmuPredicate.Result> validate(ProcessingEnvironment environment) {
final List<ImmuPredicate.Result> results = new ArrayList<>();
results.addAll(runPredicates(environment, this, PREDICATES));
superProperties(environment)
.stream()
.map((p) -> p.validate(environment))
.forEach(results::addAll);
properties()
.stream()
.map((p) -> p.validate(environment))
.forEach(results::addAll);
return results;
}
示例7: getHolderValueType
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
public static TypeMirror getHolderValueType(TypeMirror type, TypeElement defHolder, ProcessingEnvironment env) {
TypeElement typeElement = getDeclaration(type);
if (typeElement == null)
return null;
if (isSubElement(typeElement, defHolder)) {
if (type.getKind().equals(TypeKind.DECLARED)) {
Collection<? extends TypeMirror> argTypes = ((DeclaredType) type).getTypeArguments();
if (argTypes.size() == 1) {
return argTypes.iterator().next();
} else if (argTypes.isEmpty()) {
VariableElement member = getValueMember(typeElement);
if (member != null) {
return member.asType();
}
}
}
}
return null;
}
示例8: init
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public void init(ProcessingEnvironment processingEnv) {
// get messager
messager = processingEnv.getMessager();
wrappedProcessor.init(processingEnv);
}
示例9: UserMarkerAnnotation
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
/**
* This constructor is used by the user's generated specialized processor.
* The info that would normally be given by the use of {@link Service} is provided in
* {@link MarkerAnnotation}.
* @param userAnnotationClass The annotation that will annotate user created services.
* @param info Configuration information.
* @param procEnv The current processing environment.
*/
UserMarkerAnnotation(TypeElement userAnnotationClass, MarkerAnnotation info, ProcessingEnvironment procEnv) {
markingAnnotation = userAnnotationClass;
serviceParentType = procEnv.getElementUtils().getTypeElement(info.getSiName());
if (serviceParentType == null) {
throw new IllegalStateException("User service interface class not found! " + info.getSiName());
}
serviceBaseName = info.getServiceName();
individualNameKey = info.getServiceNameFromAnnotation();
outputPackage = info.getOutputPackage();
}
示例10: init
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
super.init(processingEnvironment);
elementUtils = processingEnvironment.getElementUtils();
typeUtils = processingEnvironment.getTypeUtils();
messager = processingEnvironment.getMessager();
filer = processingEnvironment.getFiler();
}
示例11: init
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
this.messager = processingEnv.getMessager();
this.filer = processingEnv.getFiler();
}
示例12: init
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
this.typeUtils=processingEnv.getTypeUtils();
this.elementUtils=processingEnv.getElementUtils();
this.filer=processingEnv.getFiler();
this.messager=processingEnv.getMessager();
this.elementFactory=new ElementFactory(elementUtils, typeUtils);
}
示例13: init
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
graph = new ClassGraph();
types = processingEnv.getTypeUtils();
messager = processingEnv.getMessager();
try {
graphFile = processingEnv.getFiler().createResource(CLASS_OUTPUT, FOLDER, TYPEGRAPH_FILE);
} catch (IOException e) {
error("TypeGraph could not be created: %s", e.getMessage());
}
graphFile.delete();
}
示例14: RequestOptionsGenerator
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
RequestOptionsGenerator(
ProcessingEnvironment processingEnvironment, ProcessorUtil processorUtil) {
this.processingEnvironment = processingEnvironment;
this.processorUtil = processorUtil;
requestOptionsName = ClassName.get(REQUEST_OPTIONS_PACKAGE_NAME,
REQUEST_OPTIONS_SIMPLE_NAME);
requestOptionsType = processingEnvironment.getElementUtils().getTypeElement(
REQUEST_OPTIONS_QUALIFIED_NAME);
}
示例15: getReturnType
import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
public TypeMirror getReturnType(ProcessingEnvironment env) {
if (returnTypeCache == null) {
if (returnType == null) {
throw new RuntimeException("Invalid return type.");
}
returnTypeCache = lookupType(env, returnType);
}
return returnTypeCache;
}