LightQuickFixTestCase.parseActionHint() method was removed
This commit is contained in:
committed by
Dmitry Jemerov
parent
d5aac7df25
commit
4f079d2768
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.quickfix;
|
|||||||
|
|
||||||
import com.intellij.codeInsight.CodeInsightSettings;
|
import com.intellij.codeInsight.CodeInsightSettings;
|
||||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||||
|
import com.intellij.codeInsight.daemon.quickFix.ActionHint;
|
||||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||||
import com.intellij.codeInsight.intention.IntentionAction;
|
import com.intellij.codeInsight.intention.IntentionAction;
|
||||||
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
|
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
|
||||||
@@ -285,10 +286,10 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
|
|||||||
try {
|
try {
|
||||||
PsiFile psiFile = getFile();
|
PsiFile psiFile = getFile();
|
||||||
|
|
||||||
Pair<String, Boolean> pair = LightQuickFixTestCase.parseActionHint(psiFile, beforeFile.content);
|
ActionHint actionHint = ActionHint.parse(psiFile, beforeFile.content);
|
||||||
String text = pair.getFirst();
|
String text = actionHint.getExpectedText();
|
||||||
|
|
||||||
boolean actionShouldBeAvailable = pair.getSecond();
|
boolean actionShouldBeAvailable = actionHint.shouldPresent();
|
||||||
|
|
||||||
if (psiFile instanceof KtFile) {
|
if (psiFile instanceof KtFile) {
|
||||||
DirectiveBasedActionUtils.INSTANCE.checkForUnexpectedErrors((KtFile) psiFile);
|
DirectiveBasedActionUtils.INSTANCE.checkForUnexpectedErrors((KtFile) psiFile);
|
||||||
@@ -300,7 +301,7 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
|
|||||||
String afterText =
|
String afterText =
|
||||||
new StringBuilder(actualText).insert(getEditor().getCaretModel().getOffset(), "<caret>").toString();
|
new StringBuilder(actualText).insert(getEditor().getCaretModel().getOffset(), "<caret>").toString();
|
||||||
|
|
||||||
if (pair.second) {
|
if (actionShouldBeAvailable) {
|
||||||
assertNotNull(".after file should exist", afterFile);
|
assertNotNull(".after file should exist", afterFile);
|
||||||
if (!afterText.equals(afterFile.content)) {
|
if (!afterText.equals(afterFile.content)) {
|
||||||
StringBuilder actualTestFile = new StringBuilder();
|
StringBuilder actualTestFile = new StringBuilder();
|
||||||
@@ -389,10 +390,10 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
|
|||||||
try {
|
try {
|
||||||
PsiFile psiFile = getFile();
|
PsiFile psiFile = getFile();
|
||||||
|
|
||||||
Pair<String, Boolean> pair = LightQuickFixTestCase.parseActionHint(psiFile, originalFileText);
|
ActionHint actionHint = ActionHint.parse(psiFile, originalFileText);
|
||||||
String text = pair.getFirst();
|
String text = actionHint.getExpectedText();
|
||||||
|
|
||||||
boolean actionShouldBeAvailable = pair.getSecond();
|
boolean actionShouldBeAvailable = actionHint.shouldPresent();
|
||||||
|
|
||||||
if (psiFile instanceof KtFile) {
|
if (psiFile instanceof KtFile) {
|
||||||
DirectiveBasedActionUtils.INSTANCE.checkForUnexpectedErrors((KtFile) psiFile);
|
DirectiveBasedActionUtils.INSTANCE.checkForUnexpectedErrors((KtFile) psiFile);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.quickfix
|
package org.jetbrains.kotlin.idea.quickfix
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.daemon.quickFix.ActionHint
|
||||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase
|
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase
|
||||||
import com.intellij.codeInsight.intention.IntentionAction
|
import com.intellij.codeInsight.intention.IntentionAction
|
||||||
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler
|
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler
|
||||||
@@ -62,10 +63,10 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() {
|
|||||||
try {
|
try {
|
||||||
val psiFile = actionFile
|
val psiFile = actionFile
|
||||||
|
|
||||||
val pair = LightQuickFixTestCase.parseActionHint(psiFile, actionFileText)
|
val actionHint = ActionHint.parse(psiFile, actionFileText)
|
||||||
val text = pair.getFirst()
|
val text = actionHint.expectedText
|
||||||
|
|
||||||
val actionShouldBeAvailable = pair.getSecond()
|
val actionShouldBeAvailable = actionHint.shouldPresent()
|
||||||
|
|
||||||
if (psiFile is KtFile) {
|
if (psiFile is KtFile) {
|
||||||
DirectiveBasedActionUtils.checkForUnexpectedErrors(psiFile)
|
DirectiveBasedActionUtils.checkForUnexpectedErrors(psiFile)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.idea.quickfix;
|
package org.jetbrains.kotlin.idea.quickfix;
|
||||||
|
|
||||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||||
|
import com.intellij.codeInsight.daemon.quickFix.ActionHint;
|
||||||
import com.intellij.codeInsight.daemon.quickFix.QuickFixTestCase;
|
import com.intellij.codeInsight.daemon.quickFix.QuickFixTestCase;
|
||||||
import com.intellij.codeInsight.intention.IntentionAction;
|
import com.intellij.codeInsight.intention.IntentionAction;
|
||||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||||
@@ -29,7 +30,6 @@ import com.intellij.openapi.command.CommandProcessor;
|
|||||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||||
import com.intellij.openapi.projectRoots.Sdk;
|
import com.intellij.openapi.projectRoots.Sdk;
|
||||||
import com.intellij.openapi.startup.StartupManager;
|
import com.intellij.openapi.startup.StartupManager;
|
||||||
import com.intellij.openapi.util.Pair;
|
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||||
@@ -187,18 +187,14 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
|||||||
|
|
||||||
private static void applyAction(String contents, QuickFixTestCase quickFixTestCase, String testName, String testFullPath)
|
private static void applyAction(String contents, QuickFixTestCase quickFixTestCase, String testName, String testFullPath)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Pair<String, Boolean> pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents);
|
|
||||||
|
|
||||||
String fileName = StringsKt.substringAfterLast(testFullPath, "/", "");
|
String fileName = StringsKt.substringAfterLast(testFullPath, "/", "");
|
||||||
String text = pair.getFirst().replace("${file}", fileName);
|
ActionHint actionHint = ActionHint.parse(quickFixTestCase.getFile(), contents.replace("${file}", fileName));
|
||||||
|
|
||||||
boolean actionShouldBeAvailable = pair.getSecond().booleanValue();
|
|
||||||
|
|
||||||
quickFixTestCase.beforeActionStarted(testName, contents);
|
quickFixTestCase.beforeActionStarted(testName, contents);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
myWrapper = quickFixTestCase;
|
myWrapper = quickFixTestCase;
|
||||||
quickFixTestCase.doAction(text, actionShouldBeAvailable, testFullPath, testName);
|
quickFixTestCase.doAction(actionHint, testFullPath, testName);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
myWrapper = null;
|
myWrapper = null;
|
||||||
@@ -207,9 +203,8 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName)
|
protected void doAction(ActionHint actionHint, String testFullPath, String testName) throws Exception {
|
||||||
throws Exception {
|
doAction(actionHint, testFullPath, testName, myWrapper);
|
||||||
doAction(text, actionShouldBeAvailable, testFullPath, testName, myWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -267,13 +262,13 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
|||||||
|
|
||||||
private void checkForUnexpectedActions() throws ClassNotFoundException {
|
private void checkForUnexpectedActions() throws ClassNotFoundException {
|
||||||
String text = getEditor().getDocument().getText();
|
String text = getEditor().getDocument().getText();
|
||||||
Pair<String, Boolean> pair = parseActionHintImpl(getFile(), text);
|
ActionHint actionHint = ActionHint.parse(getFile(), text);
|
||||||
if (!pair.second) {
|
if (!actionHint.shouldPresent()) {
|
||||||
List<IntentionAction> actions = getAvailableActions();
|
List<IntentionAction> actions = getAvailableActions();
|
||||||
|
|
||||||
String prefix = "class ";
|
String prefix = "class ";
|
||||||
if (pair.first.startsWith(prefix)) {
|
if (actionHint.getExpectedText().startsWith(prefix)) {
|
||||||
String className = pair.first.substring(prefix.length());
|
String className = actionHint.getExpectedText().substring(prefix.length());
|
||||||
final Class<?> aClass = Class.forName(className);
|
final Class<?> aClass = Class.forName(className);
|
||||||
assert IntentionAction.class.isAssignableFrom(aClass) : className + " should be inheritor of IntentionAction";
|
assert IntentionAction.class.isAssignableFrom(aClass) : className + " should be inheritor of IntentionAction";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user