Questions about expression evaluator in custom debugger

Answered
I'm implementing a custom debugger and need to support expression evaluator in a number of custom languages.
I create and return a list of supported languages in the getSupportedLanguages() method of the editors provider but there are several issues:
  1. I see the drop-down populated with my languages, but in addition of it there’s also a language of the currently opened file displayed - how can I avoid it? I.e. if I have an XML file open, stop at the breakpoint and evaluate expression, I see XML displayed in the dropdown, but when I click on it, I see two languages that I return in the getSupportedLanguages. And the same problem is when I add a conditional breakpoint, I see this XML option there in addition to the languages that I support. What I need is to get rid of the XML language in the drop-down, I only need `datasonnet` and `simple`. 


  2. Is there any way to modify the expression evaluator UI to add some additional parameters I need to pass to the evaluator?

It would be great if anyone can point me to some examples or even give me some insight on how the existing expression evaluation in IntelliJ is implemented.

Thanks a lot in advance!

 

6 comments
Comment actions Permalink

Hi, unfortunately default language is taken from the current breakpoint file language, check https://github.com/JetBrains/intellij-community/blob/263520365a82f17cc68d38ee9cac1d9d6ae7e864/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebuggerEditorBase.java#L218 and LanguageChooser at the line 511

Default expression evaluator UI is not customizable at the moment https://github.com/JetBrains/intellij-community/blob/263520365a82f17cc68d38ee9cac1d9d6ae7e864/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/evaluate/XDebuggerEvaluationDialog.java#L44

but you can create your own dialog and evaluate action and reuse some components like XDebuggerTreePanel or EvaluationInputComponent

0
Comment actions Permalink

Thanks, Egor, so looks like I should start with overriding the Evaluate action, correct? What is the ID of the action and how can I override it?

 

0
Comment actions Permalink

I went as far as adding `<xdebugger.support ...` to my `plugin.xml`, and I created an override for the getEvaluateHandler() method:

@Override
@NotNull
public DebuggerActionHandler getEvaluateHandler() {
return evaluateActionHandler;
}

Then I created my own action handler, but from what I can tell, when I evaluate expression, this handler is never used, instead, the default handler is used instead. After some debugging I found that `DebuggerSupport.getDebuggerSupports()` returns a list of debugger supports and the one I created is not the first one in the list. The first one is XDebuggerSupport and as a result my code is never called.

So is there a way to disable the XDebuggerSupport?

0
Comment actions Permalink

The default action is

<action id="EvaluateExpression" class="com.intellij.xdebugger.impl.actions.EvaluateAction" icon="AllIcons.Debugger.EvaluateExpression"/>

it is easier to create your own action and place it on the debugger toolbar. In your own action there's no need to bother with DebuggerSupport, just call your own handler.

 

0
Comment actions Permalink

But then is it possible to unregister the default action or at least disable it when I'm in the context of debugging a certain project?

 

0
Comment actions Permalink

it is not recommended, for now it maybe easier to register your xdebuggersupport impl with order like this: order="before XDebuggerSupport"

0

Please sign in to leave a comment.