Search in sources :

Example 1 with TaskEvent

use of com.sun.source.util.TaskEvent in project buck by facebook.

the class TaskListenerWrapperTest method testIgnoresNullListeners.

@Test
public void testIgnoresNullListeners() {
    TaskListenerWrapper wrapper = new TaskListenerWrapper(null);
    TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE);
    wrapper.started(e);
    wrapper.finished(e);
// Expect no crashes
}
Also used : TaskEvent(com.sun.source.util.TaskEvent) Test(org.junit.Test)

Example 2 with TaskEvent

use of com.sun.source.util.TaskEvent in project buck by facebook.

the class TaskListenerWrapperTest method testChainsToInnerOnFinish.

@Test
public void testChainsToInnerOnFinish() {
    TaskListenerWrapper wrapper = new TaskListenerWrapper(innerListener);
    TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE);
    innerListener.finished(e);
    EasyMock.replay(innerListener);
    wrapper.finished(e);
    EasyMock.verify(innerListener);
}
Also used : TaskEvent(com.sun.source.util.TaskEvent) Test(org.junit.Test)

Example 3 with TaskEvent

use of com.sun.source.util.TaskEvent in project buck by facebook.

the class TaskListenerWrapperTest method testChainsToInnerOnStart.

@Test
public void testChainsToInnerOnStart() {
    TaskListenerWrapper wrapper = new TaskListenerWrapper(innerListener);
    TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE);
    innerListener.started(e);
    EasyMock.replay(innerListener);
    wrapper.started(e);
    EasyMock.verify(innerListener);
}
Also used : TaskEvent(com.sun.source.util.TaskEvent) Test(org.junit.Test)

Example 4 with TaskEvent

use of com.sun.source.util.TaskEvent in project buck by facebook.

the class TracingTaskListenerTest method testTracesBeforeChainingOnFinish.

/**
   * In order for TracingTaskListener to record the most accurate timings for time spent in javac,
   * it needs to trace finish events before it chains to the next listener.
   */
@Test
public void testTracesBeforeChainingOnFinish() {
    TaskEvent parseEvent = new TaskEvent(TaskEvent.Kind.PARSE, createMock(JavaFileObject.class));
    mockControl.checkOrder(true);
    mockTracer.endParse();
    mockNextListener.finished(parseEvent);
    mockControl.replay();
    tracingTaskListener.finished(parseEvent);
    mockControl.verify();
}
Also used : JavaFileObject(javax.tools.JavaFileObject) TaskEvent(com.sun.source.util.TaskEvent) Test(org.junit.Test)

Example 5 with TaskEvent

use of com.sun.source.util.TaskEvent in project ceylon-compiler by ceylon.

the class JavaCompiler method parse.

/** Parse contents of input stream.
     *  @param filename     The name of the file from which input stream comes.
     *  @param input        The input stream to be parsed.
     */
protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
    long msec = now();
    JCCompilationUnit tree = make.TopLevel(List.<JCTree.JCAnnotation>nil(), null, List.<JCTree>nil());
    if (content != null) {
        if (verbose) {
            log.printVerbose("parsing.started", filename);
        }
        if (taskListener != null) {
            TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
            taskListener.started(e);
        }
        Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
        tree = parser.parseCompilationUnit();
        if (verbose) {
            log.printVerbose("parsing.done", Long.toString(elapsed(msec)));
        }
    }
    tree.sourcefile = filename;
    if (content != null && taskListener != null) {
        TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, tree);
        taskListener.finished(e);
    }
    return tree;
}
Also used : TaskEvent(com.sun.source.util.TaskEvent) JCTree(com.sun.tools.javac.tree.JCTree)

Aggregations

TaskEvent (com.sun.source.util.TaskEvent)20 TaskListener (com.sun.source.util.TaskListener)7 JavaFileObject (javax.tools.JavaFileObject)7 JCCompilationUnit (com.sun.tools.javac.tree.JCTree.JCCompilationUnit)5 Test (org.junit.Test)5 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)4 JCTree (com.sun.tools.javac.tree.JCTree)4 File (java.io.File)3 DiagnosticListener (javax.tools.DiagnosticListener)3 JavaPositionsRetriever (com.redhat.ceylon.compiler.java.codegen.JavaPositionsRetriever)2 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)2 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)2 JavacTaskImpl (com.sun.tools.javac.api.JavacTaskImpl)2 Context (com.sun.tools.javac.util.Context)2 CeylonCompilationUnit (com.redhat.ceylon.compiler.java.codegen.CeylonCompilationUnit)1 CeylonModelLoader (com.redhat.ceylon.compiler.java.loader.CeylonModelLoader)1 RuntimeModelLoader (com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader)1 RuntimeModuleManager (com.redhat.ceylon.compiler.java.runtime.model.RuntimeModuleManager)1 CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)1 CeylonPhasedUnit (com.redhat.ceylon.compiler.java.tools.CeylonPhasedUnit)1