don't reparse injected files since they are created with already substituted language... clion/163.49
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 9 Jun 2016 12:01:20 +0000 (15:01 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Thu, 9 Jun 2016 12:01:20 +0000 (15:01 +0300)
platform/core-api/src/com/intellij/psi/LanguageSubstitutors.java

index 1a1a1c96f3b10c40ef5476ed28829316cd266c14..149ebc7b5e1959c54fe056541d5f0058f4c06e71 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.psi;
 
+import com.intellij.injected.editor.VirtualFileWindow;
 import com.intellij.lang.Language;
 import com.intellij.lang.LanguageExtension;
 import com.intellij.openapi.application.ApplicationManager;
@@ -57,6 +58,11 @@ public final class LanguageSubstitutors extends LanguageExtension<LanguageSubsti
   private void processLanguageSubstitution(@NotNull final VirtualFile file,
                                            @NotNull Language originalLang,
                                            @NotNull final Language substitutedLang) {
+    if (file instanceof VirtualFileWindow) {
+      // Injected files are created with substituted language, no need to reparse:
+      //   com.intellij.psi.impl.source.tree.injected.MultiHostRegistrarImpl#doneInjecting
+      return;
+    }
     Language prevSubstitutedLang = SUBSTITUTED_LANG_KEY.get(file);
     final Language prevLang = ObjectUtils.notNull(prevSubstitutedLang, originalLang);
     if (!haveCommonAncestorLanguage(substitutedLang, prevLang)) {