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


Java TaskEvent类代码示例

本文整理汇总了Java中com.sun.source.util.TaskEvent的典型用法代码示例。如果您正苦于以下问题:Java TaskEvent类的具体用法?Java TaskEvent怎么用?Java TaskEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: initProcessAnnotations

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    if (options.isSet(PROC, "none")) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = JavacProcessingEnvironment.instance(context);
        procEnvImpl.setProcessors(processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            options.put("save-parameter-names", "save-parameter-names");
            reader.saveParameterNames = true;
            keepComments = true;
            genEndPos = true;
            if (!taskListener.isEmpty())
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
            deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:JavaCompiler.java

示例2: finished

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public void finished(TaskEvent taskEvent) {
    List<AbstractCodingRulesAnalyzer> currentAnalyzers = this.analyzers.get(taskEvent.getKind());

    if (currentAnalyzers != null) {
        TypeElement typeElem = taskEvent.getTypeElement();
        Tree tree = trees.getTree(typeElem);
        if (tree != null) {
            JavaFileObject prevSource = log.currentSourceFile();
            try {
                log.useSource(taskEvent.getCompilationUnit().getSourceFile());
                for (AbstractCodingRulesAnalyzer analyzer : currentAnalyzers) {
                    analyzer.treeVisitor.scan((JCTree)tree);
                }
            } finally {
                log.useSource(prevSource);
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CodingRulesAnalyzerPlugin.java

示例3: finished

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
@DefinedBy(Api.COMPILER_TREE)
public void finished(TaskEvent e) {
    switch (e.getKind()) {
    case ANALYZE:
        collectClassSymbols((JCCompilationUnit) e.getCompilationUnit());
        break;
    case COMPILATION:
        Log.debug("Compilation finished");
        Log.debug("Extracting pub APIs for the following symbols:");
        for (ClassSymbol cs : classSymbols)
            Log.debug("    " + cs.fullname);
        extractPubApis();

        // Save result for later retrieval. (Important that we do this
        // before we return from this method, because we may not access
        // symbols after compilation is finished.)
        PubAPIs pa = PubAPIs.instance(context);
        explicitPubApis = pa.getPubapis(explicitJFOs, true);
        nonExplicitPubApis = pa.getPubapis(explicitJFOs, false);

        Log.debug("done");
        break;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:PublicApiCollector.java

示例4: process

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:TestSimpleAddRemove.java

示例5: finished

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
public void finished(TaskEvent e) {
    if (e.getKind() != TaskEvent.Kind.ANALYZE)
        return;

    if (!elements.remove(e.getTypeElement().getQualifiedName()))
        return;

    if (e.getTypeElement().getSimpleName().contentEquals("MyClass")) {
        Element owner = e.getTypeElement().getEnclosingElement();
        if (owner.getKind() != ElementKind.PACKAGE)
            throw new RuntimeException("class owner should be a package: " + owner);
        if (owner.getAnnotationMirrors().size() != 1)
            throw new RuntimeException("the owner package should have one annotation: " + owner);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:PackageProcessor.java

示例6: started

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
public void started( TaskEvent te )
{
  if( JreUtil.isJava8() )
  {
    return;
  }

  CompilationUnitTree compilationUnit = te.getCompilationUnit();
  if( !(compilationUnit instanceof JCTree.JCCompilationUnit) )
  {
    return;
  }

  if( _done )
  {
    return;
  }

  _done = true;

  openModule( _ctx, "jdk.compiler" );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:24,代码来源:BootstrapPlugin.java

示例7: started

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
public void started( TaskEvent e )
{
  switch( e.getKind() )
  {
    case ENTER:
      if( !_initialized )
      {
        _initialized = true;

        // Note there are no "non-java" files to compile in default Manifold,
        // only other languages implementing their own IManifoldHost might compile their language files at this time
        ManifoldHost.initializeAndCompileNonJavaFiles( _fileManager, _gosuInputFiles, this::deriveSourcePath, this::deriveClasspath, this::deriveOutputPath );

        // Need to bootstap for dynamically loading darkj classes Manifold itself uses during compilation e.g., ManClassFinder
        Bootstrap.init();

        // Override javac's ClassFinder and Resolve so that we can safely load class symbols corresponding with extension classes
        hijackJavacCompilerForJava9( e );
      }
      break;
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:24,代码来源:JavacPlugin.java

示例8: finished

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
public void finished( TaskEvent e )
{
  switch( e.getKind() )
  {
    case PARSE:
    {
      addInputFile( e );
      break;
    }

    case ENTER:
      process( e );
      break;

  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:18,代码来源:JavacPlugin.java

示例9: addInputFile

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
private void addInputFile( TaskEvent e )
{
  if( !_initialized )
  {
    CompilationUnitTree compilationUnit = e.getCompilationUnit();
    ExpressionTree pkg = compilationUnit.getPackageName();
    String packageQualifier = pkg == null ? "" : (pkg.toString() + '.');
    for( Tree classDecl : compilationUnit.getTypeDecls() )
    {
      if( classDecl instanceof JCTree.JCClassDecl )
      {
        _javaInputFiles.add( new Pair<>( packageQualifier + ((JCTree.JCClassDecl)classDecl).getSimpleName(), compilationUnit.getSourceFile() ) );
      }
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:17,代码来源:JavacPlugin.java

示例10: finished

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
public void finished(TaskEvent taskEvent) {
    if (taskEvent.getKind().equals(eventKind)) {
        TypeElement typeElem = taskEvent.getTypeElement();
        Tree tree = trees.getTree(typeElem);
        if (tree != null) {
            JavaFileObject prevSource = log.currentSourceFile();
            try {
                log.useSource(taskEvent.getCompilationUnit().getSourceFile());
                treeVisitor.scan((JCTree)tree);
            } finally {
                log.useSource(prevSource);
            }
        }
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:17,代码来源:AbstractCodingRulesAnalyzer.java

示例11: runLastRound

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
private void runLastRound(PrintWriter xout,
                          int roundNumber,
                          boolean errorStatus,
                          TaskListener taskListener) throws IOException {
    roundNumber++;
    List<ClassSymbol> noTopLevelClasses = List.nil();
    Set<TypeElement> noAnnotations =  Collections.emptySet();
    printRoundInfo(xout, roundNumber, noTopLevelClasses, noAnnotations, true);

    Set<Element> emptyRootElements = Collections.emptySet(); // immutable
    RoundEnvironment renv = new JavacRoundEnvironment(true,
                                                      errorStatus,
                                                      emptyRootElements,
                                                      JavacProcessingEnvironment.this);
    if (taskListener != null)
        taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));

    try {
        discoveredProcs.iterator().runContributingProcs(renv);
    } finally {
        if (taskListener != null)
            taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:25,代码来源:JavacProcessingEnvironment.java

示例12: initProcessAnnotations

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    Options options = Options.instance(context);
    if (options.get("-proc:none") != null) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = new JavacProcessingEnvironment(context, processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            if (context.get(Scanner.Factory.scannerFactoryKey) == null)
                DocCommentScanner.Factory.preRegister(context);
            options.put("save-parameter-names", "save-parameter-names");
            reader.saveParameterNames = true;
            keepComments = true;
            if (taskListener != null)
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));


        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:35,代码来源:JavaCompiler.java

示例13: attribute

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
/**
 * Attribute a parse tree.
 * @returns the attributed parse tree
 */
public Env<AttrContext> attribute(Env<AttrContext> env) {
    if (verboseCompilePolicy)
        log.printLines(log.noticeWriter, "[attribute " + env.enclClass.sym + "]");
    if (verbose)
        printVerbose("checking.attribution", env.enclClass.sym);

    if (taskListener != null) {
        TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
        taskListener.started(e);
    }

    JavaFileObject prev = log.useSource(
                              env.enclClass.sym.sourcefile != null ?
                              env.enclClass.sym.sourcefile :
                              env.toplevel.sourcefile);
    try {
        attr.attribClass(env.tree.pos(), env.enclClass.sym);
    }
    finally {
        log.useSource(prev);
    }

    return env;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:29,代码来源:JavaCompiler.java

示例14: initProcessAnnotations

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
/**
 * Check if we should process annotations.
 * If so, and if no scanner is yet registered, then set up the DocCommentScanner
 * to catch doc comments, and set keepComments so the parser records them in
 * the compilation unit.
 *
 * @param processors user provided annotation processors to bypass
 * discovery, {@code null} means that no processors were provided
 */
public void initProcessAnnotations(Iterable<? extends Processor> processors) {
    // Process annotations if processing is not disabled and there
    // is at least one Processor available.
    if (options.isSet(PROC, "none")) {
        processAnnotations = false;
    } else if (procEnvImpl == null) {
        procEnvImpl = new JavacProcessingEnvironment(context, processors);
        processAnnotations = procEnvImpl.atLeastOneProcessor();

        if (processAnnotations) {
            options.put("save-parameter-names", "save-parameter-names");
            reader.saveParameterNames = true;
            keepComments = true;
            genEndPos = true;
            if (taskListener != null)
                taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
            log.deferDiagnostics = true;
        } else { // free resources
            procEnvImpl.close();
        }
    }
}
 
开发者ID:aducode,项目名称:openjdk-source-code-learn,代码行数:32,代码来源:JavaCompiler.java

示例15: finished

import com.sun.source.util.TaskEvent; //导入依赖的package包/类
@Override
public void finished(TaskEvent e) {
  if (e.getKind() == Kind.ANALYZE) {
    e.getCompilationUnit().accept(new Scanner(), null);
  } else if (e.getKind() == Kind.GENERATE) {
    try {
      FileObject file =
          processingEnv
              .getFiler()
              .createResource(
                  StandardLocation.CLASS_OUTPUT, "", "output.txt", e.getTypeElement());
      try (OutputStream os = file.openOutputStream()) {
        os.write(values.toString().getBytes(UTF_8));
      }
    } catch (IOException exception) {
      throw new IOError(exception);
    }
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:20,代码来源:JavacTurbineTest.java


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