From ead2dea10deac417da667379ee630ed56542ef61 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 1 Oct 2014 22:15:28 +0400 Subject: [PATCH] Corrected annotations: ExtendWordSelectionHandler CAN return null --- .../com/intellij/codeInsight/editorActions/annotations.xml | 6 ++---- .../plugin/editor/wordSelection/JetCodeBlockSelectioner.kt | 2 +- .../jet/plugin/editor/wordSelection/JetListSelectioner.kt | 6 +++--- .../editor/wordSelection/JetStatementGroupSelectioner.kt | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/annotations/com/intellij/codeInsight/editorActions/annotations.xml b/annotations/com/intellij/codeInsight/editorActions/annotations.xml index 70bff5ebfbb..59fe9e5fcd9 100644 --- a/annotations/com/intellij/codeInsight/editorActions/annotations.xml +++ b/annotations/com/intellij/codeInsight/editorActions/annotations.xml @@ -173,10 +173,9 @@ - + val=""fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>?""/> - + val=""fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>?""/> { + override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { val result = ArrayList() val node = e.getNode()!! diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt index 230003ab596..2e8ba072ee2 100644 --- a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt +++ b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt @@ -34,10 +34,10 @@ public class JetListSelectioner : BasicSelectioner() { override fun canSelect(e: PsiElement) = e is JetParameterList || e is JetValueArgumentList || e is JetTypeParameterList || e is JetTypeArgumentList - override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List { + override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { val node = e.getNode()!! - val startNode = node.findChildByType(TokenSet.create(JetTokens.LPAR, JetTokens.LT)) ?: return listOf() - val endNode = node.findChildByType(TokenSet.create(JetTokens.RPAR, JetTokens.GT)) ?: return listOf() + val startNode = node.findChildByType(TokenSet.create(JetTokens.LPAR, JetTokens.LT)) ?: return null + val endNode = node.findChildByType(TokenSet.create(JetTokens.RPAR, JetTokens.GT)) ?: return null return listOf(TextRange(startNode.getStartOffset() + 1, endNode.getStartOffset())) } } diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt index 963b7dbd61d..e49e19b0a0e 100644 --- a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt +++ b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt @@ -39,9 +39,9 @@ public class JetStatementGroupSelectioner : BasicSelectioner() { override fun canSelect(e: PsiElement) = e is JetExpression || e is JetWhenEntry - override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List { + override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List? { val parent = e.getParent() - if (parent !is JetBlockExpression && parent !is JetWhenExpression) return listOf() + if (parent !is JetBlockExpression && parent !is JetWhenExpression) return null val startElement = e.siblings(forward = false, withItself = false) .firstOrNull { // find preceding '{' or blank line