mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
[OC-23442] fix move multiple psi preview html
GitOrigin-RevId: 57e19c65b66cc7fdb52f13b5b07405f81ba2b38c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e288f74d8e
commit
43a43dfadd
@@ -1 +1 @@
|
||||
<p><icon src="source"/> doSmth → <icon src="target"/> beforeAbstractMethodNoClass</p>
|
||||
<p><icon src="source_doSmth"/> doSmth → <icon src="target_beforeAbstractMethodNoClass"/> beforeAbstractMethodNoClass</p>
|
||||
@@ -231,7 +231,7 @@ public class IntentionPreviewTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
myFixture.configureByText("Test.java", "public class Test {} void <caret>method() {}");
|
||||
IntentionAction action = myFixture.findSingleIntention("Move member into class");
|
||||
myFixture.checkIntentionPreviewHtml(action,
|
||||
"<p><icon src=\"source\"/> method → <icon src=\"target\"/> Test</p>");
|
||||
"<p><icon src=\"source_method\"/> method → <icon src=\"target_Test\"/> Test</p>");
|
||||
}
|
||||
|
||||
public void testNavigate() {
|
||||
|
||||
@@ -269,25 +269,42 @@ public interface IntentionPreviewInfo {
|
||||
|
||||
HtmlBuilder builder = new HtmlBuilder();
|
||||
|
||||
sources.forEach((source) -> {
|
||||
Icon sourceIcon = source.getIcon(0);
|
||||
if (sourceIcon instanceof DeferredIcon) {
|
||||
sourceIcon = ((DeferredIcon)sourceIcon).evaluate();
|
||||
}
|
||||
Icon targetIcon = target.getIcon(0);
|
||||
if (targetIcon instanceof DeferredIcon) {
|
||||
targetIcon = ((DeferredIcon)targetIcon).evaluate();
|
||||
}
|
||||
if (sources.isEmpty()) return new Html(builder.wrapWith("p"));
|
||||
|
||||
var source = sources.get(0);
|
||||
Icon targetIcon = getIcon(target);
|
||||
Icon sourceIcon = getIcon(source);
|
||||
|
||||
builder.append(getHtmlMoveFragment(
|
||||
sourceIcon,
|
||||
targetIcon,
|
||||
source.getName(),
|
||||
explicitTargetName == null ? target.getName() : explicitTargetName));
|
||||
|
||||
for (int i = 1; i < sources.size(); i++) {
|
||||
source = sources.get(i);
|
||||
sourceIcon = getIcon(source);
|
||||
|
||||
builder
|
||||
.append(HtmlChunk.br())
|
||||
.append(getHtmlMoveFragment(
|
||||
sourceIcon,
|
||||
targetIcon,
|
||||
source.getName(),
|
||||
explicitTargetName == null ? target.getName() : explicitTargetName));
|
||||
}
|
||||
|
||||
builder.append(getHtmlMoveFragment(
|
||||
sourceIcon,
|
||||
targetIcon,
|
||||
source.getName(),
|
||||
explicitTargetName == null ? target.getName() : explicitTargetName));
|
||||
});
|
||||
return new Html(builder.wrapWith("p"));
|
||||
}
|
||||
|
||||
private static Icon getIcon(@NotNull PsiNamedElement source) {
|
||||
Icon icon = source.getIcon(0);
|
||||
if (icon instanceof DeferredIcon) {
|
||||
icon = ((DeferredIcon)icon).evaluate();
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static HtmlChunk getHtmlMoveFragment(@Nullable Icon sourceIcon,
|
||||
@Nullable Icon targetIcon,
|
||||
@@ -299,7 +316,6 @@ public interface IntentionPreviewInfo {
|
||||
.append(" ").append(HtmlChunk.htmlEntity("→")).append(" ")
|
||||
.append(getIconChunk(targetIcon, "target_" + targetName))
|
||||
.append(Objects.requireNonNull(targetName))
|
||||
.append(HtmlChunk.br())
|
||||
.toFragment();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user