void () { if (myEventDisposable != null) { return; } myEventDisposable = Disposer.newDisposable(); Disposer.register(JavaAutoRunManager.this, myEventDisposable); MessageBusConnection connection = project.getMessageBus().connect(myEventDisposable); connection.subscribe(CompilerTopics.COMPILATION_STATUS, new CompilationStatusListener() { private boolean myFoundFilesToMake = false; @Override public void automakeCompilationFinished(int errors, int warnings, @NotNull CompileContext compileContext) { if (!myFoundFilesToMake) return; if (errors == 0) { restartAllAutoTests(() -> isUpToDate()); } myHasErrors = errors == 0; myFoundFilesToMake = false; } @Override public void fileGenerated(@NotNull String outputRoot, @NotNull String relativePath) { myFoundFilesToMake = true; } }); connection.subscribe(ProjectTaskListener.TOPIC, new ProjectTaskListener() { @Override public void started(@NotNull ProjectTaskContext context) { context.enableCollectionOfGeneratedFiles(); } @Override public void finished(ProjectTaskManager.@NotNull Result result) { if (result.anyTaskMatches((task, state) -> task instanceof ModuleBuildTask)) { if (result.getContext().getGeneratedFilesRoots().isEmpty() && result.getContext().getDirtyOutputPaths().isEmpty()) return; myHasErrors = result.hasErrors() || result.isAborted(); if (!result.hasErrors() && !result.isAborted()) { restartAllAutoTests(() -> isUpToDate()); } } } }); }