mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-173562 "Log message to console" for emulated method breakpoints prints an empty line
This commit is contained in:
+9
-4
@@ -46,6 +46,7 @@ import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
|
||||
import com.intellij.xml.CommonXmlStrings;
|
||||
import com.sun.jdi.Location;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.request.BreakpointRequest;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -231,13 +232,17 @@ public abstract class BreakpointWithHighlighter<P extends JavaBreakpointProperti
|
||||
}
|
||||
}
|
||||
|
||||
static void createLocationBreakpointRequest(@NotNull FilteredRequestor requestor,
|
||||
@Nullable Location location,
|
||||
@NotNull DebugProcessImpl debugProcess) {
|
||||
@Nullable
|
||||
static BreakpointRequest createLocationBreakpointRequest(@NotNull FilteredRequestor requestor,
|
||||
@Nullable Location location,
|
||||
@NotNull DebugProcessImpl debugProcess) {
|
||||
if (location != null) {
|
||||
RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
|
||||
requestsManager.enableRequest(requestsManager.createBreakpointRequest(requestor, location));
|
||||
BreakpointRequest request = requestsManager.createBreakpointRequest(requestor, location);
|
||||
requestsManager.enableRequest(request);
|
||||
return request;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,10 +59,7 @@ import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.LocatableEvent;
|
||||
import com.sun.jdi.event.MethodEntryEvent;
|
||||
import com.sun.jdi.event.MethodExitEvent;
|
||||
import com.sun.jdi.request.ClassPrepareRequest;
|
||||
import com.sun.jdi.request.EventRequest;
|
||||
import com.sun.jdi.request.MethodEntryRequest;
|
||||
import com.sun.jdi.request.MethodExitRequest;
|
||||
import com.sun.jdi.request.*;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -86,6 +83,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
private boolean myIsStatic;
|
||||
|
||||
public static final @NonNls Key<MethodBreakpoint> CATEGORY = BreakpointCategory.lookup("method_breakpoints");
|
||||
private static final String METHOD_ENTRY_KEY = "METHOD_ENTRY_KEY";
|
||||
|
||||
protected MethodBreakpoint(@NotNull Project project, XBreakpoint breakpoint) {
|
||||
super(project, breakpoint);
|
||||
@@ -216,7 +214,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
}
|
||||
if (!ContainerUtil.isEmpty(allLineLocations)) {
|
||||
if (breakpoint.isWatchEntry()) {
|
||||
createLocationBreakpointRequest(breakpoint, ContainerUtil.getFirstItem(allLineLocations), debugProcess);
|
||||
createLocationBreakpointRequest(breakpoint, ContainerUtil.getFirstItem(allLineLocations), debugProcess, true);
|
||||
}
|
||||
if (breakpoint.isWatchExit()) {
|
||||
MethodBytecodeUtil.visit(method, new MethodVisitor(Opcodes.API_VERSION) {
|
||||
@@ -238,7 +236,7 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
//case Opcodes.ATHROW:
|
||||
allLineLocations.stream()
|
||||
.filter(l -> l.lineNumber() == myLastLine)
|
||||
.findFirst().ifPresent(location -> createLocationBreakpointRequest(breakpoint, location, debugProcess));
|
||||
.findFirst().ifPresent(location -> createLocationBreakpointRequest(breakpoint, location, debugProcess, false));
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
@@ -256,6 +254,16 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
}
|
||||
}
|
||||
|
||||
private static void createLocationBreakpointRequest(@NotNull FilteredRequestor requestor,
|
||||
@Nullable Location location,
|
||||
@NotNull DebugProcessImpl debugProcess,
|
||||
boolean methodEntry) {
|
||||
BreakpointRequest request = createLocationBreakpointRequest(requestor, location, debugProcess);
|
||||
if (request != null) {
|
||||
request.putProperty(METHOD_ENTRY_KEY, methodEntry);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createRequestForPreparedClass(@NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType classType) {
|
||||
if (isEmulated()) {
|
||||
createRequestForPreparedClassEmulated(this, debugProcess, classType, true);
|
||||
@@ -319,8 +327,22 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
|
||||
|
||||
public String getEventMessage(@NotNull LocatableEvent event) {
|
||||
final Location location = event.location();
|
||||
final String locationQName = DebuggerUtilsEx.getLocationMethodQName(location);
|
||||
Location location = event.location();
|
||||
if (event instanceof MethodEntryEvent) {
|
||||
return getEventMessage(true, ((MethodEntryEvent)event).method(), location);
|
||||
}
|
||||
if (event instanceof MethodExitEvent) {
|
||||
return getEventMessage(false, ((MethodExitEvent)event).method(), location);
|
||||
}
|
||||
Object entryProperty = event.request().getProperty(METHOD_ENTRY_KEY);
|
||||
if (entryProperty instanceof Boolean) {
|
||||
return getEventMessage((Boolean)entryProperty, location.method(), location);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getEventMessage(boolean entry, Method method, Location location) {
|
||||
String locationQName = DebuggerUtilsEx.getLocationMethodQName(location);
|
||||
String locationFileName;
|
||||
try {
|
||||
locationFileName = location.sourceName();
|
||||
@@ -328,30 +350,13 @@ public class MethodBreakpoint extends BreakpointWithHighlighter<JavaMethodBreakp
|
||||
catch (AbsentInformationException e) {
|
||||
locationFileName = getFileName();
|
||||
}
|
||||
final int locationLine = location.lineNumber();
|
||||
if (event instanceof MethodEntryEvent) {
|
||||
MethodEntryEvent entryEvent = (MethodEntryEvent)event;
|
||||
final Method method = entryEvent.method();
|
||||
return DebuggerBundle.message(
|
||||
"status.method.entry.breakpoint.reached",
|
||||
method.declaringType().name() + "." + method.name() + "()",
|
||||
locationQName,
|
||||
locationFileName,
|
||||
locationLine
|
||||
);
|
||||
}
|
||||
if (event instanceof MethodExitEvent) {
|
||||
MethodExitEvent exitEvent = (MethodExitEvent)event;
|
||||
final Method method = exitEvent.method();
|
||||
return DebuggerBundle.message(
|
||||
"status.method.exit.breakpoint.reached",
|
||||
method.declaringType().name() + "." + method.name() + "()",
|
||||
locationQName,
|
||||
locationFileName,
|
||||
locationLine
|
||||
);
|
||||
}
|
||||
return "";
|
||||
int locationLine = location.lineNumber();
|
||||
return DebuggerBundle.message(entry ? "status.method.entry.breakpoint.reached" : "status.method.exit.breakpoint.reached",
|
||||
method.declaringType().name() + "." + method.name() + "()",
|
||||
locationQName,
|
||||
locationFileName,
|
||||
locationLine
|
||||
);
|
||||
}
|
||||
|
||||
public PsiElement getEvaluationElement() {
|
||||
|
||||
Reference in New Issue
Block a user