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


Java ProcessingEnvironment类代码示例

本文整理汇总了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; 
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:23,代码来源:ElementHandle.java

示例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;
    }
  };
}
 
开发者ID:uber,项目名称:NullAway,代码行数:30,代码来源:DataFlow.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:RequestManagerGenerator.java

示例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());
}
 
开发者ID:hf,项目名称:immu,代码行数:19,代码来源:ImmuCompilerTest.java

示例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) {
  }
}
 
开发者ID:qq542391099,项目名称:butterknife-parent,代码行数:24,代码来源:ButterKnifeProcessor.java

示例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;
}
 
开发者ID:hf,项目名称:immu,代码行数:19,代码来源:ImmuObjectElement.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:TypeModeler.java

示例8: init

import javax.annotation.processing.ProcessingEnvironment; //导入依赖的package包/类
@Override
public void init(ProcessingEnvironment processingEnv) {

    // get messager
    messager = processingEnv.getMessager();

    wrappedProcessor.init(processingEnv);
}
 
开发者ID:toolisticon,项目名称:annotation-processor-toolkit,代码行数:9,代码来源:AnnotationProcessorWrapper.java

示例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();
}
 
开发者ID:c0d3d,项目名称:easy-plugins,代码行数:19,代码来源:UserMarkerAnnotation.java

示例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();
}
 
开发者ID:srym,项目名称:shoebill,代码行数:10,代码来源:ShoebillProcessor.java

示例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();
}
 
开发者ID:commsen,项目名称:EM,代码行数:8,代码来源:FragmentAnnotationProcessor.java

示例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);
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:10,代码来源:BaseProcessor.java

示例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();
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:14,代码来源:JavaGraphProcessor.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:RequestOptionsGenerator.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:APHotSpotSignature.java


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