diff --git a/annotations/com/intellij/codeInsight/editorActions/annotations.xml b/annotations/com/intellij/codeInsight/editorActions/annotations.xml
index 460373c801a..70bff5ebfbb 100644
--- a/annotations/com/intellij/codeInsight/editorActions/annotations.xml
+++ b/annotations/com/intellij/codeInsight/editorActions/annotations.xml
@@ -168,20 +168,59 @@
name='com.intellij.codeInsight.editorActions.CopyPasteReferenceProcessor void restoreReferences(com.intellij.codeInsight.editorActions.ReferenceData[], TRef[]) 1'>
- -
+
-
-
+ name='com.intellij.codeInsight.editorActions.ExtendWordSelectionHandler java.util.List<com.intellij.openapi.util.TextRange> select(com.intellij.psi.PsiElement, java.lang.CharSequence, int, com.intellij.openapi.editor.Editor)'>
+
+
+
+
+
+ -
-
+ name='com.intellij.codeInsight.editorActions.ExtendWordSelectionHandler java.util.List<com.intellij.openapi.util.TextRange> select(com.intellij.psi.PsiElement, java.lang.CharSequence, int, com.intellij.openapi.editor.Editor) 1'>
-
+ name='com.intellij.codeInsight.editorActions.ExtendWordSelectionHandler java.util.List<com.intellij.openapi.util.TextRange> select(com.intellij.psi.PsiElement, java.lang.CharSequence, int, com.intellij.openapi.editor.Editor) 3'>
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
diff --git a/annotations/com/intellij/codeInsight/editorActions/wordSelection/annotations.xml b/annotations/com/intellij/codeInsight/editorActions/wordSelection/annotations.xml
new file mode 100644
index 00000000000..1bfed657b32
--- /dev/null
+++ b/annotations/com/intellij/codeInsight/editorActions/wordSelection/annotations.xml
@@ -0,0 +1,9 @@
+
+ -
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/annotations/com/intellij/openapi/util/text/annotations.xml b/annotations/com/intellij/openapi/util/text/annotations.xml
index 92e32317eee..46b0bc93aa1 100644
--- a/annotations/com/intellij/openapi/util/text/annotations.xml
+++ b/annotations/com/intellij/openapi/util/text/annotations.xml
@@ -1,5 +1,17 @@
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
-
-
+
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetCodeBlockSelectioner.java b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetCodeBlockSelectioner.java
deleted file mode 100644
index e175b0070d5..00000000000
--- a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetCodeBlockSelectioner.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2010-2013 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.codeInsight.editorActions.wordSelection.BasicSelectioner;
-import com.intellij.lang.ASTNode;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiWhiteSpace;
-import com.intellij.psi.impl.source.tree.LeafPsiElement;
-import org.jetbrains.jet.lang.psi.JetBlockExpression;
-import org.jetbrains.jet.lang.psi.JetPsiUtil;
-import org.jetbrains.jet.lang.psi.JetWhenExpression;
-import org.jetbrains.jet.lexer.JetTokens;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Originally from IDEA platform: CodeBlockOrInitializerSelectioner
- */
-public class JetCodeBlockSelectioner extends BasicSelectioner {
- public boolean canSelect(PsiElement e) {
- return e instanceof JetBlockExpression || e instanceof JetWhenExpression;
- }
-
- public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
- List result = new ArrayList();
-
- result.add(e.getTextRange());
-
- ASTNode[] children = e.getNode().getChildren(null);
- if (children.length == 0) {
- return result;
- }
-
- int start = findOpeningBrace(children);
- int end = findClosingBrace(children, start);
-
- result.addAll(expandToWholeLine(editorText, new TextRange(start, end)));
-
- return result;
- }
-
- public static int findOpeningBrace(ASTNode[] children) {
- int start = children[children.length - 1].getTextRange().getStartOffset();
- for (int i = 0; i < children.length; i++) {
- PsiElement child = children[i].getPsi();
-
- if (child instanceof LeafPsiElement) {
- if (((LeafPsiElement) child).getElementType() == JetTokens.LBRACE) {
- int j = i + 1;
-
- while (children[j] instanceof PsiWhiteSpace) {
- j++;
- }
-
- start = children[j].getTextRange().getStartOffset();
- }
- }
- }
- return start;
- }
-
- public static int findClosingBrace(ASTNode[] children, int startOffset) {
- int end = children[children.length - 1].getTextRange().getEndOffset();
- for (int i = 0; i < children.length; i++) {
- PsiElement child = children[i].getPsi();
-
- if (child instanceof LeafPsiElement) {
- if (((LeafPsiElement) child).getElementType() == JetTokens.RBRACE) {
- int j = i - 1;
-
- while (children[j] instanceof PsiWhiteSpace && children[j].getTextRange().getStartOffset() > startOffset) {
- j--;
- }
-
- end = children[j].getTextRange().getEndOffset();
- }
- }
- }
- return end;
- }
-}
diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetCodeBlockSelectioner.kt b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetCodeBlockSelectioner.kt
new file mode 100644
index 00000000000..18b56837d4c
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetCodeBlockSelectioner.kt
@@ -0,0 +1,90 @@
+/*
+ * 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.codeInsight.editorActions.wordSelection.BasicSelectioner
+import com.intellij.lang.ASTNode
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.util.TextRange
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiWhiteSpace
+import com.intellij.psi.impl.source.tree.LeafPsiElement
+import org.jetbrains.jet.lang.psi.JetBlockExpression
+import org.jetbrains.jet.lang.psi.JetWhenExpression
+import org.jetbrains.jet.lexer.JetTokens
+
+import java.util.ArrayList
+import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase
+
+/**
+ * Originally from IDEA platform: CodeBlockOrInitializerSelectioner
+ */
+public class JetCodeBlockSelectioner : BasicSelectioner() {
+ override fun canSelect(e: PsiElement): Boolean {
+ return e is JetBlockExpression || e is JetWhenExpression
+ }
+
+ override fun select(e: PsiElement, editorText: CharSequence, cursorOffset: Int, editor: Editor): List {
+ val result = ArrayList()
+
+ val children = e.getNode()!!.getChildren(null)
+
+ val start = findOpeningBrace(children)
+ val end = findClosingBrace(children, start)
+
+ result.add(e.getTextRange()!!)
+ result.addAll(ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(start, end)))
+
+ return result
+ }
+
+ class object {
+ public fun findOpeningBrace(children: Array): Int {
+ var start = children.last().getTextRange()!!.getStartOffset()
+ for ((i, child) in children.withIndices()) {
+ if (child is LeafPsiElement) {
+ if (child.getElementType() == JetTokens.LBRACE) {
+ var j = i + 1
+ while (children[j] is PsiWhiteSpace) {
+ j++
+ }
+
+ start = children[j].getTextRange()!!.getStartOffset()
+ }
+ }
+ }
+ return start
+ }
+
+ public fun findClosingBrace(children: Array, startOffset: Int): Int {
+ var end = children[children.size - 1].getTextRange()!!.getEndOffset()
+ for ((i, child) in children.withIndices()) {
+ if (child is LeafPsiElement) {
+ if (child.getElementType() == JetTokens.RBRACE) {
+ var j = i - 1
+ while (children[j] is PsiWhiteSpace && children[j].getTextRange()!!.getStartOffset() > startOffset) {
+ j--
+ }
+
+ end = children[j].getTextRange()!!.getEndOffset()
+ }
+ }
+ }
+ return end
+ }
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.java b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.java
deleted file mode 100644
index 771f2ac614f..00000000000
--- a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2010-2013 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.codeInsight.editorActions.wordSelection.BasicSelectioner;
-import com.intellij.lang.ASTNode;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.tree.TokenSet;
-import org.jetbrains.jet.lang.psi.JetParameterList;
-import org.jetbrains.jet.lang.psi.JetTypeArgumentList;
-import org.jetbrains.jet.lang.psi.JetTypeParameterList;
-import org.jetbrains.jet.lang.psi.JetValueArgumentList;
-import org.jetbrains.jet.lexer.JetTokens;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class JetListSelectioner extends BasicSelectioner {
- @Override
- public boolean canSelect(PsiElement e) {
- return e instanceof JetParameterList || e instanceof JetValueArgumentList ||
- e instanceof JetTypeParameterList || e instanceof JetTypeArgumentList;
- }
-
- @Override
- public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
- ASTNode node = e.getNode();
- ASTNode startNode = node.findChildByType(TokenSet.create(JetTokens.LPAR, JetTokens.LT));
- ASTNode endNode = node.findChildByType(TokenSet.create(JetTokens.RPAR, JetTokens.GT));
- if (startNode != null && endNode != null) {
- return Arrays.asList(new TextRange(startNode.getStartOffset() + 1, endNode.getStartOffset()));
- } else {
- return Arrays.asList();
- }
- }
-}
diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt
new file mode 100644
index 00000000000..30fdd2a7057
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetListSelectioner.kt
@@ -0,0 +1,49 @@
+/*
+ * 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.codeInsight.editorActions.wordSelection.BasicSelectioner
+import com.intellij.lang.ASTNode
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.util.TextRange
+import com.intellij.psi.PsiElement
+import com.intellij.psi.tree.TokenSet
+import org.jetbrains.jet.lang.psi.JetParameterList
+import org.jetbrains.jet.lang.psi.JetTypeArgumentList
+import org.jetbrains.jet.lang.psi.JetTypeParameterList
+import org.jetbrains.jet.lang.psi.JetValueArgumentList
+import org.jetbrains.jet.lexer.JetTokens
+
+import java.util.Arrays
+
+public class JetListSelectioner : BasicSelectioner() {
+ override fun canSelect(e: PsiElement): Boolean {
+ return e is JetParameterList || e is JetValueArgumentList || e is JetTypeParameterList || e is JetTypeArgumentList
+ }
+
+ 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))
+ val endNode = node.findChildByType(TokenSet.create(JetTokens.RPAR, JetTokens.GT))
+ if (startNode != null && endNode != null) {
+ return Arrays.asList(TextRange(startNode.getStartOffset() + 1, endNode.getStartOffset()))
+ }
+ else {
+ return Arrays.asList()
+ }
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.java b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.java
deleted file mode 100644
index c8e934180d5..00000000000
--- a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2010-2013 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.codeInsight.editorActions.wordSelection.BasicSelectioner;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.openapi.util.text.LineTokenizer;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiWhiteSpace;
-import com.intellij.psi.impl.source.tree.LeafPsiElement;
-import org.jetbrains.jet.lang.psi.JetBlockExpression;
-import org.jetbrains.jet.lang.psi.JetExpression;
-import org.jetbrains.jet.lang.psi.JetWhenEntry;
-import org.jetbrains.jet.lang.psi.JetWhenExpression;
-import org.jetbrains.jet.lexer.JetTokens;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Originally from IDEA platform: StatementGroupSelectioner
- */
-public class JetStatementGroupSelectioner extends BasicSelectioner {
- @Override
- public boolean canSelect(PsiElement e) {
- return e instanceof JetExpression || e instanceof JetWhenEntry;
- }
-
- @Override
- public List select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
- List result = new ArrayList();
-
- PsiElement parent = e.getParent();
-
- if (!(parent instanceof JetBlockExpression) && !(parent instanceof JetWhenExpression)) {
- return result;
- }
-
-
- PsiElement startElement = e;
- PsiElement endElement = e;
-
-
- while (startElement.getPrevSibling() != null) {
- PsiElement sibling = startElement.getPrevSibling();
-
- if (sibling instanceof LeafPsiElement) {
- if (((LeafPsiElement) sibling).getElementType() == JetTokens.LBRACE) {
- break;
- }
- }
-
- if (sibling instanceof PsiWhiteSpace) {
- PsiWhiteSpace whiteSpace = (PsiWhiteSpace) sibling;
-
- String[] strings = LineTokenizer.tokenize(whiteSpace.getText().toCharArray(), false);
- if (strings.length > 2) {
- break;
- }
- }
-
- startElement = sibling;
- }
-
- while (startElement instanceof PsiWhiteSpace) {
- startElement = startElement.getNextSibling();
- }
-
- while (endElement.getNextSibling() != null) {
- PsiElement sibling = endElement.getNextSibling();
-
- if (sibling instanceof LeafPsiElement) {
- if (((LeafPsiElement) sibling).getElementType() == JetTokens.RBRACE) {
- break;
- }
- }
-
- if (sibling instanceof PsiWhiteSpace) {
- PsiWhiteSpace whiteSpace = (PsiWhiteSpace) sibling;
-
- String[] strings = LineTokenizer.tokenize(whiteSpace.getText().toCharArray(), false);
- if (strings.length > 2) {
- break;
- }
- }
-
- endElement = sibling;
- }
-
- while (endElement instanceof PsiWhiteSpace) {
- endElement = endElement.getPrevSibling();
- }
-
- result.addAll(expandToWholeLine(editorText, new TextRange(startElement.getTextRange().getStartOffset(),
- endElement.getTextRange().getEndOffset())));
-
- return result;
- }
-}
diff --git a/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt
new file mode 100644
index 00000000000..a62a5847cd3
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/editor/wordSelection/JetStatementGroupSelectioner.kt
@@ -0,0 +1,80 @@
+/*
+ * 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.codeInsight.editorActions.wordSelection.BasicSelectioner
+import com.intellij.openapi.editor.Editor
+import com.intellij.openapi.util.TextRange
+import com.intellij.openapi.util.text.LineTokenizer
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiWhiteSpace
+import com.intellij.psi.impl.source.tree.LeafPsiElement
+import org.jetbrains.jet.lang.psi.JetBlockExpression
+import org.jetbrains.jet.lang.psi.JetExpression
+import org.jetbrains.jet.lang.psi.JetWhenEntry
+import org.jetbrains.jet.lang.psi.JetWhenExpression
+import org.jetbrains.jet.lexer.JetTokens
+
+import java.util.ArrayList
+import com.intellij.codeInsight.editorActions.ExtendWordSelectionHandlerBase
+
+/**
+ * Originally from IDEA platform: StatementGroupSelectioner
+ */
+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 {
+ val parent = e.getParent()
+ if (parent !is JetBlockExpression && parent !is JetWhenExpression) {
+ return listOf()
+ }
+
+ var startElement = e
+ while (startElement.getPrevSibling() != null) {
+ val sibling = startElement.getPrevSibling()
+
+ if (sibling is LeafPsiElement && sibling.getElementType() == JetTokens.LBRACE) break
+
+ if (sibling is PsiWhiteSpace && LineTokenizer.tokenize(sibling.getText()!!.toCharArray(), false).size > 2) break
+
+ startElement = sibling!!
+ }
+
+ while (startElement is PsiWhiteSpace) {
+ startElement = startElement.getNextSibling()!!
+ }
+
+ var endElement = e
+ while (endElement.getNextSibling() != null) {
+ val sibling = endElement.getNextSibling()
+
+ if (sibling is LeafPsiElement && sibling.getElementType() == JetTokens.RBRACE) break
+
+ if (sibling is PsiWhiteSpace && LineTokenizer.tokenize(sibling.getText()!!.toCharArray(), false).size > 2) break
+
+ endElement = sibling!!
+ }
+
+ while (endElement is PsiWhiteSpace) {
+ endElement = endElement.getPrevSibling()!!
+ }
+
+ return ExtendWordSelectionHandlerBase.expandToWholeLine(editorText, TextRange(startElement.getTextRange()!!.getStartOffset(), endElement.getTextRange()!!.getEndOffset()))
+ }
+}