當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。