cleanup
authorAlexey Kudravtsev <cdr@intellij.com>
Mon, 31 May 2010 14:31:04 +0000 (18:31 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Tue, 1 Jun 2010 09:13:08 +0000 (13:13 +0400)
platform/lang-impl/src/com/intellij/codeInsight/problems/WolfTheProblemSolverImpl.java

index 4318a65a2cb6573a0aab4fc83267c3c224af71e7..69624d0e7bb45a768e39381c7dc39832a4d89d33 100644 (file)
@@ -73,25 +73,6 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
     }
   };
 
-  private final VirtualFileListener myVirtualFileListener = new VirtualFileAdapter() {
-    public void fileDeleted(final VirtualFileEvent event) {
-      onDeleted(event.getFile());
-    }
-
-    public void fileMoved(final VirtualFileMoveEvent event) {
-      onDeleted(event.getFile());
-    }
-
-    private void onDeleted(final VirtualFile file) {
-      if (file.isDirectory()) {
-        clearInvalidFiles();
-      }
-      else {
-        doRemove(file);
-      }
-    }
-  };
-
   private void doRemove(VirtualFile problemFile) {
     ProblemFileInfo old;
     synchronized (myProblems) {
@@ -106,8 +87,6 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
     }
   }
 
-  private final PsiTreeChangeListener myChangeListener;
-
   private static class ProblemFileInfo {
     private final Collection<Problem> problems = new THashSet<Problem>();
     private boolean hasSyntaxErrors;
@@ -118,10 +97,7 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
 
       final ProblemFileInfo that = (ProblemFileInfo)o;
 
-      if (hasSyntaxErrors != that.hasSyntaxErrors) return false;
-      if (!problems.equals(that.problems)) return false;
-
-      return true;
+      return hasSyntaxErrors == that.hasSyntaxErrors && problems.equals(that.problems);
     }
 
     public int hashCode() {
@@ -133,7 +109,7 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
 
   public WolfTheProblemSolverImpl(Project project, PsiManager psiManager, VirtualFileManager virtualFileManager) {
     myProject = project;
-    myChangeListener = new PsiTreeChangeAdapter() {
+    PsiTreeChangeListener changeListener = new PsiTreeChangeAdapter() {
       public void childAdded(PsiTreeChangeEvent event) {
         childrenChanged(event);
       }
@@ -158,8 +134,26 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver {
         clearSyntaxErrorFlag(event);
       }
     };
-    psiManager.addPsiTreeChangeListener(myChangeListener);
-    virtualFileManager.addVirtualFileListener(myVirtualFileListener, myProject);
+    psiManager.addPsiTreeChangeListener(changeListener);
+    VirtualFileListener virtualFileListener = new VirtualFileAdapter() {
+      public void fileDeleted(final VirtualFileEvent event) {
+        onDeleted(event.getFile());
+      }
+
+      public void fileMoved(final VirtualFileMoveEvent event) {
+        onDeleted(event.getFile());
+      }
+
+      private void onDeleted(final VirtualFile file) {
+        if (file.isDirectory()) {
+          clearInvalidFiles();
+        }
+        else {
+          doRemove(file);
+        }
+      }
+    };
+    virtualFileManager.addVirtualFileListener(virtualFileListener, myProject);
     FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
     if (fileStatusManager != null) { //tests?
       fileStatusManager.addFileStatusListener(new FileStatusListener() {