简体   繁体   中英

Eclipse: How do I enable Watch and Inspect action on my source code in my custom debugger?

I'm one of the developer of EclipseFP, which provides Haskell development plugins for Eclipse. It contains a debugger, so I've implemented the DebugTarget, the StackFrames, etc. Variables and expressions work in the debug perspective. However, the only way to add an expression is via the Add Watch Expression action in the Expressions view. I'd like to be able to right click inside my source code and select Watch, as I can in Java. I see the Watch action disabled in the run menu. What's the integration point to say "I want the watch action to work on my source code"? Thanks!

Maybe answering your own question is bad form, but I finally managed to achieve what I wanted...

After looking at the JDT code, there seems to be no explicit entry point. I've created normal editors actions, and the code to add a new expression in the debug expression view is:

  IWatchExpression expression= DebugPlugin.getDefault().getExpressionManager().newWatchExpression(snippet);
  DebugPlugin.getDefault().getExpressionManager().addExpression(expression);
  IAdaptable object = DebugUITools.getDebugContext();
  IDebugElement context= null;
  if (object instanceof IDebugElement) {
    context= (IDebugElement) object;
  } else if (object instanceof ILaunch) {
    context= ((ILaunch) object).getDebugTarget();
  }
  expression.setExpressionContext(context);

Following the JDT code's lead, I have a system property that my debug target sets when suspended, that in turn enables the "display" action that shows you the current value of the expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM