From 68c62875bde090bda64ac26f842304edb01fb913 Mon Sep 17 00:00:00 2001
From: Tagir Valeev
Date: Wed, 2 Apr 2025 10:04:57 +0200
Subject: [PATCH] [mod-commands] Improve create directory preview (IJPL-181933)
GitOrigin-RevId: e3c3a581dc2c417ba8d5a8aa63ec97b46bbf8bb4
---
.../com/intellij/modcommand/ModCommandTest.java | 2 +-
.../impl/modcommand/ModCommandBatchExecutorImpl.java | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/java/java-tests/testSrc/com/intellij/modcommand/ModCommandTest.java b/java/java-tests/testSrc/com/intellij/modcommand/ModCommandTest.java
index 303288596d96..1ee1d1e1a1ef 100644
--- a/java/java-tests/testSrc/com/intellij/modcommand/ModCommandTest.java
+++ b/java/java-tests/testSrc/com/intellij/modcommand/ModCommandTest.java
@@ -81,6 +81,6 @@ public final class ModCommandTest extends LightPlatformCodeInsightTestCase {
IntentionPreviewInfo preview = ModCommandExecutor.getInstance().getPreview(command, ActionContext.from(null, getFile()));
IntentionPreviewInfo.Html html = assertInstanceOf(preview, IntentionPreviewInfo.Html.class);
String actual = html.content().toString();
- assertEquals("Create directories:
", actual);
+ assertEquals("Create directories:
• a
• a/b
• a/c
", actual);
}
}
diff --git a/platform/analysis-impl/src/com/intellij/lang/impl/modcommand/ModCommandBatchExecutorImpl.java b/platform/analysis-impl/src/com/intellij/lang/impl/modcommand/ModCommandBatchExecutorImpl.java
index a7ca260f1291..cdcd218668de 100644
--- a/platform/analysis-impl/src/com/intellij/lang/impl/modcommand/ModCommandBatchExecutorImpl.java
+++ b/platform/analysis-impl/src/com/intellij/lang/impl/modcommand/ModCommandBatchExecutorImpl.java
@@ -377,8 +377,11 @@ public class ModCommandBatchExecutorImpl implements ModCommandExecutor {
return new IntentionPreviewInfo.Html(text(AnalysisBundle.message("preview.create.directory", createdDirs.get(0))));
}
return new IntentionPreviewInfo.Html(
- tag("p").addText(AnalysisBundle.message("preview.create.directories"))
- .child(tag("ul").children(ContainerUtil.map(createdDirs, text -> tag("li").addText(text))))
+ tag("p").addText(AnalysisBundle.message("preview.create.directories")).children(
+ ContainerUtil.map(createdDirs, text -> new HtmlBuilder().br()
+ .appendRaw("• ") //NON-NLS
+ .append(text)
+ .toFragment()))
);
}
return navigateInfo;
@@ -463,6 +466,9 @@ public class ModCommandBatchExecutorImpl implements ModCommandExecutor {
//noinspection unchecked
return IntentionPreviewInfo.addListOption((List)list, optList.label().label(), value -> !oldList.contains(value)).content();
}
+ if (newValue == null) {
+ throw new IllegalStateException("Null value is not supported");
+ }
throw new IllegalStateException("Value of type " + newValue.getClass() + " is not supported");
}