@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;
}
java类javax.annotation.processing.ProcessingEnvironment的实例源码
ElementHandle.java 文件源码
项目:data-mediator
阅读 29
收藏 0
点赞 0
评论 0
DataFlow.java 文件源码
项目:NullAway
阅读 31
收藏 0
点赞 0
评论 0
/**
* 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;
}
};
}
RequestManagerGenerator.java 文件源码
项目:GitHub
阅读 30
收藏 0
点赞 0
评论 0
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);
}
ImmuCompilerTest.java 文件源码
项目:immu
阅读 31
收藏 0
点赞 0
评论 0
@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());
}
ButterKnifeProcessor.java 文件源码
项目:butterknife-parent
阅读 34
收藏 0
点赞 0
评论 0
@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) {
}
}
ImmuObjectElement.java 文件源码
项目:immu
阅读 29
收藏 0
点赞 0
评论 0
@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;
}
TypeModeler.java 文件源码
项目:OpenJSharp
阅读 35
收藏 0
点赞 0
评论 0
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;
}
AnnotationProcessorWrapper.java 文件源码
项目:annotation-processor-toolkit
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void init(ProcessingEnvironment processingEnv) {
// get messager
messager = processingEnv.getMessager();
wrappedProcessor.init(processingEnv);
}
UserMarkerAnnotation.java 文件源码
项目:easy-plugins
阅读 30
收藏 0
点赞 0
评论 0
/**
* 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();
}
ShoebillProcessor.java 文件源码
项目:shoebill
阅读 31
收藏 0
点赞 0
评论 0
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
super.init(processingEnvironment);
elementUtils = processingEnvironment.getElementUtils();
typeUtils = processingEnvironment.getTypeUtils();
messager = processingEnvironment.getMessager();
filer = processingEnvironment.getFiler();
}
FragmentAnnotationProcessor.java 文件源码
项目:EM
阅读 31
收藏 0
点赞 0
评论 0
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
this.messager = processingEnv.getMessager();
this.filer = processingEnv.getFiler();
}
BaseProcessor.java 文件源码
项目:domino
阅读 31
收藏 0
点赞 0
评论 0
@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);
}
JavaGraphProcessor.java 文件源码
项目:JavaGraph
阅读 32
收藏 0
点赞 0
评论 0
@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();
}
RequestOptionsGenerator.java 文件源码
项目:GitHub
阅读 35
收藏 0
点赞 0
评论 0
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);
}
APHotSpotSignature.java 文件源码
项目:openjdk-jdk10
阅读 30
收藏 0
点赞 0
评论 0
public TypeMirror getReturnType(ProcessingEnvironment env) {
if (returnTypeCache == null) {
if (returnType == null) {
throw new RuntimeException("Invalid return type.");
}
returnTypeCache = lookupType(env, returnType);
}
return returnTypeCache;
}
ReactPropertyProcessor.java 文件源码
项目:RNLearn_Project1
阅读 37
收藏 0
点赞 0
评论 0
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
mFiler = processingEnv.getFiler();
mMessager = processingEnv.getMessager();
mElements = processingEnv.getElementUtils();
mTypes = processingEnv.getTypeUtils();
}
GeneratedPlugin.java 文件源码
项目:openjdk-jdk10
阅读 31
收藏 0
点赞 0
评论 0
public void generate(ProcessingEnvironment env, PrintWriter out) {
out.printf(" // class: %s\n", intrinsicMethod.getEnclosingElement());
out.printf(" // method: %s\n", intrinsicMethod);
out.printf(" // generated-by: %s\n", getClass().getName());
out.printf(" private static final class %s extends GeneratedInvocationPlugin {\n", pluginName);
out.printf("\n");
out.printf(" @Override\n");
out.printf(" public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {\n");
InjectedDependencies deps = createExecute(env, out);
out.printf(" }\n");
createPrivateMembers(out, deps);
out.printf(" }\n");
}
BaseAbstractProcessor.java 文件源码
项目:RapidRouter
阅读 28
收藏 0
点赞 0
评论 0
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
GlobalEnvironment.init(processingEnv);
elementUtils = processingEnv.getElementUtils();
typeUtils = processingEnv.getTypeUtils();
filer = processingEnv.getFiler();
}
ProcessorUtil.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
ProcessorUtil(ProcessingEnvironment processingEnv) {
this.processingEnv = processingEnv;
appGlideModuleType =
processingEnv.getElementUtils().getTypeElement(APP_GLIDE_MODULE_QUALIFIED_NAME);
libraryGlideModuleType =
processingEnv.getElementUtils().getTypeElement(LIBRARY_GLIDE_MODULE_QUALIFIED_NAME);
}
Aptools.java 文件源码
项目:Java-9-Programming-By-Example
阅读 25
收藏 0
点赞 0
评论 0
@Transition(from = "MethodTool", end = true)
public String getJavadoc() {
ProcessingEnvironment processingEnv = Environment.get();
String javaDoc = processingEnv.getElementUtils().getDocComment(methodElement);
if (javaDoc == null) {
javaDoc = "";
}
return javaDoc;
}
RequestManagerFactoryGenerator.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
RequestManagerFactoryGenerator(ProcessingEnvironment processingEnv) {
Elements elementUtils = processingEnv.getElementUtils();
glideType = elementUtils.getTypeElement(GLIDE_QUALIFIED_NAME);
lifecycleType = elementUtils.getTypeElement(LIFECYCLE_QUALIFIED_NAME);
requestManagerTreeNodeType =
elementUtils.getTypeElement(REQUEST_MANAGER_TREE_NODE_QUALIFIED_NAME);
requestManagerFactoryInterface =
elementUtils.getTypeElement(REQUEST_MANAGER_FACTORY_QUALIFIED_NAME);
TypeElement requestManagerType = elementUtils.getTypeElement(REQUEST_MANAGER_QUALIFIED_NAME);
requestManagerClassName = ClassName.get(requestManagerType);
}
ElementHandle.java 文件源码
项目:data-mediator
阅读 35
收藏 0
点赞 0
评论 0
@Override
protected VariableElement doGet(ProcessingEnvironment env) {
TypeElement typeElt = env.getElementUtils().getTypeElement(fqn.getName());
if (typeElt != null) {
for (VariableElement variableElt : ElementFilter.fieldsIn(typeElt.getEnclosedElements())) {
if (variableElt.getSimpleName().contentEquals(name)) {
return variableElt;
}
}
}
return null;
}
AppModuleProcessor.java 文件源码
项目:GitHub
阅读 24
收藏 0
点赞 0
评论 0
AppModuleProcessor(ProcessingEnvironment processingEnv, ProcessorUtil processorUtil) {
this.processingEnv = processingEnv;
this.processorUtil = processorUtil;
appModuleGenerator = new AppModuleGenerator(processorUtil);
requestOptionsGenerator = new RequestOptionsGenerator(processingEnv, processorUtil);
requestManagerGenerator = new RequestManagerGenerator(processingEnv, processorUtil);
requestManagerFactoryGenerator = new RequestManagerFactoryGenerator(processingEnv);
glideGenerator = new GlideGenerator(processingEnv, processorUtil);
requestBuilderGenerator = new RequestBuilderGenerator(processingEnv, processorUtil);
}
DescriptionsProcessor.java 文件源码
项目:allure-java
阅读 36
收藏 0
点赞 0
评论 0
@Override
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
public synchronized void init(final ProcessingEnvironment env) {
super.init(env);
filer = env.getFiler();
elementUtils = env.getElementUtils();
messager = env.getMessager();
}
PreferenceRoomProcessor.java 文件源码
项目:PreferenceRoom
阅读 44
收藏 0
点赞 0
评论 0
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
annotatedEntityMap = new HashMap<>();
annotatedEntityNameMap = new HashMap<>();
annotatedComponentList = new ArrayList<>();
messager = processingEnv.getMessager();
}
CompletePluginGenerator.java 文件源码
项目:easy-plugins
阅读 38
收藏 0
点赞 0
评论 0
public static void buildServiceFiles(Element annotationElement,
RoundEnvironment roundEnv,
ProcessingEnvironment procEnv,
ProcessorOutputCollection output) {
buildFiles(
PluginAnnotation.createUserMarker(annotationElement, procEnv),
procEnv,
roundEnv,
output,
false);
}
GeneratedNodeIntrinsicPlugin.java 文件源码
项目:openjdk-jdk10
阅读 116
收藏 0
点赞 0
评论 0
@Override
protected InjectedDependencies createExecute(ProcessingEnvironment env, PrintWriter out) {
InjectedDependencies deps = new InjectedDependencies();
List<? extends VariableElement> params = getParameters();
int idx = 0;
for (; idx < params.size(); idx++) {
VariableElement param = params.get(idx);
if (param.getAnnotation(InjectedNodeParameter.class) == null) {
break;
}
out.printf(" %s arg%d = %s;\n", param.asType(), idx, deps.use(env, (DeclaredType) param.asType()));
}
for (int i = 0; i < signature.length; i++, idx++) {
if (intrinsicMethod.getParameters().get(i).getAnnotation(ConstantNodeParameter.class) != null) {
constantArgument(env, out, deps, idx, signature[i], i);
} else {
if (signature[i].equals(valueNodeType(env))) {
out.printf(" ValueNode arg%d = args[%d];\n", idx, i);
} else {
out.printf(" %s arg%d = (%s) args[%d];\n", signature[i], idx, signature[i], i);
}
}
}
factoryCall(env, out, deps, idx);
return deps;
}
DataFlow.java 文件源码
项目:NullAway
阅读 37
收藏 0
点赞 0
评论 0
@Override
public Analysis<?, ?, ?> load(AnalysisParams key) {
final ProcessingEnvironment env = key.environment();
final ControlFlowGraph cfg = key.cfg();
final TransferFunction<?, ?> transfer = key.transferFunction();
@SuppressWarnings({"unchecked", "rawtypes"})
final Analysis<?, ?, ?> analysis = new Analysis(env, transfer);
analysis.performAnalysis(cfg);
return analysis;
}
TypeMonikerFactory.java 文件源码
项目:OpenJSharp
阅读 30
收藏 0
点赞 0
评论 0
public TypeMirror create(ProcessingEnvironment apEnv) {
TypeElement typeDecl = apEnv.getElementUtils().getTypeElement(typeDeclName);
TypeMirror[] tmpArgs = new TypeMirror[typeArgs.size()];
int idx = 0;
for (TypeMoniker moniker : typeArgs)
tmpArgs[idx++] = moniker.create(apEnv);
return apEnv.getTypeUtils().getDeclaredType(typeDecl, tmpArgs);
}
Processor.java 文件源码
项目:GitHub
阅读 40
收藏 0
点赞 0
评论 0
public static List<Processor> allProcessors(ProcessingEnvironment processingEnvironment) {
List<Processor> list = new ArrayList<>();
list.add(new JsonObjectProcessor(processingEnvironment));
list.add(new OnJsonParseCompleteProcessor(processingEnvironment));
list.add(new OnPreSerializeProcessor(processingEnvironment));
list.add(new JsonFieldProcessor(processingEnvironment));
return list;
}