當前位置: 首頁>>代碼示例>>Java>>正文


Java JavacProcessingEnvironment類代碼示例

本文整理匯總了Java中com.sun.tools.javac.processing.JavacProcessingEnvironment的典型用法代碼示例。如果您正苦於以下問題:Java JavacProcessingEnvironment類的具體用法?Java JavacProcessingEnvironment怎麽用?Java JavacProcessingEnvironment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JavacProcessingEnvironment類屬於com.sun.tools.javac.processing包,在下文中一共展示了JavacProcessingEnvironment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dataflow

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的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

示例2: checkConstructorInitialization

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
/**
 * @param entities field init info
 * @param state visitor state
 * @return a map from each constructor C to the nonnull fields that C does *not* initialize
 */
private SetMultimap<MethodTree, Symbol> checkConstructorInitialization(
    FieldInitEntities entities, VisitorState state) {
  SetMultimap<MethodTree, Symbol> result = LinkedHashMultimap.create();
  Set<Symbol> nonnullInstanceFields = entities.nonnullInstanceFields();
  Trees trees = Trees.instance(JavacProcessingEnvironment.instance(state.context));
  for (MethodTree constructor : entities.constructors()) {
    if (constructorInvokesAnother(constructor, state)) {
      continue;
    }
    Set<Element> guaranteedNonNull =
        guaranteedNonNullForConstructor(entities, state, trees, constructor);
    for (Symbol fieldSymbol : nonnullInstanceFields) {
      if (!guaranteedNonNull.contains(fieldSymbol)) {
        result.put(constructor, fieldSymbol);
      }
    }
  }
  return result;
}
 
開發者ID:uber,項目名稱:NullAway,代碼行數:25,代碼來源:NullAway.java

示例3: process

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    round++;

    JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv;
    Context c = jpe.getContext();
    check(c.get(JavacElements.class), eltUtils);
    check(c.get(JavacTypes.class), typeUtils);
    check(c.get(JavacTrees.class), treeUtils);

    final int MAXROUNDS = 3;
    if (round < MAXROUNDS)
        generateSource("Gen" + round);

    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:TestContext.java

示例4: process

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    FSInfo fsInfo = context.get(FSInfo.class);

    round++;
    if (round == 1) {
        boolean expect = Boolean.valueOf(options.get("expect"));
        checkEqual("cache result", fsInfo.isDirectory(testDir.toPath()), expect);
        initialFSInfo = fsInfo;
    } else {
        checkEqual("fsInfo", fsInfo, initialFSInfo);
    }

    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:T7018098.java

