mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[lombok] IDEA-301009 fix quickfix creation (added test)
GitOrigin-RevId: a22d0e428adb191220c8b85a0f7a14e62d63a2c4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cb49799e15
commit
012f1176fe
@@ -0,0 +1,55 @@
|
||||
package de.plushnikov.intellij.plugin.inspection;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import de.plushnikov.intellij.plugin.AbstractLombokLightCodeInsightTestCase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DataEqualsAndHashCodeQuickFixTest extends AbstractLombokLightCodeInsightTestCase {
|
||||
|
||||
public void testClassWithDataExtendsObject() {
|
||||
myFixture.configureByText(JavaFileType.INSTANCE, """
|
||||
import lombok.Data;
|
||||
|
||||
@Data<caret>
|
||||
public class ClassWithDataExtendsObject {
|
||||
private String str;
|
||||
}
|
||||
""");
|
||||
|
||||
assertFalse("Annotate class by '@EqualsAndHashCode' QuickFix should NOT be present",
|
||||
hasActionWithText());
|
||||
}
|
||||
|
||||
public void testClassWithDataExtendsAnotherClass() {
|
||||
myFixture.configureByText(JavaFileType.INSTANCE, """
|
||||
static class SomeClassA {
|
||||
private int i;
|
||||
}
|
||||
|
||||
@lombok.Data<caret>
|
||||
public class ClassWithDataExtendsAnotherClass extends SomeClassA {
|
||||
private String str;
|
||||
}
|
||||
""");
|
||||
|
||||
assertTrue("Annotate class by '@EqualsAndHashCode' QuickFix should be present",
|
||||
hasActionWithText());
|
||||
}
|
||||
|
||||
private boolean hasActionWithText() {
|
||||
myFixture.enableInspections(LombokInspection.class);
|
||||
|
||||
final Editor editor = getEditor();
|
||||
final PsiFile file = getFile();
|
||||
CodeInsightTestFixtureImpl.instantiateAndRun(file, editor, new int[0], false);
|
||||
final List<IntentionAction> availableActions = CodeInsightTestFixtureImpl.getAvailableIntentions(editor, file);
|
||||
|
||||
return ContainerUtil.exists(availableActions, action -> action.getText().contains("'@EqualsAndHashCode'"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user