KT-13693 Expand selection for array brackets

#KT-13693 Fixed
This commit is contained in:
shiraji
2016-09-10 18:06:09 +09:00
parent 3f2f79ef59
commit d83b1747bb
7 changed files with 49 additions and 0 deletions
+1
View File
@@ -510,6 +510,7 @@
<extendWordSelectionHandler implementation="org.jetbrains.kotlin.idea.editor.wordSelection.KotlinInvokedExpressionSelectioner"/>
<extendWordSelectionHandler implementation="org.jetbrains.kotlin.idea.editor.wordSelection.KotlinTypeSelectioner"/>
<extendWordSelectionHandler implementation="org.jetbrains.kotlin.idea.editor.wordSelection.KotlinSuperTypeSelectioner"/>
<extendWordSelectionHandler implementation="org.jetbrains.kotlin.idea.editor.wordSelection.KotlinBracketsSelectioner"/>
<basicWordSelectionFilter implementation="org.jetbrains.kotlin.idea.editor.wordSelection.KotlinWordSelectionFilter"/>
<typedHandler implementation="org.jetbrains.kotlin.idea.editor.KotlinTypedHandler"/>
@@ -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
}
}
+4
View File
@@ -0,0 +1,4 @@
fun test() {
val a = arrayOf(arrayOf(1))
a[1][2<caret>]
}
+4
View File
@@ -0,0 +1,4 @@
fun test() {
val a = arrayOf(arrayOf(1))
a[1][<selection>2<caret></selection>]
}
+4
View File
@@ -0,0 +1,4 @@
fun test() {
val a = arrayOf(arrayOf(1))
a[1]<selection>[2<caret>]</selection>
}
+4
View File
@@ -0,0 +1,4 @@
fun test() {
val a = arrayOf(arrayOf(1))
<selection>a[1][2<caret>]</selection>
}
@@ -100,6 +100,10 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase {
doTest();
}
public void testArrayBrackets() {
doTest();
}
private void doTest() {
String dirName = getTestName(false);