Fix KtDotQualifiedExpressionElementType stub building for complex qualified elements

Fixed #EA212081
This commit is contained in:
Igor Yakovlev
2020-02-06 20:13:43 +03:00
parent ddcc3b39f7
commit 9e05c702ab
4 changed files with 68 additions and 3 deletions
@@ -23,7 +23,7 @@ object KotlinStubVersions {
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
// if you are not 100% sure it can be avoided.
// Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version.
const val SOURCE_STUB_VERSION = 136
const val SOURCE_STUB_VERSION = 137
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression;
public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElementType<KtDotQualifiedExpression> {
@@ -27,6 +28,26 @@ public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElemen
super(debugName, KtDotQualifiedExpression.class);
}
private static boolean checkNodeTypesTraversal(ASTNode node) {
IElementType type = node.getElementType();
if (type != KtStubElementTypes.DOT_QUALIFIED_EXPRESSION &&
type != KtStubElementTypes.REFERENCE_EXPRESSION &&
type != KtTokens.IDENTIFIER &&
type != KtTokens.DOT
) {
return false;
}
for (ASTNode child = node.getFirstChildNode(); child != null; child = child.getTreeNext()) {
if (!checkNodeTypesTraversal(child)) {
return false;
}
}
return true;
}
@Override
public boolean shouldCreateStub(ASTNode node) {
ASTNode treeParent = node.getTreeParent();
@@ -38,7 +59,7 @@ public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElemen
parentElementType == KtStubElementTypes.VALUE_ARGUMENT ||
parentElementType == KtStubElementTypes.DOT_QUALIFIED_EXPRESSION
) {
return super.shouldCreateStub(node);
return checkNodeTypesTraversal(node) && super.shouldCreateStub(node);
}
return false;