KT-6521 Expand selection works wrong on a call inside for loop's range

KT-6518 Extend selection not working for expression in if

 #KT-6521 Fixed
 #KT-6518 Fixed
This commit is contained in:
Valentin Kipyatkov
2014-12-23 22:57:59 +03:00
parent 94466da61b
commit 37e40267fe
11 changed files with 46 additions and 1 deletions
@@ -19,6 +19,7 @@ package org.jetbrains.jet.jvm.compiler;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.jet.JUnit3RunnerWithInners;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.junit.runner.RunWith;
@@ -29,7 +29,7 @@ public class KotlinWordSelectionFilter : Condition<PsiElement>{
if (KotlinListSelectioner.canSelect(e)) return false
if (e is JetContainerNode) return false
if (e.getParent().getFirstChild().getNextSibling() == null) return false // skip nodes with the same range as their parent
if (e.getParent().getFirstChild().getNextSibling() == null && e.getParent() !is JetContainerNode) return false // skip nodes with the same range as their parent
return when (e.getNode().getElementType()) {
BLOCK, LITERAL_STRING_TEMPLATE_ENTRY -> false
@@ -0,0 +1,5 @@
fun foo() {
for (i in 1..<caret>10) {
}
}
@@ -0,0 +1,5 @@
fun foo() {
for (i in 1..<selection><caret>10</selection>) {
}
}
@@ -0,0 +1,5 @@
fun foo() {
for (i in <selection>1..<caret>10</selection>) {
}
}
@@ -0,0 +1,5 @@
fun foo() {
<selection> for (i in 1..<caret>10) {
}
</selection>}
@@ -0,0 +1,5 @@
fun foo() {
if (!<caret>a) {
bar()
}
}
@@ -0,0 +1,5 @@
fun foo() {
if (!<selection><caret>a</selection>) {
bar()
}
}
@@ -0,0 +1,5 @@
fun foo() {
if (<selection>!<caret>a</selection>) {
bar()
}
}
@@ -0,0 +1,5 @@
fun foo() {
<selection> if (!<caret>a) {
bar()
}
</selection>}
@@ -55,6 +55,10 @@ public class WordSelectionTest extends JetLightCodeInsightFixtureTestCase {
public void testTemplateStringLiteral2() { doTest(); }
public void testTemplateStringLiteral3() { doTest(); }
public void testForRange() { doTest(); }
public void testIfCondition() { doTest(); }
private void doTest() {
String dirName = getTestName(false);