* TImur debugger contributions applied.
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/plugin.xml b/core/plugins/org.eclipse.dltk.debug.ui/plugin.xml
index 4c7507c..db46021 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/plugin.xml
+++ b/core/plugins/org.eclipse.dltk.debug.ui/plugin.xml
@@ -6,6 +6,7 @@
<extension-point id="interpreterInstallTypePage"
name="%interpreterInstallTypePage"
schema="schema/interpreterInstallTypePage.exsd" />
+ <extension-point id="scriptDetailFormatter" name="scriptDetailFormatter" schema="schema/scriptDetailFormatter.exsd"/>
<!-- Extensions -->
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/schema/scriptDetailFormatter.exsd b/core/plugins/org.eclipse.dltk.debug.ui/schema/scriptDetailFormatter.exsd
new file mode 100644
index 0000000..6cb1669
--- /dev/null
+++ b/core/plugins/org.eclipse.dltk.debug.ui/schema/scriptDetailFormatter.exsd
@@ -0,0 +1,121 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.dltk.debug.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.dltk.debug.ui" id="scriptDetailFormatter" name="scriptDetailFormatter"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <element ref="detailFormatter" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="detailFormatter">
+ <annotation>
+ <appInfo>
+ <meta.element labelAttribute="type"/>
+ </appInfo>
+ </annotation>
+ <complexType>
+ <attribute name="type" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="nature" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="snippet" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java
index 83cba82..dfe4bb3 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptDebugModelPresentation.java
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IDebugElement;
@@ -42,6 +43,7 @@
import org.eclipse.dltk.debug.core.model.IScriptWatchpoint;
import org.eclipse.dltk.debug.ui.breakpoints.BreakpointUtils;
import org.eclipse.dltk.internal.debug.ui.ExternalFileEditorInput;
+import org.eclipse.dltk.internal.debug.ui.ScriptDetailFormattersManager;
import org.eclipse.dltk.internal.debug.ui.ScriptEvaluationContextManager;
import org.eclipse.dltk.internal.ui.editor.ExternalStorageEditorInput;
import org.eclipse.dltk.launching.DebuggingEngineRunner;
@@ -229,11 +231,11 @@
public String getVariableText(IScriptVariable variable) {
try {
String name = variable.getName();
-
- if (!variable.hasChildren()) {
- String value = variable.getValueString();
- if (value != null && value.length() > 0) {
- return name + " = " + value;
+ IScriptValue value = (IScriptValue) variable.getValue();
+ if (value != null) {
+ String valueText = getValueText(value);
+ if (valueText != null && valueText.length() > 0) {
+ return name + " = " + valueText;
}
}
@@ -245,6 +247,19 @@
return variable.toString();
}
+ protected String getValueText(IScriptValue value) {
+ try {
+ return value.getValueString();
+ } catch (DebugException e) {
+ DebugPlugin.log(e);
+ }
+ return value.toString();
+ }
+
+ protected String renderUnknownValue(IScriptValue value) throws DebugException {
+ return value.getValueString();
+ }
+
protected String getBreakpointText(IScriptBreakpoint breakpoint) {
try {
StringBuffer sb = new StringBuffer();
@@ -291,21 +306,17 @@
protected String getExpressionText(IExpression expression) {
final String expressionText = expression.getExpressionText();
- try {
- if (expression instanceof IErrorReportingExpression) {
- IErrorReportingExpression errorExpression = (IErrorReportingExpression) expression;
- if (errorExpression.hasErrors()) {
- return expressionText;
- }
+ if (expression instanceof IErrorReportingExpression) {
+ IErrorReportingExpression errorExpression = (IErrorReportingExpression) expression;
+ if (errorExpression.hasErrors()) {
+ return expressionText;
}
+ }
- IScriptValue value = (IScriptValue) expression.getValue();
- if (value != null) {
- return MessageFormat.format("{0} = {1}", new Object[] {
- expressionText, value.getValueString() });
- }
- } catch (DebugException e) {
- DLTKDebugUIPlugin.log(e);
+ IScriptValue value = (IScriptValue) expression.getValue();
+ if (value != null) {
+ return MessageFormat.format("{0} = {1}", new Object[] {
+ expressionText, getValueText(value) });
}
return expressionText;
@@ -322,6 +333,8 @@
return getStackFrameText((IScriptStackFrame) element);
} else if (element instanceof IScriptVariable) {
return getVariableText((IScriptVariable) element);
+ } else if (element instanceof IScriptValue) {
+ return getValueText((IScriptValue) element);
} else if (element instanceof IExpression) {
return getExpressionText((IExpression) element);
}
@@ -331,10 +344,13 @@
// Details
public void computeDetail(IValue value, IValueDetailListener listener) {
- try {
- listener.detailComputed(value, value.getValueString());
- } catch (DebugException e) {
- e.printStackTrace();
+ IScriptDebugTarget target = (IScriptDebugTarget)value.getDebugTarget();
+ IScriptThread thread = getEvaluationThread(target);
+ if (thread == null) {
+ listener.detailComputed(value, getValueText((IScriptValue) value));
+ } else {
+ String natureId = target.getLanguageToolkit().getNatureId();
+ ScriptDetailFormattersManager.getDefault(natureId).computeValueDetail((IScriptValue)value, thread, listener);
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java
index bd633ec..9e26136 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/ScriptWatchExpressionFilter.java
@@ -3,7 +3,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension;
-import org.eclipse.dltk.debug.core.model.IScriptVariable;
+import org.eclipse.dltk.debug.core.model.IScriptValue;
public class ScriptWatchExpressionFilter implements
IWatchExpressionFactoryAdapterExtension {
@@ -14,7 +14,7 @@
public String createWatchExpression(IVariable variable)
throws CoreException {
- IScriptVariable v = (IScriptVariable) variable;
+ IScriptValue v = (IScriptValue) variable.getValue();
return v.getEvalName();
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java
index 244beea..54bca87 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowClassVariablesActionDelegate.java
@@ -24,11 +24,8 @@
DebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS);
getPrefs().setValue(
DebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS, !value);
-
}
public void selectionChanged(IAction action, ISelection selection) {
- action.setChecked(getPrefs().getBoolean(
- DebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_CLASS));
}
}
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java
index df50576..844ac79 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/actions/ToggleShowGlobalVariablesActionDelegate.java
@@ -16,7 +16,6 @@
}
public void init(IViewPart view) {
-
}
public void run(IAction action) {
@@ -27,7 +26,5 @@
}
public void selectionChanged(IAction action, ISelection selection) {
- action.setChecked(!getPrefs().getBoolean(
- DebugPreferenceConstants.PREF_DBGP_SHOW_SCOPE_GLOBAL));
- }
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java
new file mode 100644
index 0000000..de8c904
--- /dev/null
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/DetailFormatter.java
@@ -0,0 +1,82 @@
+package org.eclipse.dltk.internal.debug.ui;
+
+/**
+ * Information about a detail formatter.
+ */
+public class DetailFormatter implements Comparable {
+
+ private boolean fEnabled;
+
+ private String fTypeName;
+
+ private String fSnippet;
+
+ public DetailFormatter(String typeName, String snippet, boolean enabled) {
+ fTypeName= typeName;
+ fSnippet= snippet;
+ fEnabled= enabled;
+ }
+
+ /**
+ * Indicate if this pretty should be used or not.
+ * @return boolean
+ */
+ public boolean isEnabled() {
+ return fEnabled;
+ }
+
+ /**
+ * Returns the code snippet.
+ * @return String
+ */
+ public String getSnippet() {
+ return fSnippet;
+ }
+
+ /**
+ * Returns the type name.
+ * @return String
+ */
+ public String getTypeName() {
+ return fTypeName;
+ }
+
+ /**
+ * Sets the enabled flag.
+ * @param enabled the new value of the flag
+ */
+ public void setEnabled(boolean enabled) {
+ fEnabled= enabled;
+ }
+
+ /**
+ * Sets the code snippet.
+ * @param snippet the snippet to set
+ */
+ public void setSnippet(String snippet) {
+ fSnippet= snippet;
+ }
+
+ /**
+ * Sets the type name.
+ * @param typeName the type name to set
+ */
+ public void setTypeName(String typeName) {
+ fTypeName= typeName;
+ }
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object another) {
+ DetailFormatter detailFormatter= (DetailFormatter)another;
+ if (fTypeName == null) {
+ if (detailFormatter.fTypeName == null) {
+ return 0;
+ }
+ return detailFormatter.fTypeName.compareTo(fTypeName);
+ }
+ return fTypeName.compareTo(detailFormatter.fTypeName);
+ }
+
+}
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java
index 428c7c0..a479d10 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDebugHover.java
@@ -104,7 +104,7 @@
IScriptEvaluationEngine engine = ((IScriptThread) frame
.getThread()).getEvaluationEngine();
IScriptEvaluationResult result = engine.syncEvaluate(
- snippet, null);
+ snippet, frame);
if (result != null) {
return getResultText(result);
@@ -192,18 +192,13 @@
protected String getResultText(IScriptEvaluationResult result)
throws DebugException {
- // TODO: make with string constnants and patterns
IScriptValue value = result.getValue();
-
- String str = value == null ? "Can't evaluate hover" : value
- .getValueString();
-
+ String str = getModelPresentation().getText(value);
return prepareHtml(result.getSnippet() + " = " + str);
}
protected String getVariableText(IVariable variable) throws DebugException {
- return prepareHtml(variable.getName() + " = "
- + variable.getValue().getValueString());
+ return prepareHtml(getModelPresentation().getText(variable));
}
protected String prepareHtml(String text) {
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java
new file mode 100644
index 0000000..836e468
--- /dev/null
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/internal/debug/ui/ScriptDetailFormattersManager.java
@@ -0,0 +1,139 @@
+package org.eclipse.dltk.internal.debug.ui;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.dltk.core.SimpleDLTKExtensionManager;
+import org.eclipse.dltk.core.SimpleDLTKExtensionManager.ElementInfo;
+import org.eclipse.dltk.debug.core.eval.IScriptEvaluationCommand;
+import org.eclipse.dltk.debug.core.eval.IScriptEvaluationListener;
+import org.eclipse.dltk.debug.core.eval.IScriptEvaluationResult;
+import org.eclipse.dltk.debug.core.model.IScriptThread;
+import org.eclipse.dltk.debug.core.model.IScriptValue;
+import org.eclipse.dltk.debug.ui.DLTKDebugUIPlugin;
+
+public class ScriptDetailFormattersManager {
+ private static final String DEFAULT_FORMATTER_TYPE = "#DEFAULT#";
+ private static final String ATTR_SNIPPET = "snippet";
+ private static final String ATTR_TYPE = "type";
+ private static final String ATTR_NATURE = "nature";
+ private static final String SCRIPT_DETAIL_FORMATTER_EXTENSION = DLTKDebugUIPlugin.PLUGIN_ID
+ + ".scriptDetailFormatter";
+
+ private static HashMap managerInstances = new HashMap();
+ private static final String CANNOT_EVALUATE = "Can't evaluate details.";
+ private HashMap formatters = new HashMap();
+ private DetailFormatter defaultFormatter = null;
+
+ /**
+ * Return the default detail formatters manager.
+ *
+ * @param natureId
+ *
+ * @return default detail formatters manager.
+ */
+ static public ScriptDetailFormattersManager getDefault(String natureId) {
+ ScriptDetailFormattersManager instance = (ScriptDetailFormattersManager) managerInstances
+ .get(natureId);
+ if (instance == null) {
+ instance = new ScriptDetailFormattersManager(natureId);
+ managerInstances.put(natureId, instance);
+ }
+ return instance;
+ }
+
+ public ScriptDetailFormattersManager(String natureId) {
+ populateDetailFormatters(natureId);
+ }
+
+ private void populateDetailFormatters(String natureId) {
+ SimpleDLTKExtensionManager manager = new SimpleDLTKExtensionManager(
+ SCRIPT_DETAIL_FORMATTER_EXTENSION);
+ ElementInfo[] infos = manager.getElementInfos();
+ for (int i = 0; i < infos.length; i++) {
+ IConfigurationElement config = infos[i].getConfig();
+ String nature = config.getAttribute(ATTR_NATURE);
+ if (natureId.equals(nature)) {
+ String code = config.getAttribute(ATTR_SNIPPET);
+ String type = config.getAttribute(ATTR_TYPE);
+ DetailFormatter formatter = new DetailFormatter(type, code,
+ true);
+ if (DEFAULT_FORMATTER_TYPE.equals(type)) {
+ setDefaultFormatter(formatter);
+ } else {
+ addFormatter(formatter);
+ }
+ }
+ }
+ }
+
+ private String getValueText(IValue value) {
+ try {
+ return value.getValueString();
+ } catch (DebugException e) {
+ return e.getMessage();
+ }
+ }
+
+ public void computeValueDetail(final IScriptValue value,
+ final IScriptThread thread, final IValueDetailListener listener) {
+ Runnable postEventDispatch = new Runnable() {
+ public void run() {
+ DetailFormatter formatter = getDetailFormatter(value);
+ if (thread == null || !thread.isSuspended()
+ || formatter == null || !formatter.isEnabled()) {
+ listener.detailComputed(value, getValueText(value));
+ } else {
+ final IScriptEvaluationCommand command = value
+ .createEvaluationCommand(formatter.getSnippet(),
+ thread);
+
+ command.asyncEvaluate(new IScriptEvaluationListener() {
+ public void evaluationComplete(
+ IScriptEvaluationResult result) {
+ if (result == null)
+ return;
+
+ IScriptValue resultValue = result.getValue();
+ if (resultValue != null) {
+ listener.detailComputed(value,
+ getValueText(resultValue));
+ } else {
+ listener.detailComputed(value, CANNOT_EVALUATE);
+ }
+ }
+ });
+ }
+ }
+ };
+ DebugPlugin.getDefault().asyncExec(postEventDispatch);
+ }
+
+ protected DetailFormatter getDetailFormatter(IScriptValue value) {
+ DetailFormatter formatter = (DetailFormatter) formatters.get(value
+ .getType().getName());
+ if (formatter == null)
+ formatter = getDefaultFormatter();
+ return formatter;
+ }
+
+ private DetailFormatter getDefaultFormatter() {
+ return defaultFormatter;
+ }
+
+ public void setDefaultFormatter(DetailFormatter formatter) {
+ defaultFormatter = formatter;
+ }
+
+ public void addFormatter(DetailFormatter formatter) {
+ formatters.put(formatter.getTypeName(), formatter);
+ }
+
+ public void removeFormatter(DetailFormatter formatter) {
+ formatters.remove(formatter.getTypeName());
+ }
+}