Search in sources :

Example 1 with AutoTestWatcher

use of com.intellij.execution.testframework.autotest.AutoTestWatcher in project intellij-community by JetBrains.

the class JavaAutoRunManager method createWatcher.

@NotNull
@Override
protected AutoTestWatcher createWatcher(Project project) {
    return new AutoTestWatcher() {

        private boolean myHasErrors = false;

        private CompilationStatusListener myStatusListener;

        @Override
        public void activate() {
            if (myStatusListener == null) {
                myStatusListener = new CompilationStatusListener() {

                    private boolean myFoundFilesToMake = false;

                    @Override
                    public void compilationFinished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
                        if (!myFoundFilesToMake)
                            return;
                        if (errors == 0) {
                            restartAllAutoTests(0);
                        }
                        myHasErrors = errors == 0;
                        myFoundFilesToMake = false;
                    }

                    @Override
                    public void automakeCompilationFinished(int errors, int warnings, CompileContext compileContext) {
                        compilationFinished(false, errors, warnings, compileContext);
                    }

                    @Override
                    public void fileGenerated(String outputRoot, String relativePath) {
                        myFoundFilesToMake = true;
                    }
                };
                CompilerManager.getInstance(project).addCompilationStatusListener(myStatusListener, project);
            }
        }

        @Override
        public void deactivate() {
            if (myStatusListener != null) {
                CompilerManager.getInstance(project).removeCompilationStatusListener(myStatusListener);
            }
        }

        @Override
        public boolean isUpToDate(int modificationStamp) {
            return !myHasErrors;
        }
    };
}
Also used : AutoTestWatcher(com.intellij.execution.testframework.autotest.AutoTestWatcher) CompilationStatusListener(com.intellij.openapi.compiler.CompilationStatusListener) CompileContext(com.intellij.openapi.compiler.CompileContext) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AutoTestWatcher (com.intellij.execution.testframework.autotest.AutoTestWatcher)1 CompilationStatusListener (com.intellij.openapi.compiler.CompilationStatusListener)1 CompileContext (com.intellij.openapi.compiler.CompileContext)1 NotNull (org.jetbrains.annotations.NotNull)1