Minor code refactoring

This commit is contained in:
Valentin Kipyatkov
2014-12-15 20:26:36 -07:00
parent 11a72632bc
commit 01b70cfe8e
@@ -35,12 +35,14 @@ import com.intellij.psi.PsiComment
* Originally from IDEA platform: StatementGroupSelectioner * Originally from IDEA platform: StatementGroupSelectioner
*/ */
public class KotlinStatementGroupSelectioner : ExtendWordSelectionHandlerBase() { public class KotlinStatementGroupSelectioner : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement) override fun canSelect(e: PsiElement): Boolean {
= e is JetExpression || e is JetWhenEntry || e is PsiComment if (e !is JetExpression && e !is JetWhenEntry && e !is PsiComment) return false
val parent = e.getParent()
return parent is JetBlockExpression || parent 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 parent = e.getParent() val parent = e.getParent()
if (parent !is JetBlockExpression && parent !is JetWhenExpression) return null
val startElement = e.siblings(forward = false, withItself = false) val startElement = e.siblings(forward = false, withItself = false)
.firstOrNull { // find preceding '{' or blank line .firstOrNull { // find preceding '{' or blank line