Corrected annotations: ExtendWordSelectionHandler CAN return null

This commit is contained in:
Valentin Kipyatkov
2014-10-01 22:15:28 +04:00
parent f4c9eabd1d
commit ead2dea10d
4 changed files with 8 additions and 10 deletions
@@ -173,10 +173,9 @@
</item>
<item
name='com.intellij.codeInsight.editorActions.ExtendWordSelectionHandler java.util.List&lt;com.intellij.openapi.util.TextRange&gt; select(com.intellij.psi.PsiElement, java.lang.CharSequence, int, com.intellij.openapi.editor.Editor)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
<annotation name='kotlin.jvm.KotlinSignature'>
<val name="value"
val="&quot;fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List&lt;TextRange&gt;&quot;"/>
val="&quot;fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List&lt;TextRange&gt;?&quot;"/>
</annotation>
</item>
<item
@@ -213,10 +212,9 @@
</item>
<item
name='com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase java.util.List&lt;com.intellij.openapi.util.TextRange&gt; select(com.intellij.psi.PsiElement, java.lang.CharSequence, int, com.intellij.openapi.editor.Editor)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
<annotation name='kotlin.jvm.KotlinSignature'>
<val name="value"
val="&quot;fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List&lt;TextRange&gt;&quot;"/>
val="&quot;fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List&lt;TextRange&gt;?&quot;"/>
</annotation>
</item>
<item
@@ -37,7 +37,7 @@ public class JetCodeBlockSelectioner : BasicSelectioner() {
override fun canSelect(e: PsiElement)
= e is JetBlockExpression || e is JetWhenExpression
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange> {
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
val result = ArrayList<TextRange>()
val node = e.getNode()!!
@@ -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<TextRange> {
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
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()))
}
}
@@ -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<TextRange> {
override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List<TextRange>? {
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