mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-186951 Caller method filter - prepare caller key in advance
This commit is contained in:
@@ -10,6 +10,7 @@ import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.jdi.ThreadGroupReferenceProxyImpl;
|
||||
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
import com.intellij.debugger.memory.utils.StackFrameItem;
|
||||
import com.intellij.debugger.ui.breakpoints.BreakpointIntentionAction;
|
||||
import com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint;
|
||||
import com.intellij.debugger.ui.impl.watch.MethodsTracker;
|
||||
import com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl;
|
||||
@@ -23,6 +24,7 @@ import com.intellij.xdebugger.frame.XStackFrame;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
|
||||
import com.sun.jdi.Location;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ThreadReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -89,6 +91,14 @@ public class JavaExecutionStack extends XExecutionStack {
|
||||
@NotNull
|
||||
public XStackFrame createStackFrame(@NotNull StackFrameProxyImpl stackFrameProxy) {
|
||||
StackFrameDescriptorImpl descriptor = new StackFrameDescriptorImpl(stackFrameProxy, myTracker);
|
||||
|
||||
if (descriptor.getUiIndex() == 1 && myTopFrame instanceof JavaStackFrame) {
|
||||
Method method = descriptor.getMethod();
|
||||
if (method != null) {
|
||||
((JavaStackFrame)myTopFrame).getDescriptor().putUserData(BreakpointIntentionAction.CALLER_KEY, DebuggerUtilsEx.methodKey(method));
|
||||
}
|
||||
}
|
||||
|
||||
DebugProcessImpl debugProcess = (DebugProcessImpl)descriptor.getDebugProcess();
|
||||
Location location = descriptor.getLocation();
|
||||
if (location != null) {
|
||||
|
||||
+14
-34
@@ -3,13 +3,9 @@ package com.intellij.debugger.ui.breakpoints
|
||||
|
||||
import com.intellij.debugger.engine.JavaDebugProcess
|
||||
import com.intellij.debugger.engine.JavaStackFrame
|
||||
import com.intellij.debugger.engine.SuspendContextImpl
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException
|
||||
import com.intellij.debugger.engine.events.DebuggerContextCommandImpl
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx
|
||||
import com.intellij.debugger.impl.PrioritizedTask
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.ui.classFilter.ClassFilter
|
||||
@@ -94,6 +90,9 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val CALLER_KEY = Key.create<String>("CALLER_KEY")
|
||||
|
||||
@JvmStatic
|
||||
fun getIntentions(breakpoint: XBreakpoint<*>, currentSession: XDebugSession?): List<AnAction> {
|
||||
val process = currentSession?.debugProcess
|
||||
@@ -102,43 +101,24 @@ internal abstract class BreakpointIntentionAction(protected val myBreakpoint: XB
|
||||
|
||||
val currentStackFrame = currentSession.currentStackFrame
|
||||
if (currentStackFrame is JavaStackFrame) {
|
||||
currentStackFrame.descriptor.typeName?.let {
|
||||
val frameDescriptor = currentStackFrame.descriptor
|
||||
frameDescriptor.typeName?.let {
|
||||
res.add(AddClassFilter(breakpoint, it))
|
||||
res.add(AddClassNotFilter(breakpoint, it))
|
||||
}
|
||||
|
||||
currentStackFrame.descriptor.thisObject?.uniqueID()?.let {
|
||||
frameDescriptor.thisObject?.uniqueID()?.let {
|
||||
res.add(AddInstanceFilter(breakpoint, it))
|
||||
}
|
||||
|
||||
if (Registry.`is`("debugger.breakpoints.caller.filter")) {
|
||||
frameDescriptor.getUserData(CALLER_KEY)?.let {
|
||||
res.add(AddCallerFilter(breakpoint, it))
|
||||
res.add(AddCallerNotFilter(breakpoint, it))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Registry.`is`("debugger.breakpoints.caller.filter")) {
|
||||
val debugProcess = process.debuggerSession.process
|
||||
debugProcess.managerThread.invokeAndWait(object : DebuggerContextCommandImpl(debugProcess.debuggerContext) {
|
||||
|
||||
override fun getPriority() = PrioritizedTask.Priority.HIGH
|
||||
|
||||
override fun threadAction(suspendContext: SuspendContextImpl) {
|
||||
try {
|
||||
val thread = suspendContext.thread
|
||||
if (thread != null && thread.frameCount() > 1) {
|
||||
val parentFrame = thread.frame(1)
|
||||
if (parentFrame != null) {
|
||||
val method = DebuggerUtilsEx.getMethod(parentFrame.location())
|
||||
if (method != null) {
|
||||
val key = DebuggerUtilsEx.methodKey(parentFrame.location().method())
|
||||
res.add(AddCallerFilter(breakpoint, key))
|
||||
res.add(AddCallerNotFilter(breakpoint, key))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e: EvaluateException) {
|
||||
LineBreakpoint.LOG.warn(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
||||
return emptyList()
|
||||
|
||||
Reference in New Issue
Block a user