always return some light tree from FileElement
authorpeter <peter@jetbrains.com>
Mon, 31 Oct 2016 12:26:48 +0000 (13:26 +0100)
committerpeter <peter@jetbrains.com>
Mon, 31 Oct 2016 12:27:35 +0000 (13:27 +0100)
platform/core-impl/src/com/intellij/psi/impl/source/tree/FileElement.java

index 87355e1b582224909e551192f06acbd4a1319630..da7f3fb9b084dfe70e29163d38ac1d8d1b209109 100644 (file)
@@ -23,7 +23,6 @@ import com.intellij.psi.impl.PsiManagerEx;
 import com.intellij.psi.impl.source.CharTableImpl;
 import com.intellij.psi.impl.source.PsiFileImpl;
 import com.intellij.psi.tree.IElementType;
-import com.intellij.psi.tree.IFileElementType;
 import com.intellij.psi.tree.ILightStubFileElementType;
 import com.intellij.util.CharTable;
 import org.jetbrains.annotations.NotNull;
@@ -52,10 +51,8 @@ public class FileElement extends LazyParseableElement implements FileASTNode, Ge
   @NotNull
   @Override
   public LighterAST getLighterAST() {
-    final IFileElementType contentType = (IFileElementType)getElementType();
-    assert contentType instanceof ILightStubFileElementType:contentType; // method should not be called for such element types
-
-    if (!isParsed()) {
+    IElementType contentType = getElementType();
+    if (!isParsed() && contentType instanceof ILightStubFileElementType) {
       return new FCTSBackedLighterAST(getCharTable(), ((ILightStubFileElementType<?>)contentType).parseContentsLight(this));
     }
     return new TreeBackedLighterAST(this);