示例5: init

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override
public void init( JavacTask task, String... args )
{
  _javacTask = (BasicJavacTask)task;
  if( isCompilingCore() )
  {
    // Do not apply the plugin on Manifold core itself
    // Note this can only happen during incremental compile when JavacPlugin.class was previously compiled and in
    // the classpath but other parts of core manifold were changed and need compilation (the placeholder plugin is'nt
    // used in this case).
    JavacProcessingEnvironment.instance( getContext() ).getMessager().printMessage( Diagnostic.Kind.NOTE, "Bypassing JavacPlugin during incremental compilation of Manifold core" );
    return;
  }
  hijackJavacFileManager();
  task.addTaskListener( this );
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:17,代碼來源:JavacPlugin.java

示例6: init

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void init(ProcessingEnvironment procEnv) {
	super.init(procEnv);
	if (System.getProperty("lombok.disable") != null) {
		lombokDisabled = true;
		return;
	}
	
	this.processingEnv = (JavacProcessingEnvironment) procEnv;
	placePostCompileAndDontMakeForceRoundDummiesHook();
	transformer = new JavacTransformer(procEnv.getMessager());
	trees = Trees.instance(procEnv);
	SortedSet<Long> p = transformer.getPriorities();
	if (p.isEmpty()) {
		this.priorityLevels = new long[] {0L};
		this.priorityLevelsRequiringResolutionReset = new HashSet<Long>();
	} else {
		this.priorityLevels = new long[p.size()];
		int i = 0;
		for (Long prio : p) this.priorityLevels[i++] = prio;
		this.priorityLevelsRequiringResolutionReset = transformer.getPrioritiesRequiringResolutionReset();
	}
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:24,代碼來源:LombokProcessor.java

示例7: listOptions

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
private void listOptions(StringBuilder message, ProcessingEnvironment procEnv) {
	try {
		JavacProcessingEnvironment environment = (JavacProcessingEnvironment) procEnv;
		Options instance = Options.instance(environment.getContext());
		Field field = Options.class.getDeclaredField("values");
		field.setAccessible(true);
		@SuppressWarnings("unchecked") Map<String, String> values = (Map<String, String>) field.get(instance);
		if (values.isEmpty()) {
			message.append("Options: empty\n\n");
			return;
		}
		message.append("Compiler Options:\n");
		for (Map.Entry<String, String> value : values.entrySet()) {
			message.append("- ");
			string(message, value.getKey());
			message.append(" = ");
			string(message, value.getValue());
			message.append("\n");
		}
		message.append("\n");
	} catch (Exception e) {
		message.append("No options available\n\n");
	}
	
}
 
開發者ID:git03394538,項目名稱:lombok-ianchiu,代碼行數:26,代碼來源:Processor.java

示例8: process

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    FSInfo fsInfo = context.get(FSInfo.class);

    round++;
    if (round == 1) {
        boolean expect = Boolean.valueOf(options.get("expect"));
        checkEqual("cache result", fsInfo.isDirectory(testDir), expect);
        initialFSInfo = fsInfo;
    } else {
        checkEqual("fsInfo", fsInfo, initialFSInfo);
    }

    return true;
}
 
開發者ID:ojdkbuild,項目名稱:lookaside_java-1.8.0-openjdk,代碼行數:17,代碼來源:T7018098.java

示例9: init

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override // from AbstractProcessor
    public void init (ProcessingEnvironment procenv)
    {
        super.init(procenv);

        if (!(procenv instanceof JavacProcessingEnvironment)) {
            procenv.getMessager().printMessage(
                Diagnostic.Kind.WARNING, "Immuter requires javac v1.6.");
            return;
        }

        Context ctx = ((JavacProcessingEnvironment)procenv).getContext();
        _trees = Trees.instance(procenv);
        _procenv = procenv;

        // note our options
        _handleStar = "true".equalsIgnoreCase(procenv.getOptions().get(HANDLE_STAR));

//         procenv.getMessager().printMessage(
//             Diagnostic.Kind.NOTE, "Immuter running [src=" + procenv.getSourceVersion() + "]");
    }
 
開發者ID:samskivert,項目名稱:immutablej,代碼行數:22,代碼來源:Processor.java

示例10: init

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override // from AbstractProcessor
    public void init (ProcessingEnvironment procenv)
    {
        super.init(procenv);

        if (!(procenv instanceof JavacProcessingEnvironment)) {
            procenv.getMessager().printMessage(
                Diagnostic.Kind.WARNING, "Imferrer requires javac v1.6.");
            return;
        }

        Context ctx = ((JavacProcessingEnvironment)procenv).getContext();
        _trees = Trees.instance(procenv);
        _imfer = Imfer.instance(ctx);
        _procenv = procenv;

//         procenv.getMessager().printMessage(
//             Diagnostic.Kind.NOTE, "Imferrer running [vers=" + procenv.getSourceVersion() + "]");
    }
 
開發者ID:samskivert,項目名稱:immutablej,代碼行數:20,代碼來源:Processor.java

示例11: init

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
public void init(ProcessingEnvironment procEnv) {
    javacProcessingEnv = (JavacProcessingEnvironment) procEnv;
    maker = TreeMaker.instance(javacProcessingEnv.getContext());
    parserFactory = ParserFactory.instance(javacProcessingEnv.getContext());
    utils = javacProcessingEnv.getElementUtils();
    typeUtils = javacProcessingEnv.getTypeUtils();
    trees = JavacTrees.instance(javacProcessingEnv);
    types = Types.instance(javacProcessingEnv.getContext());

    voidType = maker.Type((Type) typeUtils.getNoType(TypeKind.VOID));
    objectClass = utils.getTypeElement("java.lang.Object");

    debugMode = Boolean.parseBoolean(getOption(DEBUG_MODE_OPTION_NAME));

    // reflection
    try {
        newParserMethod = ParserFactory.class.getMethod("newParser", CharSequence.class, Boolean.TYPE, Boolean.TYPE, Boolean.TYPE);
    } catch (NoSuchMethodException ignored) {
    }
}
 
開發者ID:ixkor,項目名稱:genaroid,代碼行數:21,代碼來源:GenaroidEnvironment.java

示例12: loadPlugins

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
public static ScannerSupplier loadPlugins(ScannerSupplier scannerSupplier, Context context) {
  JavaFileManager fileManager = context.get(JavaFileManager.class);
  // Unlike in annotation processor discovery, we never search CLASS_PATH if
  // ANNOTATION_PROCESSOR_PATH is unavailable.
  if (!fileManager.hasLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH)) {
    return scannerSupplier;
  }
  // Use the same classloader that Error Prone was loaded from to avoid classloader skew
  // when using Error Prone plugins together with the Error Prone javac plugin.
  JavacProcessingEnvironment processingEnvironment = JavacProcessingEnvironment.instance(context);
  ClassLoader loader = processingEnvironment.getProcessorClassLoader();
  Iterable<BugChecker> extraBugCheckers = ServiceLoader.load(BugChecker.class, loader);
  if (Iterables.isEmpty(extraBugCheckers)) {
    return scannerSupplier;
  }
  return scannerSupplier.plus(
      ScannerSupplier.fromBugCheckerClasses(
          Iterables.transform(extraBugCheckers, BugChecker::getClass)));
}
 
