How to get "Watches" ContentImpl without anActionEvent.getData?
here is my code https://github.com/roroco/ro-idea/blob/get-watch-wio-event-getData/src/main/groovy/ro/idea/ToggleConsoleContent.groovy
this action will toggle between "Debug Console > Console" and "Debug Console > Debugger > Watches", but the question is when debug console hide and I use
e.getData(PlatformDataKeys.NONEMPTY_CONTENT_MANAGER)
it return null, i can't get the contentManager contains "Watches", so is there any way to get "Watches" ContentImpl when debug console invisible?
请先登录再写评论。
Hi, try using another approach:
get your XDebugSession, then find watches content
then you can select it right there using
I find XDebugSession is not good idea since when debug stop, i cannot get session, here is my solution
Runnable callback = getSelectedDescriptor("Debug").activationCallback
XDebugSessionTab t;
for (Field f : callback.class.declaredFields) {
f.setAccessible(true)
def r = f.get(callback)
if (r instanceof XDebugSessionTab) {
t = r
break
}
}
act.cm = t.ui.contentManager
public RunContentDescriptor getSelectedDescriptor(String twn) {
ToolWindow console = twm.getToolWindow(twn)
if (console) {
Content ctn = console.contentManager.selectedContent
RunContentDescriptor selectedDescriptor
for (d in getDescriptors(twn)) {
if (d.executionId == ctn.executionId) {
selectedDescriptor = d
break
}
}
selectedDescriptor
}
}
Fine if it works :) Also
may give you the XDebugSessionTab more quickly (if it is opened).
Once you have it, you can getUI and do find/select Content as before