EDU-456 Disable error highlighting in Preview task action
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 2 Aug 2016 12:53:19 +0000 (15:53 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Tue, 2 Aug 2016 12:53:19 +0000 (15:53 +0300)
python/educational-core/course-creator/resources/META-INF/plugin.xml
python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCHighlightErrorFilter.java [new file with mode: 0644]

index 3acf7ad0f2e89b88b1f33c2e25c49f7c194aae60..b46da939f1b4a568ffee11ff2d02fe7dbaed0fcf 100644 (file)
@@ -25,6 +25,7 @@
     <renameHandler implementation="com.jetbrains.edu.coursecreator.handlers.CCLessonRenameHandler" order="first"/>
     <applicationService serviceInterface="com.jetbrains.edu.coursecreator.settings.CCSettings"
                         serviceImplementation="com.jetbrains.edu.coursecreator.settings.CCSettings"/>
+    <highlightErrorFilter implementation="com.jetbrains.edu.coursecreator.CCHighlightErrorFilter"/>
   </extensions>
   <extensions defaultExtensionNs="Edu">
     <studyActionsProvider implementation="com.jetbrains.edu.coursecreator.CCStudyActionsProvider"/>
diff --git a/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCHighlightErrorFilter.java b/python/educational-core/course-creator/src/com/jetbrains/edu/coursecreator/CCHighlightErrorFilter.java
new file mode 100644 (file)
index 0000000..d3e9e17
--- /dev/null
@@ -0,0 +1,25 @@
+package com.jetbrains.edu.coursecreator;
+
+import com.intellij.codeInsight.highlighting.HighlightErrorFilter;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.PsiErrorElement;
+import com.intellij.psi.PsiFile;
+import org.jetbrains.annotations.NotNull;
+
+public class CCHighlightErrorFilter extends HighlightErrorFilter {
+  @Override
+  public boolean shouldHighlightErrorElement(@NotNull PsiErrorElement element) {
+    PsiFile file = element.getContainingFile();
+    if (file == null) {
+      return true;
+    }
+    VirtualFile virtualFile = file.getVirtualFile();
+    if (virtualFile == null) {
+      return true;
+    }
+    if (virtualFile.getPath().contains(CCUtils.GENERATED_FILES_FOLDER)) {
+      return false;
+    }
+    return true;
+  }
+}