diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt index e343f6e6ee8..c1b62b3104e 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/KotlinStubVersions.kt @@ -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). diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtDotQualifiedExpressionElementType.java b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtDotQualifiedExpressionElementType.java index 72dfb0a1694..4b11ce7ecd7 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtDotQualifiedExpressionElementType.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtDotQualifiedExpressionElementType.java @@ -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 { @@ -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; diff --git a/idea/testData/stubs/AnnotationValues.expected b/idea/testData/stubs/AnnotationValues.expected index c788cd3f3d4..cc181ded727 100644 --- a/idea/testData/stubs/AnnotationValues.expected +++ b/idea/testData/stubs/AnnotationValues.expected @@ -317,3 +317,41 @@ PsiJetFileStubImpl[package=test] REFERENCE_EXPRESSION[referencedName=ArraysSpread] VALUE_ARGUMENT_LIST VALUE_ARGUMENT[isSpread=true] + CLASS[fqName=test.WithComplexDotQualifiedAnnotation, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=WithComplexDotQualifiedAnnotation, superNames=[]] + MODIFIER_LIST[] + ANNOTATION_ENTRY[hasValueArguments=true, shortName=SomeAnno1] + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION[referencedName=SomeAnno1] + VALUE_ARGUMENT_LIST + VALUE_ARGUMENT[isSpread=false] + VALUE_ARGUMENT_NAME + REFERENCE_EXPRESSION[referencedName=x] + ANNOTATION_ENTRY[hasValueArguments=true, shortName=SomeAnno2] + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION[referencedName=SomeAnno2] + VALUE_ARGUMENT_LIST + VALUE_ARGUMENT[isSpread=false] + VALUE_ARGUMENT_NAME + REFERENCE_EXPRESSION[referencedName=x] + ANNOTATION_ENTRY[hasValueArguments=true, shortName=SomeAnno3] + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION[referencedName=SomeAnno3] + VALUE_ARGUMENT_LIST + VALUE_ARGUMENT[isSpread=false] + VALUE_ARGUMENT_NAME + REFERENCE_EXPRESSION[referencedName=x] + ANNOTATION_ENTRY[hasValueArguments=true, shortName=SomeAnno4] + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION[referencedName=SomeAnno4] + VALUE_ARGUMENT_LIST + VALUE_ARGUMENT[isSpread=false] + VALUE_ARGUMENT_NAME + REFERENCE_EXPRESSION[referencedName=x] diff --git a/idea/testData/stubs/AnnotationValues.kt b/idea/testData/stubs/AnnotationValues.kt index 21eb707a235..89f30f8dd13 100644 --- a/idea/testData/stubs/AnnotationValues.kt +++ b/idea/testData/stubs/AnnotationValues.kt @@ -128,4 +128,10 @@ annotation class ArraysSpread( @ArraysSpread( *[1, 2, 3] ) -class WithSpreadOperatorArrays \ No newline at end of file +class WithSpreadOperatorArrays + +@SomeAnno1(x = (1 + 2).toLong()) +@SomeAnno2(x = 1.toLong()) +@SomeAnno3(x = 1.toLong() + 2) +@SomeAnno4(x = 1 + some.value + 2) +class WithComplexDotQualifiedAnnotation \ No newline at end of file