diff --git a/build.gradle.kts b/build.gradle.kts
index d7eaa28..cfa8d3a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -57,7 +57,8 @@ dependencies {
intellijIdeaCommunity("2023.2.6")
//intellijIdeaCommunity("2023.3.6")
//intellijIdeaCommunity("2024.1.6")
- //intellijIdeaCommunity("2024.2.1")
+ //intellijIdeaCommunity("2024.2.4")
+ //intellijIdeaCommunity("2024.3")
// EAP
//create("IC","243.12818.47")
bundledPlugin("com.intellij.java")
@@ -74,7 +75,7 @@ dependencies {
//bundledPlugin("com.intellij.modules.json") // TODO: Uncomment when it exists (check at least when requiring 2024.3+)...
bundledPlugin("org.intellij.intelliLang")
- // Extra plugin(s); not needed, but maybe useful during development:
+ // Extra plugin(s); not needed for the plugin, but maybe useful during development:
bundledPlugin("org.intellij.plugins.markdown")
/* Other (bundled) plugins: */
// Define these variables to prevent spell checking errors in the comment below
@@ -123,6 +124,7 @@ intellijPlatform {
changeNotes.set("""
Version 232.0.1:
- Improve threading for previewing quick fixes
+ - Improve/refactor action tests
Version 232.0.0:
- Upgraded minimum supported JetBrains version to 2023.2
diff --git a/src/test/java/opwvhk/intellij/avro_idl/AvroIdlCodeInsightTest.java b/src/test/java/opwvhk/intellij/avro_idl/AvroIdlCodeInsightTest.java
index 1d37851..b6025c4 100644
--- a/src/test/java/opwvhk/intellij/avro_idl/AvroIdlCodeInsightTest.java
+++ b/src/test/java/opwvhk/intellij/avro_idl/AvroIdlCodeInsightTest.java
@@ -2,11 +2,7 @@
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.lang.LanguageDocumentation;
import com.intellij.lang.annotation.HighlightSeverity;
-import com.intellij.lang.documentation.DocumentationProvider;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiElement;
import com.intellij.spellchecker.SpellCheckerSeveritiesProvider;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import opwvhk.intellij.avro_idl.inspections.*;
@@ -16,10 +12,6 @@
@SuppressWarnings("unchecked")
public class AvroIdlCodeInsightTest extends BasePlatformTestCase {
-
- private static final DocumentationProvider DOCUMENTATION_PROVIDER = LanguageDocumentation.INSTANCE.forLanguage(
- AvroIdlLanguage.INSTANCE);
-
@Override
protected String getTestDataPath() {
return "src/test/testData/codeInsight";
@@ -43,6 +35,7 @@ public void testAnnotator() {
Highlight.error("my-data", "Not a valid identifier: my-data"),
Highlight.error("duplicate", "Field \"duplicate\" is already defined"),
Highlight.error("duplicate", "Field \"duplicate\" is already defined"),
+ // 11
Highlight.error("@namespace(\"unused\")",
"Type references must not be annotated: Avro < 1.11.1 changes the referenced type, Avro >= 1.11.1 fails to compile."),
Highlight.error("one-letter", "Not a valid identifier: one-letter"),
@@ -59,6 +52,7 @@ public void testAnnotator() {
Highlight.error("@logicalType(\"timestamp-millis\")",
"The logical type \"timestamp-millis\" requires the underlying type \"long\""),
Highlight.error("56", "@aliases elements must be strings"),
+ // 21
Highlight.error("\"invites-failure\"", "Not a valid identifier: invites-failure"),
Highlight.error("@logicalType(\"local-timestamp-millis\")",
"The logical type \"local-timestamp-millis\" requires the underlying type \"long\""),
@@ -73,8 +67,10 @@ public void testAnnotator() {
Highlight.error("@logicalType(\"decimal\")",
"The logical type \"decimal\" requires the underlying type \"bytes\" or \"fixed\""),
Highlight.error("8", "@scale must contain a non-negative number of at most the value of @precision"),
+ // 31
Highlight.error("@logicalType(\"decimal\")",
"The logical type \"decimal\" requires the underlying type \"bytes\" or \"fixed\""),
+ // Swap these two when using 2024.3
Highlight.error("@logicalType(\"decimal\")",
"The logical type \"decimal\" requires the underlying type \"bytes\" or \"fixed\""),
Highlight.error("@logicalType(\"decimal\")",
@@ -481,21 +477,6 @@ public void testMissingErrorQuickFix() {
myFixture.checkResultByFile("MissingErrorFixed.avdl");
}
- @SuppressWarnings("unused")
- public void _testDocumentation() {
- myFixture.configureByFiles("DocumentationTestData.java", "DocumentationTestData.simple");
- final PsiElement originalElement = myFixture.getElementAtCaret();
- Editor editor = myFixture.getEditor();
- PsiElement element = DOCUMENTATION_PROVIDER.getCustomDocumentationElement(editor, originalElement.getContainingFile(), originalElement, editor.getCaretModel().getOffset());
- if (element == null) {
- element = originalElement;
- }
-
- final String generateDoc = DOCUMENTATION_PROVIDER.generateDoc(element, originalElement);
- assertNotNull(generateDoc);
- assertSameLinesWithFile(getTestDataPath() + "/" + "DocumentationTest.html.expected", generateDoc);
- }
-
@SuppressWarnings("SameParameterValue")
private record Highlight(HighlightSeverity severity, String text, String description) {
static Highlight error(String text, String description) {
diff --git a/src/test/java/opwvhk/intellij/avro_idl/actions/AvroIdlActionsTest.java b/src/test/java/opwvhk/intellij/avro_idl/actions/AvroIdlActionsTest.java
index ea86ac0..893bd2c 100644
--- a/src/test/java/opwvhk/intellij/avro_idl/actions/AvroIdlActionsTest.java
+++ b/src/test/java/opwvhk/intellij/avro_idl/actions/AvroIdlActionsTest.java
@@ -1,11 +1,12 @@
package opwvhk.intellij.avro_idl.actions;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.ex.ActionUtil;
+import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWrapper;
import com.intellij.testFramework.HeavyPlatformTestCase;
-import com.intellij.testFramework.MapDataContext;
import com.intellij.testFramework.TestActionEvent;
import java.io.IOException;
@@ -61,6 +62,7 @@ public void testNoFiles() throws IOException {
public void testNoSuitableFiles() throws IOException {
AnAction action = ActionManager.getInstance().getAction("AvroIdl.IdlToProtocol");
+
executeTest(action, false);
}
@@ -85,19 +87,20 @@ public void testSchemaToIdl() throws IOException {
}
private void executeTest(AnAction action, boolean shouldExecute) throws IOException {
- MapDataContext dataContext = new MapDataContext();
LocalFileSystem vfs = LocalFileSystem.getInstance();
- dataContext.put(LangDataKeys.VIRTUAL_FILE_ARRAY,
- list(inputDirectory, s -> s.map(vfs::refreshAndFindFileByNioFile).toArray(VirtualFile[]::new)));
- dataContext.put(CommonDataKeys.PROJECT, getProject());
+ DataContext dataContext = SimpleDataContext.builder()
+ .add(LangDataKeys.VIRTUAL_FILE_ARRAY,
+ list(inputDirectory, s -> s.map(vfs::refreshAndFindFileByNioFile).toArray(VirtualFile[]::new)))
+ .add(CommonDataKeys.PROJECT, getProject())
+ .build();
AnActionEvent event = TestActionEvent.createTestEvent(action, dataContext);
- action.update(event);
+ ActionUtil.performDumbAwareUpdate(action, event, false);
Presentation p = event.getPresentation();
assertThat(p.isEnabled()).as("event %s", p.isEnabled() ? "enabled" : "disabled").isEqualTo(shouldExecute);
assertThat(p.isVisible()).as("event %s", p.isVisible() ? "visible" : "hidden").isEqualTo(shouldExecute);
- action.actionPerformed(event); // Outside if statement to verify it correctly handles null invocations
+ ActionUtil.performActionDumbAwareWithCallbacks(action, event);
if (shouldExecute) {
assertSameTextContentRecursive(resultDirectory, outputDirectory);
} else {