[mod-commands] Improve create directory preview (IJPL-181933)

GitOrigin-RevId: e3c3a581dc2c417ba8d5a8aa63ec97b46bbf8bb4
This commit is contained in:
Tagir Valeev
2025-04-02 17:24:07 +00:00
committed by intellij-monorepo-bot
parent 7d57941ece
commit 68c62875bd
2 changed files with 9 additions and 3 deletions
@@ -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("<p>Create directories:<ul><li>a</li><li>a/b</li><li>a/c</li></ul></p>", actual);
assertEquals("<p>Create directories:<br/>&bull; a<br/>&bull; a/b<br/>&bull; a/c</p>", actual);
}
}
@@ -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("&bull; ") //NON-NLS
.append(text)
.toFragment()))
);
}
return navigateInfo;
@@ -463,6 +466,9 @@ public class ModCommandBatchExecutorImpl implements ModCommandExecutor {
//noinspection unchecked
return IntentionPreviewInfo.addListOption((List<String>)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");
}