diff --git a/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java b/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java index b7583f2755b2..d650cd216fc7 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/LightStubBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import com.intellij.psi.PsiFile; import com.intellij.psi.StubBuilder; 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.containers.BooleanStack; import com.intellij.util.containers.Stack; @@ -44,29 +43,26 @@ public class LightStubBuilder implements StubBuilder { if (tree == null) { FileType fileType = file.getFileType(); if (!(fileType instanceof LanguageFileType)) { - LOG.error("File is not of LanguageFileType: " + fileType + ", " + file); + LOG.error("File is not of LanguageFileType: " + file + ", " + fileType); return null; } - assert file instanceof PsiFileImpl; - final IFileElementType contentType = ((PsiFileImpl)file).getElementTypeForStubBuilder(); - if (contentType == null) { + if (!(file instanceof PsiFileImpl)) { + LOG.error("Unexpected PsiFile instance: " + file + ", " + file.getClass()); + return null; + } + if (((PsiFileImpl)file).getElementTypeForStubBuilder() == null) { LOG.error("File is not of IStubFileElementType: " + file); return null; } - final FileASTNode node = file.getNode(); - if (node.getElementType() instanceof ILightStubFileElementType) { - tree = node.getLighterAST(); - } - else { - tree = new TreeBackedLighterAST(node); - } - } else { + FileASTNode node = file.getNode(); + tree = node.getElementType() instanceof ILightStubFileElementType ? node.getLighterAST() : new TreeBackedLighterAST(node); + } + else { FORCED_AST.set(null); } - if (tree == null) return null; - final StubElement rootStub = createStubForFile(file, tree); + StubElement rootStub = createStubForFile(file, tree); buildStubTree(tree, tree.getRoot(), rootStub); return rootStub; } @@ -181,4 +177,4 @@ public class LightStubBuilder implements StubBuilder { protected boolean skipChildProcessingWhenBuildingStubs(@NotNull LighterAST tree, @NotNull LighterASTNode parent, @NotNull LighterASTNode node) { return false; } -} +} \ No newline at end of file diff --git a/platform/core-impl/src/com/intellij/psi/stubs/StubTreeBuilder.java b/platform/core-impl/src/com/intellij/psi/stubs/StubTreeBuilder.java index 73cc7f2a3dd4..6330501a6035 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/StubTreeBuilder.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/StubTreeBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import com.intellij.psi.StubBuilder; import com.intellij.psi.impl.source.PsiFileImpl; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.IStubFileElementType; -import com.intellij.util.Function; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.FileContent; @@ -38,7 +37,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; public class StubTreeBuilder { @@ -144,4 +142,4 @@ public class StubTreeBuilder { return ContainerUtil.map(roots, trinity -> Pair.create(trinity.second, trinity.third)); } -} +} \ No newline at end of file