use BuildManagerListener in CompilerReferenceServiceImpl to be notified about auto...
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Tue, 4 Oct 2016 15:25:10 +0000 (18:25 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Tue, 4 Oct 2016 15:25:10 +0000 (18:25 +0300)
java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java

index f52cc0f2e729f90f92dd3a32170b803e5b7f922f..e8de37f8b142ce3eaaa3e97ee1ff6c6c6eaf38aa 100644 (file)
  */
 package com.intellij.compiler;
 
+import com.intellij.compiler.server.BuildManagerListener;
 import com.intellij.ide.highlighter.JavaFileType;
-import com.intellij.openapi.compiler.CompileContext;
-import com.intellij.openapi.compiler.CompileTask;
-import com.intellij.openapi.compiler.CompilerManager;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
@@ -40,9 +38,9 @@ import org.jetbrains.annotations.TestOnly;
 
 import java.util.Collections;
 import java.util.Set;
+import java.util.UUID;
 
 import static com.intellij.psi.search.GlobalSearchScope.*;
-import static com.intellij.psi.search.GlobalSearchScope.notScope;
 
 public class CompilerReferenceServiceImpl extends CompilerReferenceService {
   private static final Key<ParameterizedCachedValue<GlobalSearchScope, CompilerSearchAdapter>> CACHE_KEY = Key.create("compiler.ref.service.search");
@@ -64,21 +62,21 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService {
   @Override
   public void projectOpened() {
     if (isEnabled()) {
-      CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {
+      myProject.getMessageBus().connect(myProject).subscribe(BuildManagerListener.TOPIC, new BuildManagerListener() {
         @Override
-        public boolean execute(CompileContext context) {
+        public void beforeBuildProcessStarted(Project project, UUID sessionId) {
+        }
+
+        @Override
+        public void buildStarted(Project project, UUID sessionId, boolean isAutomake) {
           closeReaderIfNeed();
-          return true;
         }
-      });
 
-      CompilerManager.getInstance(myProject).addAfterTask(new CompileTask() {
         @Override
-        public boolean execute(CompileContext context) {
+        public void buildFinished(Project project, UUID sessionId, boolean isAutomake) {
           myChangedModules.clear();
           myDirtyScope = EMPTY_SCOPE;
           openReaderIfNeed();
-          return true;
         }
       });