Jump to: navigation, search

Difference between revisions of "EDT:Debug Extensibility"

Line 7: Line 7:
 
== Variable adapters  ==
 
== Variable adapters  ==
  
If you wish to control how a Java variable is displayed in the Variables view, you will need to contribute a variable adapter to the EDT Java debug framework. This is done with Eclipse extension points. In your plug-in's manifest editor, add an extension for '''org.eclipse.edt.debug.core.variableAdapters'''. A reference implementation can be found in '''org.eclipse.edt.debug.core''''s '''plugin.xml''' file (see the corresponding class '''org.eclipse.edt.debug.internal.core.java.variables.EDTVariableAdapter''').<br>  
+
If you wish to control how a Java variable is displayed in the Variables view, you will need to contribute a variable adapter to the EDT Java debug framework. This is done with Eclipse extension points. In your plug-in's manifest editor, add an extension for '''org.eclipse.edt.debug.core.javaVariableAdapters'''. A reference implementation can be found in '''org.eclipse.edt.debug.core''''s '''plugin.xml''' file (see the corresponding class '''org.eclipse.edt.debug.internal.core.java.variables.EDTVariableAdapter''').<br>  
  
Your contributed class will need to implement '''org.eclipse.edt.debug.core.java.IVariableAdapter'''. Take a look at its source, as well as other relevant classes &amp; interfaces, for Javadocs.  
+
Your contributed class will need to implement '''org.eclipse.edt.debug.core.java.variables.IVariableAdapter'''. Take a look at its source, as well as other relevant classes &amp; interfaces, for Javadocs.  
  
The basic idea behind a variable adapter is, given a Java variable (IJavaVariable), you first determine if it's a type you wish to adapt. If so, you then must return an IEGLJavaVariable that will correctly structure the Java variable. If the Java variable is not a type to be handled by your adapter, simply return null and the next registered adapter will be given a chance to adapt it. '''Note: first adapter to return a non-null variable wins, and order is not guaranteed!'''  
+
The basic idea behind a variable adapter is, given a Java variable (IJavaVariable), you first determine if it's a type you wish to adapt. If so, you then must return an '''IEGLJavaVariable''' that will correctly structure the Java variable. If the Java variable is not a type to be handled by your adapter, simply return null and the next registered adapter will be given a chance to adapt it. '''Note: first adapter to return a non-null variable wins, and the order of adapters being consulted is not guaranteed!'''  
  
You may find several methods in '''org.eclipse.edt.debug.core.java.VariableUtil''' to be useful. For example, '''VariableUtil.isInstanceOf()''' can tell you if a Java variable is of a particular type.
+
You may find several methods in '''org.eclipse.edt.debug.core.java.variables.VariableUtil''' to be useful. For example, '''VariableUtil.isInstanceOf()''' can tell you if a Java variable is of a particular type.  
  
 
Since you're not working directly with the Java object instance, to execute any code on the variable you need to send messages to the separate Java process using API provided by Eclipse Java Development Tools (JDT). The format for the required information can be cumbersome and hard to determine, but '''VariableUtil.runSendMessage()''' should be used for all evaluations. Take a look at '''org.eclipse.edt.debug.internal.core.java.variables.MapVariable''' to see how a complex variable can be restructured.
 
Since you're not working directly with the Java object instance, to execute any code on the variable you need to send messages to the separate Java process using API provided by Eclipse Java Development Tools (JDT). The format for the required information can be cumbersome and hard to determine, but '''VariableUtil.runSendMessage()''' should be used for all evaluations. Take a look at '''org.eclipse.edt.debug.internal.core.java.variables.MapVariable''' to see how a complex variable can be restructured.

Revision as of 14:23, 22 February 2012

If you are extending the EGL language or Java generator, you may find you need to also extend the Java-based debugger to improve the user experience. For example if you are adding a new Java class to represent an EGL type in the generated application, it will probably not look very nice in the Variables view (by default it will be displayed in the Java way, which might not match how it should be represented to an EGL user).


This document will cover the ways in which the debugger can be extended.


Variable adapters

If you wish to control how a Java variable is displayed in the Variables view, you will need to contribute a variable adapter to the EDT Java debug framework. This is done with Eclipse extension points. In your plug-in's manifest editor, add an extension for org.eclipse.edt.debug.core.javaVariableAdapters. A reference implementation can be found in org.eclipse.edt.debug.core's plugin.xml file (see the corresponding class org.eclipse.edt.debug.internal.core.java.variables.EDTVariableAdapter).

Your contributed class will need to implement org.eclipse.edt.debug.core.java.variables.IVariableAdapter. Take a look at its source, as well as other relevant classes & interfaces, for Javadocs.

The basic idea behind a variable adapter is, given a Java variable (IJavaVariable), you first determine if it's a type you wish to adapt. If so, you then must return an IEGLJavaVariable that will correctly structure the Java variable. If the Java variable is not a type to be handled by your adapter, simply return null and the next registered adapter will be given a chance to adapt it. Note: first adapter to return a non-null variable wins, and the order of adapters being consulted is not guaranteed!

You may find several methods in org.eclipse.edt.debug.core.java.variables.VariableUtil to be useful. For example, VariableUtil.isInstanceOf() can tell you if a Java variable is of a particular type.

Since you're not working directly with the Java object instance, to execute any code on the variable you need to send messages to the separate Java process using API provided by Eclipse Java Development Tools (JDT). The format for the required information can be cumbersome and hard to determine, but VariableUtil.runSendMessage() should be used for all evaluations. Take a look at org.eclipse.edt.debug.internal.core.java.variables.MapVariable to see how a complex variable can be restructured.