More correct quickfix testing - do not include suppression actions not available at caret
This commit is contained in:
@@ -38,9 +38,9 @@ import com.intellij.rt.execution.junit.FileComparisonFailure;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.text.StringsKt;
|
||||
import kotlin.io.FilesKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.apache.commons.lang.SystemUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -310,15 +310,18 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
|
||||
if (intention != null) return intention;
|
||||
|
||||
// Support warning suppression
|
||||
int caretOffset = myEditor.getCaretModel().getOffset();
|
||||
for (HighlightInfo highlight : doHighlighting()) {
|
||||
ProblemGroup group = highlight.getProblemGroup();
|
||||
if (group instanceof SuppressableProblemGroup) {
|
||||
SuppressableProblemGroup problemGroup = (SuppressableProblemGroup) group;
|
||||
PsiElement at = getFile().findElementAt(highlight.getActualStartOffset());
|
||||
SuppressIntentionAction[] actions = problemGroup.getSuppressActions(at);
|
||||
for (SuppressIntentionAction action : actions) {
|
||||
if (action.getText().equals(text)) {
|
||||
return action;
|
||||
if (highlight.startOffset <= caretOffset && caretOffset <= highlight.endOffset) {
|
||||
ProblemGroup group = highlight.getProblemGroup();
|
||||
if (group instanceof SuppressableProblemGroup) {
|
||||
SuppressableProblemGroup problemGroup = (SuppressableProblemGroup) group;
|
||||
PsiElement at = getFile().findElementAt(highlight.getActualStartOffset());
|
||||
SuppressIntentionAction[] actions = problemGroup.getSuppressActions(at);
|
||||
for (SuppressIntentionAction action : actions) {
|
||||
if (action.getText().equals(text)) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user