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


Java BasicJavacTask.getContext方法代码示例

本文整理汇总了Java中com.sun.tools.javac.api.BasicJavacTask.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java BasicJavacTask.getContext方法的具体用法?Java BasicJavacTask.getContext怎么用?Java BasicJavacTask.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.api.BasicJavacTask的用法示例。


在下文中一共展示了BasicJavacTask.getContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AbstractCodingRulesAnalyzer

import com.sun.tools.javac.api.BasicJavacTask; //导入方法依赖的package包/类
public AbstractCodingRulesAnalyzer(JavacTask task) {
    BasicJavacTask impl = (BasicJavacTask)task;
    Context context = impl.getContext();
    log = Log.instance(context);
    options = Options.instance(context);
    rawDiagnostics = options.isSet("rawDiagnostics");
    diags = JCDiagnostic.Factory.instance(context);
    messages = new Messages();
    syms = Symtab.instance(context);
    elements = JavacElements.instance(context);
    types = JavacTypes.instance(context);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:AbstractCodingRulesAnalyzer.java

示例2: init

import com.sun.tools.javac.api.BasicJavacTask; //导入方法依赖的package包/类
@DefinedBy(Api.COMPILER_TREE)
public void init(JavacTask task, String... args) {
    BasicJavacTask impl = (BasicJavacTask)task;
    Context context = impl.getContext();
    log = Log.instance(context);
    trees = Trees.instance(task);
    task.addTaskListener(new PostAnalyzeTaskListener(
            new MutableFieldsAnalyzer(task),
            new AssertCheckAnalyzer(task),
            new DefinedByAnalyzer(task),
            new LegacyLogMethodAnalyzer(task)
    ));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:CodingRulesAnalyzerPlugin.java

示例3: init

import com.sun.tools.javac.api.BasicJavacTask; //导入方法依赖的package包/类
@DefinedBy(Api.COMPILER_TREE)
public void init(JavacTask task, String... args) {
    BasicJavacTask impl = (BasicJavacTask)task;
    Context context = impl.getContext();
    log = Log.instance(context);
    trees = Trees.instance(task);
    task.addTaskListener(new PostAnalyzeTaskListener(
            new MutableFieldsAnalyzer(task),
            new AssertCheckAnalyzer(task),
            new DefinedByAnalyzer(task)
    ));
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:13,代码来源:CodingRulesAnalyzerPlugin.java

示例4: init

import com.sun.tools.javac.api.BasicJavacTask; //导入方法依赖的package包/类
public void init(JavacTask task, String... args) {
    BasicJavacTask impl = (BasicJavacTask)task;
    Context context = impl.getContext();
    log = Log.instance(context);
    trees = Trees.instance(task);
    messages = new Messages();
    task.addTaskListener(new PostAnalyzeTaskListener());
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:9,代码来源:AbstractCodingRulesAnalyzer.java

示例5: clearPendingUnits

import com.sun.tools.javac.api.BasicJavacTask; //导入方法依赖的package包/类
protected void clearPendingUnits(BasicJavacTask task) {
  List<CompilationUnitTaskList> missing = new ArrayList<>();
  cups.values()
      .stream()
      .filter(pcu -> pcu.getUnit() == null)
      .forEach(missing::add);
  if (!missing.isEmpty()) {
    Context ctx = new Context(task.getContext());
    ctx.put(JavacService.class, service);
    MultiTaskListener tasks = MultiTaskListener.instance(ctx);
    tasks.add(getTaskListener(task));
    JavacProcessingEnvironment env = JavacProcessingEnvironment.instance(ctx);
    try (
        JavacFileManager jfm = new JavacFileManager(ctx, false, Charset.forName("UTF-8"))
    ) {
      List<JavaFileObject> missingFiles = new ArrayList<>();
      missing.forEach(pcu -> {
        String name = pcu.getName();
        TypeElement element = task.getElements().getTypeElement(name);
        if (element == null) {
          X_Log.info(getClass(), "No element found for ", name);
        } else {
          final javax.lang.model.element.Name qualified = element.getQualifiedName();
          Name binary = env.getElementUtils().getBinaryName(element);
          String relativeName = binary.toString().split("[$]")[0];// TODO check for enclosing types instead of this nasty hack
          JavaFileObject javaFile;
          try {
            javaFile = jfm.getJavaFileForInput(StandardLocation.SOURCE_OUTPUT, relativeName, JavaFileObject.Kind.SOURCE);
            if (javaFile == null) {
              javaFile = jfm.getJavaFileForInput(StandardLocation.SOURCE_PATH, relativeName, JavaFileObject.Kind.SOURCE);
              if (javaFile == null) {
                javaFile = jfm.getJavaFileForInput(StandardLocation.CLASS_PATH, relativeName, JavaFileObject.Kind.SOURCE);
                if (javaFile == null) {
                  X_Log.warn(getClass(), "Unable to find file ", relativeName, " to recompile...");
                }
              }
            }
            if (javaFile != null){
              missingFiles.add(javaFile);
            }
          } catch (Throwable e) {
            X_Log.warn(getClass(), "Unable to compile source for "+binary, e);
            throw X_Debug.rethrow(e);
          }
          //            pcu.setUnit(cu);
          //            pcu.finish();
        }
      });
      JavaCompiler compiler = JavaCompiler.instance(ctx);
      final com.sun.tools.javac.util.List<JavaFileObject> javaFiles = com.sun.tools.javac.util.List.from(missingFiles.toArray(new JavaFileObject[missingFiles.size()]));
      compiler.compile(javaFiles);
    } catch (Throwable throwable) {
      throw X_Debug.rethrow(throwable);
    }
  }
  doFinish();
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:58,代码来源:CompilerServiceImpl.java


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