KT-5895 Select Word: no need to select argument list including parenthesis

#KT-5895 Fixed
This commit is contained in:
Valentin Kipyatkov
2014-12-15 19:51:22 -07:00
parent dceeeb2724
commit 5f9e685188
7 changed files with 42 additions and 1 deletions
+1
View File
@@ -321,6 +321,7 @@
<extendWordSelectionHandler implementation="org.jetbrains.jet.plugin.editor.wordSelection.KotlinDocCommentSelectioner"/>
<extendWordSelectionHandler implementation="org.jetbrains.jet.plugin.editor.wordSelection.KotlinDeclarationSelectioner"/>
<extendWordSelectionHandler implementation="org.jetbrains.jet.plugin.editor.wordSelection.KotlinListSelectioner"/>
<basicWordSelectionFilter implementation="org.jetbrains.jet.plugin.editor.wordSelection.KotlinWordSelectionFilter"/>
<typedHandler implementation="org.jetbrains.jet.plugin.editor.KotlinTypedHandler"/>
<enterHandlerDelegate implementation="org.jetbrains.jet.plugin.editor.KotlinEnterHandler"
@@ -28,8 +28,12 @@ import org.jetbrains.jet.lexer.JetTokens
import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase
public class KotlinListSelectioner : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement)
class object {
fun canSelect(e: PsiElement)
= e is JetParameterList || e is JetValueArgumentList || e is JetTypeParameterList || e is JetTypeArgumentList
}
override fun canSelect(e: PsiElement) = KotlinListSelectioner.canSelect(e)
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
val node = e.getNode()!!
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2014 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.jet.plugin.editor.wordSelection
import com.intellij.openapi.util.Condition
import com.intellij.psi.PsiElement
public class KotlinWordSelectionFilter : Condition<PsiElement>{
override fun value(e: PsiElement) = !KotlinListSelectioner.canSelect(e)
}
@@ -0,0 +1,3 @@
fun <A, B> foo() {
<selection>foo<I<caret>nt, B>()</selection>
}
@@ -0,0 +1,3 @@
<selection>fun <A, <caret>B> foo() {
}
</selection>
@@ -0,0 +1,3 @@
fun foo() {
<selection>foo(<caret>1, 2)</selection>
}
@@ -0,0 +1,3 @@
<selection>fun foo(a : Array<String>, <caret>b : Int) {
}
</selection>