mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[debugger] show Java port and main class in the new attach-dialog, IJPL-210887
^IJPL-210887 fixed GitOrigin-RevId: 0ad2720dd65c4ee50dbea18e1732663844043c32
This commit is contained in:
committed by
intellij-monorepo-bot
parent
69bace9d1b
commit
fd718f2aae
@@ -117,6 +117,7 @@
|
||||
|
||||
<xdebugger.attachDebuggerProvider implementation="com.intellij.debugger.impl.attach.JavaAttachDebuggerProvider"/>
|
||||
<xdebugger.attachDebuggerProvider implementation="com.intellij.debugger.impl.attach.JavaSAAttachDebuggerProvider"/>
|
||||
<xdebugger.dialog.item.presentation.provider implementation="com.intellij.debugger.impl.attach.JavaAttachDialogItemPresentationProvider"/>
|
||||
|
||||
<consoleFilterProvider implementation="com.intellij.execution.impl.JavaDebuggerConsoleFilterProvider"/>
|
||||
<jvm.exceptionFilter implementation="com.intellij.debugger.impl.attach.JavaDebuggerAddExceptionBreakpointFilter"/>
|
||||
|
||||
+68
-5
@@ -24,9 +24,12 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.rt.execution.application.AppMainV2;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.execution.ParametersListUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.xdebugger.attach.*;
|
||||
import com.intellij.xdebugger.impl.ui.attach.dialog.AttachDialogProcessItem;
|
||||
import com.intellij.xdebugger.impl.ui.attach.dialog.extensions.XAttachDialogItemPresentationProvider;
|
||||
import com.jetbrains.sa.SaJdwp;
|
||||
import com.sun.tools.attach.AttachNotSupportedException;
|
||||
import com.sun.tools.attach.VirtualMachine;
|
||||
@@ -115,6 +118,10 @@ public class JavaAttachDebuggerProvider implements XAttachDebuggerProvider {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isJavaAttachDebugger(XAttachDebugger debugger) {
|
||||
return debugger instanceof JavaLocalAttachDebugger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull XAttachPresentationGroup<ProcessInfo> getPresentationGroup() {
|
||||
return ourAttachGroup;
|
||||
@@ -157,6 +164,10 @@ public class JavaAttachDebuggerProvider implements XAttachDebuggerProvider {
|
||||
return info instanceof DebuggerLocalAttachInfo;
|
||||
}
|
||||
|
||||
static @Nullable LocalAttachInfo getAttachInfo(@NotNull ProcessInfo info, @NotNull UserDataHolder dataHolder) {
|
||||
return getAttachInfo(null, info.getPid(), info.getCommandLine(), dataHolder.getUserData(ADDRESS_MAP_KEY));
|
||||
}
|
||||
|
||||
private static @Nullable LocalAttachInfo getAttachInfo(@Nullable Project project,
|
||||
int pid,
|
||||
String commandLine,
|
||||
@@ -357,8 +368,8 @@ public class JavaAttachDebuggerProvider implements XAttachDebuggerProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
String getProcessDisplayText(String text) {
|
||||
return text + " (" + myAddress + ")";
|
||||
@Nullable @NlsSafe String getAddress() {
|
||||
return myAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,9 +447,15 @@ public class JavaAttachDebuggerProvider implements XAttachDebuggerProvider {
|
||||
|
||||
abstract @NlsSafe String getDebuggerName();
|
||||
|
||||
@NlsSafe
|
||||
String getProcessDisplayText(String text) {
|
||||
return text;
|
||||
final @NlsSafe String getProcessDisplayText(String text) {
|
||||
var extra = getAddress();
|
||||
return StringUtil.isEmpty(extra)
|
||||
? text
|
||||
: text + " (" + extra + ")";
|
||||
}
|
||||
|
||||
@Nullable @NlsSafe String getAddress() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,3 +558,49 @@ public class JavaAttachDebuggerProvider implements XAttachDebuggerProvider {
|
||||
ProgramRunnerUtil.executeConfiguration(runSettings, JavaAttachDebuggerProvider.ProcessAttachDebugExecutor.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
class JavaAttachDialogItemPresentationProvider implements XAttachDialogItemPresentationProvider {
|
||||
|
||||
@Override
|
||||
public boolean isApplicableFor(@NotNull AttachDialogProcessItem item) {
|
||||
return ContainerUtil.exists(item.getDebuggers(), JavaAttachDebuggerProvider::isJavaAttachDebugger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
// Almost arbitrary number.
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nls @NotNull String getProcessExecutableText(@NotNull AttachDialogProcessItem item) {
|
||||
String executable = XAttachDialogItemPresentationProvider.super.getProcessExecutableText(item);
|
||||
|
||||
JavaAttachDebuggerProvider.LocalAttachInfo attachInfo = JavaAttachDebuggerProvider.getAttachInfo(item.getProcessInfo(), item.getDataHolder());
|
||||
if (attachInfo == null) return executable;
|
||||
|
||||
StringBuilder extra = new StringBuilder();
|
||||
if ("java".equals(executable)) {
|
||||
if (!StringUtil.isEmpty(attachInfo.myClass)) {
|
||||
extra.append(attachInfo.myClass);
|
||||
}
|
||||
else {
|
||||
var shouldBeClassName = ArrayUtil.getLastElement(item.getProcessInfo().getCommandLine().split(" "));
|
||||
if (!StringUtil.isEmpty(shouldBeClassName)) {
|
||||
extra.append(shouldBeClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
var address = attachInfo.getAddress();
|
||||
if (!StringUtil.isEmpty(address)) {
|
||||
if (!extra.isEmpty()) {
|
||||
extra.append(", ");
|
||||
}
|
||||
extra.append(address);
|
||||
}
|
||||
|
||||
return !extra.isEmpty()
|
||||
? executable + " (" + extra + ")"
|
||||
: executable;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user