Move check with selection tags to base check
This commit is contained in:
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.editor.Caret;
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
@@ -634,8 +635,17 @@ public class KotlinTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
||||||
String actualText = editor.getDocument().getText();
|
Caret caret = editor.getCaretModel().getCurrentCaret();
|
||||||
String afterText = new StringBuilder(actualText).insert(editor.getCaretModel().getOffset(), "<caret>").toString();
|
int selectionStart = caret.getSelectionStart();
|
||||||
|
int selectionEnd = caret.getSelectionEnd();
|
||||||
|
|
||||||
|
String afterText = TagsTestDataUtil.insertTagsInText(
|
||||||
|
Lists.<TagsTestDataUtil.TagInfo>newArrayList(
|
||||||
|
new TagsTestDataUtil.TagInfo<>(caret.getOffset(), true, "caret"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionStart, true, "selection"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionEnd, false, "selection")),
|
||||||
|
editor.getDocument().getText()
|
||||||
|
);
|
||||||
|
|
||||||
assertEqualsToFile(expectedFile, afterText);
|
assertEqualsToFile(expectedFile, afterText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.editor.Caret;
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
@@ -629,8 +630,17 @@ public class KotlinTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
||||||
String actualText = editor.getDocument().getText();
|
Caret caret = editor.getCaretModel().getCurrentCaret();
|
||||||
String afterText = new StringBuilder(actualText).insert(editor.getCaretModel().getOffset(), "<caret>").toString();
|
int selectionStart = caret.getSelectionStart();
|
||||||
|
int selectionEnd = caret.getSelectionEnd();
|
||||||
|
|
||||||
|
String afterText = TagsTestDataUtil.insertTagsInText(
|
||||||
|
Lists.<TagsTestDataUtil.TagInfo>newArrayList(
|
||||||
|
new TagsTestDataUtil.TagInfo<>(caret.getOffset(), true, "caret"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionStart, true, "selection"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionEnd, false, "selection")),
|
||||||
|
editor.getDocument().getText()
|
||||||
|
);
|
||||||
|
|
||||||
assertEqualsToFile(expectedFile, afterText);
|
assertEqualsToFile(expectedFile, afterText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.editor.Caret;
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
@@ -629,8 +630,17 @@ public class KotlinTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
||||||
String actualText = editor.getDocument().getText();
|
Caret caret = editor.getCaretModel().getCurrentCaret();
|
||||||
String afterText = new StringBuilder(actualText).insert(editor.getCaretModel().getOffset(), "<caret>").toString();
|
int selectionStart = caret.getSelectionStart();
|
||||||
|
int selectionEnd = caret.getSelectionEnd();
|
||||||
|
|
||||||
|
String afterText = TagsTestDataUtil.insertTagsInText(
|
||||||
|
Lists.<TagsTestDataUtil.TagInfo>newArrayList(
|
||||||
|
new TagsTestDataUtil.TagInfo<>(caret.getOffset(), true, "caret"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionStart, true, "selection"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionEnd, false, "selection")),
|
||||||
|
editor.getDocument().getText()
|
||||||
|
);
|
||||||
|
|
||||||
assertEqualsToFile(expectedFile, afterText);
|
assertEqualsToFile(expectedFile, afterText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
|
import com.intellij.openapi.editor.Caret;
|
||||||
import com.intellij.openapi.editor.Document;
|
import com.intellij.openapi.editor.Document;
|
||||||
import com.intellij.openapi.editor.Editor;
|
import com.intellij.openapi.editor.Editor;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
@@ -629,8 +630,17 @@ public class KotlinTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
|
||||||
String actualText = editor.getDocument().getText();
|
Caret caret = editor.getCaretModel().getCurrentCaret();
|
||||||
String afterText = new StringBuilder(actualText).insert(editor.getCaretModel().getOffset(), "<caret>").toString();
|
int selectionStart = caret.getSelectionStart();
|
||||||
|
int selectionEnd = caret.getSelectionEnd();
|
||||||
|
|
||||||
|
String afterText = TagsTestDataUtil.insertTagsInText(
|
||||||
|
Lists.<TagsTestDataUtil.TagInfo>newArrayList(
|
||||||
|
new TagsTestDataUtil.TagInfo<>(caret.getOffset(), true, "caret"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionStart, true, "selection"),
|
||||||
|
new TagsTestDataUtil.TagInfo<>(selectionEnd, false, "selection")),
|
||||||
|
editor.getDocument().getText()
|
||||||
|
);
|
||||||
|
|
||||||
assertEqualsToFile(expectedFile, afterText);
|
assertEqualsToFile(expectedFile, afterText);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
println()<caret>
|
println()<selection><caret></selection>
|
||||||
println()
|
println()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
fun foo(): Int =<caret> 1
|
fun foo(): Int =<selection><caret></selection> 1
|
||||||
|
|||||||
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea;
|
package org.jetbrains.kotlin.idea;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.intellij.openapi.editor.Caret;
|
|
||||||
import com.intellij.openapi.editor.Editor;
|
|
||||||
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
import com.intellij.rt.execution.junit.FileComparisonFailure;
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
|
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
|
||||||
@@ -26,7 +23,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
|
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase;
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
import org.jetbrains.kotlin.test.TagsTestDataUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -183,21 +179,6 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void wrapToFileComparisonFailure(String failedFilePath) {
|
private void wrapToFileComparisonFailure(String failedFilePath) {
|
||||||
Editor editor = myFixture.getEditor();
|
KotlinTestUtils.assertEqualsToFile(new File(failedFilePath), myFixture.getEditor());
|
||||||
|
|
||||||
Caret caret = editor.getCaretModel().getCurrentCaret();
|
|
||||||
int selectionStart = caret.getSelectionStart();
|
|
||||||
int selectionEnd = caret.getSelectionEnd();
|
|
||||||
|
|
||||||
String actualText = TagsTestDataUtil.insertTagsInText(
|
|
||||||
Lists.<TagsTestDataUtil.TagInfo>newArrayList(
|
|
||||||
new TagsTestDataUtil.TagInfo<String>(caret.getOffset(), true, "caret"),
|
|
||||||
new TagsTestDataUtil.TagInfo<String>(selectionStart, true, "selection"),
|
|
||||||
new TagsTestDataUtil.TagInfo<String>(selectionEnd, false, "selection")),
|
|
||||||
editor.getDocument().getText()
|
|
||||||
);
|
|
||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(new File(failedFilePath), actualText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user