reduce count of getHighlightingSettingForRoot(psiRoot) calls (that are quite expensiv...
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 13 Feb 2015 14:45:44 +0000 (17:45 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 13 Feb 2015 14:45:44 +0000 (17:45 +0300)
platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java

index d94532853e74dc61b36ce161a7de1c29d537288d..852b33c5e99a6e3918dcc0327c93ed65b604a28e 100644 (file)
@@ -156,7 +156,11 @@ public class HighlightingSettingsPerFile extends HighlightingLevelManager implem
   public boolean shouldInspect(@NotNull PsiElement psiRoot) {
     if (ApplicationManager.getApplication().isUnitTestMode()) return true;
 
-    if (!shouldHighlight(psiRoot)) return false;
+    final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot);
+    if (settingForRoot == FileHighlightingSetting.SKIP_HIGHLIGHTING ||
+        settingForRoot == FileHighlightingSetting.SKIP_INSPECTION) {
+      return false;
+    }
     final Project project = psiRoot.getProject();
     final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile();
     if (virtualFile == null || !virtualFile.isValid()) return false;
@@ -166,9 +170,6 @@ public class HighlightingSettingsPerFile extends HighlightingLevelManager implem
     final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
     if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false;
 
-    if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false;
-
-    final FileHighlightingSetting settingForRoot = getHighlightingSettingForRoot(psiRoot);
-    return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION;
+    return !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile);
   }
 }