diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 091ccb07953..f18ac78e0d7 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -510,6 +510,7 @@ + diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinBracketsSelectioner.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinBracketsSelectioner.kt new file mode 100644 index 00000000000..4b3f0c30ac7 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinBracketsSelectioner.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.editor.wordSelection + +import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.psi.KtContainerNode + +class KotlinBracketsSelectioner : ExtendWordSelectionHandlerBase() { + override fun canSelect(e: PsiElement?): Boolean { + return e is KtContainerNode && e.node.elementType == KtNodeTypes.INDICES + } +} \ No newline at end of file diff --git a/idea/testData/wordSelection/ArrayBrackets/0.kt b/idea/testData/wordSelection/ArrayBrackets/0.kt new file mode 100644 index 00000000000..8165e4d1bbb --- /dev/null +++ b/idea/testData/wordSelection/ArrayBrackets/0.kt @@ -0,0 +1,4 @@ +fun test() { + val a = arrayOf(arrayOf(1)) + a[1][2] +} \ No newline at end of file diff --git a/idea/testData/wordSelection/ArrayBrackets/1.kt b/idea/testData/wordSelection/ArrayBrackets/1.kt new file mode 100644 index 00000000000..1ed7bda1143 --- /dev/null +++ b/idea/testData/wordSelection/ArrayBrackets/1.kt @@ -0,0 +1,4 @@ +fun test() { + val a = arrayOf(arrayOf(1)) + a[1][2] +} \ No newline at end of file diff --git a/idea/testData/wordSelection/ArrayBrackets/2.kt b/idea/testData/wordSelection/ArrayBrackets/2.kt new file mode 100644 index 00000000000..64d40bae690 --- /dev/null +++ b/idea/testData/wordSelection/ArrayBrackets/2.kt @@ -0,0 +1,4 @@ +fun test() { + val a = arrayOf(arrayOf(1)) + a[1][2] +} \ No newline at end of file diff --git a/idea/testData/wordSelection/ArrayBrackets/3.kt b/idea/testData/wordSelection/ArrayBrackets/3.kt new file mode 100644 index 00000000000..f24107456d3 --- /dev/null +++ b/idea/testData/wordSelection/ArrayBrackets/3.kt @@ -0,0 +1,4 @@ +fun test() { + val a = arrayOf(arrayOf(1)) + a[1][2] +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java b/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java index 991798d2371..800328ad751 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java @@ -100,6 +100,10 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase { doTest(); } + public void testArrayBrackets() { + doTest(); + } + private void doTest() { String dirName = getTestName(false);