開發者ID:google,項目名稱:error-prone,代碼行數:20,代碼來源:ErrorPronePlugins.java

示例13: process

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    Locale locale = context.get(Locale.class);
    JavacMessages messages = context.get(JavacMessages.messagesKey);

    round++;
    if (round == 1) {
        initialLocale = locale;
        initialMessages = messages;
    } else {
        checkEqual("locale", locale, initialLocale);
        checkEqual("messages", messages, initialMessages);
    }

    return true;
}
 
開發者ID:aducode,項目名稱:openjdk-source-code-learn,代碼行數:18,代碼來源:T6597678.java

示例14: typeProcess

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
@Override
public final void typeProcess(TypeElement element, TreePath tree) {
    Context context = ((JavacProcessingEnvironment)processingEnv).getContext();
    Log log = Log.instance(context);
    if (log.nerrors > this.errsOnLastExit) {
        // If there is a Java error, do not perform any
        // of the component type checks, but come back
        // for the next compilation unit.
        this.errsOnLastExit = log.nerrors;
        return;
    }
    if (!allCheckersInited) {
        // If there was an initialization problem, an
        // error was already output. Just quit.
        return;
    }
    for (SourceChecker checker : checkers) {
        checker.errsOnLastExit = this.errsOnLastExit;
        checker.typeProcess(element, tree);
        this.errsOnLastExit = checker.errsOnLastExit;
    }
}
 
開發者ID:reprogrammer,項目名稱:checker-framework,代碼行數:23,代碼來源:AggregateChecker.java

示例15: main

import com.sun.tools.javac.processing.JavacProcessingEnvironment; //導入依賴的package包/類
public static void main(String[] args) {
    if (args.length != 1) {
        System.out.println("Usage:");
        System.out.println("    java IndexGenerator [class or package name]");
        return;
    }

    Context context = new Context();
    ProcessingEnvironment env = JavacProcessingEnvironment.instance(context);

    StubGenerator generator = new StubGenerator();

    if (env.getElementUtils().getPackageElement(args[0]) != null)
        generator.skeletonFromPackage(env.getElementUtils().getPackageElement(args[0]));
    else if (env.getElementUtils().getTypeElement(args[0]) != null)
        generator.skeletonFromType(env.getElementUtils().getTypeElement(args[0]));
    else
        System.err.println("Couldn't find a package or a class named " + args[0]);
}
 
開發者ID:reprogrammer,項目名稱:checker-framework,代碼行數:20,代碼來源:StubGenerator.java


注:本文中的com.sun.tools.javac.processing.JavacProcessingEnvironment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。