Fix KtDotQualifiedExpressionElementType stub building for complex qualified elements
Fixed #EA212081
This commit is contained in:
@@ -23,7 +23,7 @@ object KotlinStubVersions {
|
|||||||
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
|
// 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.
|
// 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.
|
// 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
|
// 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).
|
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||||
|
|||||||
+22
-1
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
|||||||
import com.intellij.psi.tree.IElementType;
|
import com.intellij.psi.tree.IElementType;
|
||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression;
|
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression;
|
||||||
|
|
||||||
public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElementType<KtDotQualifiedExpression> {
|
public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElementType<KtDotQualifiedExpression> {
|
||||||
@@ -27,6 +28,26 @@ public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElemen
|
|||||||
super(debugName, KtDotQualifiedExpression.class);
|
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
|
@Override
|
||||||
public boolean shouldCreateStub(ASTNode node) {
|
public boolean shouldCreateStub(ASTNode node) {
|
||||||
ASTNode treeParent = node.getTreeParent();
|
ASTNode treeParent = node.getTreeParent();
|
||||||
@@ -38,7 +59,7 @@ public class KtDotQualifiedExpressionElementType extends KtPlaceHolderStubElemen
|
|||||||
parentElementType == KtStubElementTypes.VALUE_ARGUMENT ||
|
parentElementType == KtStubElementTypes.VALUE_ARGUMENT ||
|
||||||
parentElementType == KtStubElementTypes.DOT_QUALIFIED_EXPRESSION
|
parentElementType == KtStubElementTypes.DOT_QUALIFIED_EXPRESSION
|
||||||
) {
|
) {
|
||||||
return super.shouldCreateStub(node);
|
return checkNodeTypesTraversal(node) && super.shouldCreateStub(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+38
@@ -317,3 +317,41 @@ PsiJetFileStubImpl[package=test]
|
|||||||
REFERENCE_EXPRESSION[referencedName=ArraysSpread]
|
REFERENCE_EXPRESSION[referencedName=ArraysSpread]
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
VALUE_ARGUMENT[isSpread=true]
|
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]
|
||||||
|
|||||||
+6
@@ -129,3 +129,9 @@ annotation class ArraysSpread(
|
|||||||
*[1, 2, 3]
|
*[1, 2, 3]
|
||||||
)
|
)
|
||||||
class WithSpreadOperatorArrays
|
class WithSpreadOperatorArrays
|
||||||
|
|
||||||
|
@SomeAnno1(x = (1 + 2).toLong())
|
||||||
|
@SomeAnno2(x = 1.toLong())
|
||||||
|
@SomeAnno3(x = 1.toLong() + 2)
|
||||||
|
@SomeAnno4(x = 1 + some.value + 2)
|
||||||
|
class WithComplexDotQualifiedAnnotation
|
||||||
Reference in New Issue
Block a user