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


Java JavacTask.addTaskListener方法代码示例

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


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

示例1: init

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
/*****************************************
 * Add task to the javac compilation process
 * @param pe the processing environment
 ****************************************/
@Override
public synchronized void init(ProcessingEnvironment pe) {
	JavacTask task = JavacTask.instance(pe);
	if (!(task instanceof BasicJavacTask)) {
		pe.getMessager()
				.printMessage(Diagnostic.Kind.WARNING,
								  "Unfortunately you are using an incompatible " +
										  "version of the javac.  Please report this at " +
										  "https://github.com/prestongarno/trywithres-compat/issues. Thank you.");
		return;
	}

	super.init(pe);
	task.addTaskListener(new Loader.TaskListenerImpl(task));
	String v = Options.instance(((BasicJavacTask) task).getContext()).get("-g:source");
	INJECT_STDOUT_STATEMENT = v != null;
}
 
开发者ID:prestongarno,项目名称:trywithres-compat,代码行数:22,代码来源:FakeProcessor.java

示例2: process

import com.sun.source.util.JavacTask; //导入方法依赖的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

示例3: getTask

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
/**
 * Fork a new compilation task; if possible the compilation context from previous executions is
 * retained (see comments in ReusableContext as to when it's safe to do so); otherwise a brand
 * new context is created.
 */
public JavacTask getTask() {
    if (task == null) {
        ReusableContext context = env.context();
        String opts = options == null ? "" :
                StreamSupport.stream(options.spliterator(), false).collect(Collectors.joining());
        context.clear();
        if (!context.polluted && (context.opts == null || context.opts.equals(opts))) {
            //we can reuse former context
            env.info().ctxReusedCount++;
        } else {
            env.info().ctxDroppedCount++;
            //it's not safe to reuse context - create a new one
            context = env.setContext(new ReusableContext());
        }
        context.opts = opts;
        JavacTask javacTask = ((JavacTool)env.javaCompiler()).getTask(out, env.fileManager(),
                diagsCollector, options, null, sources, context);
        javacTask.setTaskListener(context);
        for (TaskListener l : listeners) {
            javacTask.addTaskListener(l);
        }
        task = javacTask;
    }
    return task;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ComboTask.java

示例4: CompiledTypeProcessor

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
CompiledTypeProcessor( JavacTask javacTask )
  {
    _javacTask = javacTask;
    javacTask.addTaskListener( this );
    Context context = ((BasicJavacTask)javacTask).getContext();
    JavaCompiler compiler = JavaCompiler.instance( context );
    compiler.shouldStopPolicyIfNoError = CompileState.max( compiler.shouldStopPolicyIfNoError, CompileState.FLOW );
    _issueReporter = new IssueReporter<>( Log.instance( context ) );
    _types = Types.instance( context );
//    DiagnosticListener dl = context.get( DiagnosticListener.class );
//    context.put( DiagnosticListener.class, (DiagnosticListener)null );
//    context.put( DiagnosticListener.class, new WrappedDiagnosticListener( dl ) );

    _typesToProcess = new HashMap<>();
    _innerClassForGeneration = new HashMap<>();
  }
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:17,代码来源:CompiledTypeProcessor.java

示例5: init

import com.sun.source.util.JavacTask; //导入方法依赖的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.source.util.JavacTask; //导入方法依赖的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

示例7: testTaskListener

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
void testTaskListener(JavacTool javac, StandardJavaFileManager fm,
        Iterable<? extends JavaFileObject> files, PrintWriter out,
        int expectedDocComments) {
    out.println("Test task listener");
    JavacTask task = javac.getTask(out, fm, null, null, null, files);
    TaskListnr tl = new TaskListnr(DocTrees.instance(task));
    task.addTaskListener(tl);
    task.call();
    tl.checker.checkDocComments(expectedDocComments);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Test.java

示例8: init

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
@Override
public void init(JavacTask task, String... args) {
    task.addTaskListener(new EffectivelyFinalTaskListener(task));
}
 
开发者ID:massfords,项目名称:effectively-final,代码行数:5,代码来源:EffectivelyFinalPlugin.java

示例9: init

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
public void init(JavacTask task, String... args) {
    Pattern pattern = null;
    if (args.length == 1)
        pattern = Pattern.compile(args[0]);
    task.addTaskListener(new PostAnalyzeTaskListener(task, pattern));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:ShowTypePlugin.java

示例10: test

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:49,代码来源:TestSimpleAddRemove.java

示例11: init

import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
@Override
public void init( JavacTask task, String... args )
{
  _ctx = ((BasicJavacTask)task).getContext();
  task.addTaskListener( this );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:7,代码来源:BootstrapPlugin.java


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