From 1e020644e19a043e186665ff748cceb1b6a383cc Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 21 Jun 2017 01:15:06 +0300 Subject: [PATCH] Fix getting right bracket element for collection literal --- .../kotlin/psi/KtCollectionLiteralExpression.kt | 2 +- .../resolve/references/CollectionLiteralLeft.kt | 3 +++ .../resolve/references/CollectionLiteralRight.kt | 3 +++ .../idea/resolve/ReferenceResolveTestGenerated.java | 12 ++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 idea/testData/resolve/references/CollectionLiteralLeft.kt create mode 100644 idea/testData/resolve/references/CollectionLiteralRight.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt index a6c0404d199..3a566345653 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtCollectionLiteralExpression.kt @@ -30,7 +30,7 @@ class KtCollectionLiteralExpression(node: ASTNode) : KtExpressionImpl(node), KtR get() = findChildByType(KtTokens.LBRACKET) val rightBracket: PsiElement? - get() = findChildByType(KtTokens.LBRACKET) + get() = findChildByType(KtTokens.RBRACKET) fun getInnerExpressions(): List { return PsiTreeUtil.getChildrenOfTypeAsList(this, KtExpression::class.java) diff --git a/idea/testData/resolve/references/CollectionLiteralLeft.kt b/idea/testData/resolve/references/CollectionLiteralLeft.kt new file mode 100644 index 00000000000..6f14f4872a3 --- /dev/null +++ b/idea/testData/resolve/references/CollectionLiteralLeft.kt @@ -0,0 +1,3 @@ +val abc = [1, 2, 3] + +// REF: (kotlin).arrayOf(vararg T) \ No newline at end of file diff --git a/idea/testData/resolve/references/CollectionLiteralRight.kt b/idea/testData/resolve/references/CollectionLiteralRight.kt new file mode 100644 index 00000000000..ca056e4de81 --- /dev/null +++ b/idea/testData/resolve/references/CollectionLiteralRight.kt @@ -0,0 +1,3 @@ +val abc: IntArray = [1, 2, 3] + +// REF: (kotlin).intArrayOf(vararg kotlin.Int) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java index 72ac7c19368..c5d01c55b55 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java @@ -108,6 +108,18 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest doTest(fileName); } + @TestMetadata("CollectionLiteralLeft.kt") + public void testCollectionLiteralLeft() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/CollectionLiteralLeft.kt"); + doTest(fileName); + } + + @TestMetadata("CollectionLiteralRight.kt") + public void testCollectionLiteralRight() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/CollectionLiteralRight.kt"); + doTest(fileName); + } + @TestMetadata("CoroutineSuspensionPoint.kt") public void testCoroutineSuspensionPoint() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/CoroutineSuspensionPoint.kt");