--- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java Thu Nov 05 15:17:54 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java Tue Nov 10 09:58:50 2009 -0600
@@ -16,7 +16,6 @@
import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.jface.viewers.IStructuredSelection;
/**
* The text hovering support for C/C++ debugger.
@@ -30,17 +29,11 @@
* @return the evaluation stack frame, or <code>null</code> if none
*/
protected ICStackFrame getFrame() {
- if (fSelection instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) fSelection;
- if (selection.size() == 1) {
- Object el = selection.getFirstElement();
- if (el instanceof IAdaptable) {
- return (ICStackFrame) ((IAdaptable) el)
- .getAdapter(ICStackFrame.class);
- }
- }
- }
- return null;
+ IAdaptable adaptable = getSelectionAdaptable();
+ if (adaptable != null) {
+ return (ICStackFrame) adaptable.getAdapter(ICStackFrame.class);
+ }
+ return null;
}
@Override
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java Thu Nov 05 15:17:54 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java Tue Nov 10 09:58:50 2009 -0600
@@ -18,6 +18,7 @@
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.text.BadLocationException;
@@ -27,6 +28,7 @@
import org.eclipse.jface.text.ITextHoverExtension;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.ISelectionListener;
@@ -75,6 +77,8 @@
/**
* The text hovering support for C/C++ debugger.
+ *
+ * @since 6.1
*/
public abstract class AbstractDebugTextHover implements ICEditorTextHover, ITextHoverExtension,
@@ -82,9 +86,9 @@
static final private int MAX_HOVER_INFO_SIZE = 100;
- protected ISelection fSelection = null;
+ private ISelection fSelection = null;
- protected IEditorPart fEditor;
+ private IEditorPart fEditor;
protected abstract boolean canEvaluate();
@@ -226,6 +230,28 @@
return null;
}
+ protected ISelection getSelection() {
+ return fSelection;
+ }
+
+ protected IAdaptable getSelectionAdaptable() {
+ if (fSelection instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) fSelection;
+ if (selection.size() == 1) {
+ Object element = selection.getFirstElement();
+ if (element instanceof IAdaptable) {
+ return (IAdaptable) element;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ protected IEditorPart getEditor() {
+ return fEditor;
+ }
+
/**
* Replace any characters in the given String that would confuse an HTML parser with their escape sequences.
*/
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF Thu Nov 05 15:17:54 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF Tue Nov 10 09:58:50 2009 -0600
@@ -3,7 +3,7 @@
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb.ui;singleton:=true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
@@ -19,7 +19,10 @@
org.eclipse.ui.ide,
org.eclipse.core.variables,
org.eclipse.core.expressions,
- org.eclipse.ui.console
+ org.eclipse.ui.console,
+ org.eclipse.jface.text;bundle-version="3.4.0",
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.core.filesystem;bundle-version="1.2.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui.actions;x-internal:=true,
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/plugin.properties Thu Nov 05 15:17:54 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/plugin.properties Tue Nov 10 09:58:50 2009 -0600
@@ -44,3 +44,6 @@
launchTab.debugger.name=Debugger
launchTab.sourceLookup.name=Source
launchTab.common.name=Common
+
+editorTextHover.label=GDB Debugger
+editorTextHover.description=Shows formatted value in debugger hover
\ No newline at end of file
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/plugin.xml Thu Nov 05 15:17:54 2009 -0600
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/plugin.xml Tue Nov 10 09:58:50 2009 -0600
@@ -180,6 +180,16 @@
</renderingBindings>
</extension>
+ <extension
+ point="org.eclipse.cdt.ui.textHovers">
+ <hover
+ label="%editorTextHover.description"
+ description="%editorTextHover.description"
+ class="org.eclipse.cdt.dsf.gdb.internal.ui.GdbDebugTextHover"
+ id="org.eclipse.cdt.dsf.gdb.internal.ui.GdbDebugTextHover">
+ </hover>
+ </extension>
+
<extension point="org.eclipse.ui.propertyPages">
<page class="org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints.CBreakpointGdbThreadFilterPage"
id="org.eclipse.cdt.dsf.gdb.breakpoint.filtering"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java Tue Nov 10 09:58:50 2009 -0600
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.ui;
+
+import org.eclipse.cdt.dsf.debug.ui.AbstractDsfDebugTextHover;
+import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate;
+
+/**
+ * Debug editor text hover for GDB.
+ *
+ * @since 2.1
+ */
+public class GdbDebugTextHover extends AbstractDsfDebugTextHover {
+
+ @Override
+ protected String getModelId() {
+ return GdbLaunchDelegate.GDB_DEBUG_MODEL_ID;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java Tue Nov 10 09:58:50 2009 -0600
@@ -0,0 +1,131 @@
+/**
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package org.eclipse.cdt.dsf.debug.ui;
+
+import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.Query;
+import org.eclipse.cdt.dsf.debug.service.IExpressions;
+import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
+import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
+import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
+import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
+import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.model.IDebugModelProvider;
+
+/**
+ * An implementation of AbstractDebugTextHover using DSF services.
+ *
+ * @since 2.1
+ */
+abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover {
+
+ /**
+ * Returns the debug model ID of that this debug text hover is to be used for.
+ */
+ abstract protected String getModelId();
+
+ private static class GetExpressionValueQuery extends Query<FormattedValueDMData> {
+ private final IFrameDMContext frame;
+ private final String expression;
+ private DsfServicesTracker dsfServicesTracker;
+
+ public GetExpressionValueQuery(IFrameDMContext frame, String expression, DsfServicesTracker dsfServicesTracker) {
+ this.frame = frame;
+ this.expression = expression;
+ this.dsfServicesTracker = dsfServicesTracker;
+ }
+
+ @Override
+ protected void execute(final DataRequestMonitor<FormattedValueDMData> rm) {
+ DsfSession session = DsfSession.getSession(frame.getSessionId());
+ IExpressions expressions = dsfServicesTracker.getService(IExpressions.class);
+ IExpressionDMContext expressionDMC = expressions.createExpression(frame, expression);
+ FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, IFormattedValues.NATURAL_FORMAT);
+ expressions.getFormattedExpressionValue(formattedValueContext,
+ new DataRequestMonitor<FormattedValueDMData>(session.getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ rm.setData(getData());
+ rm.done();
+ }
+
+ @Override
+ protected void handleFailure() {
+ rm.done();
+ }
+ });
+ }
+ }
+
+ protected IFrameDMContext getFrame() {
+ IAdaptable adaptable = getSelectionAdaptable();
+ if (adaptable != null) {
+ return (IFrameDMContext) adaptable.getAdapter(IFrameDMContext.class);
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean canEvaluate() {
+ if (getFrame() == null) {
+ return false;
+ }
+
+ IAdaptable adaptable = getSelectionAdaptable();
+ if (adaptable != null) {
+ IDebugModelProvider modelProvider = (IDebugModelProvider)adaptable.getAdapter(IDebugModelProvider.class);
+ if (modelProvider != null) {
+ String[] models = modelProvider.getModelIdentifiers();
+ String myModel = getModelId();
+ for (int i = 0; i < models.length; i++) {
+ if (models[i].equals(myModel)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected String evaluateExpression(String expression) {
+ IFrameDMContext frame = getFrame();
+ String sessionId = frame.getSessionId();
+ DsfServicesTracker dsfServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), sessionId);
+ try {
+ GetExpressionValueQuery query = new GetExpressionValueQuery(frame, expression, dsfServicesTracker);
+ DsfSession session = DsfSession.getSession(sessionId);
+ session.getExecutor().execute(query);
+ try {
+ FormattedValueDMData data = query.get();
+ if (data != null)
+ return data.getFormattedValue();
+ } catch (Exception e) {
+ }
+ } finally {
+ dsfServicesTracker.dispose();
+ }
+ return null;
+ }
+
+}
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/DebugTextHover.java Thu Nov 05 15:17:54 2009 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/**
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
-
-package org.eclipse.cdt.dsf.debug.ui;
-
-import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
-import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
-import org.eclipse.cdt.dsf.concurrent.Query;
-import org.eclipse.cdt.dsf.debug.service.IExpressions;
-import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
-import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
-import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
-import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
-import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
-import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
-import org.eclipse.cdt.dsf.service.DsfServicesTracker;
-import org.eclipse.cdt.dsf.service.DsfSession;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-/**
- * An implementation of AbstractDebugTextHover using DSF services
- */
-public class DebugTextHover extends AbstractDebugTextHover {
-
- public class GetExpressionValueQuery extends Query<FormattedValueDMData> {
- private final IFrameDMContext frame;
- private final String expression;
- private DsfServicesTracker dsfServicesTracker;
-
- public GetExpressionValueQuery(IFrameDMContext frame, String expression, DsfServicesTracker dsfServicesTracker) {
- this.frame = frame;
- this.expression = expression;
- this.dsfServicesTracker = dsfServicesTracker;
- }
-
- @Override
- protected void execute(final DataRequestMonitor<FormattedValueDMData> rm) {
- DsfSession session = DsfSession.getSession(frame.getSessionId());
- IExpressions expressions = dsfServicesTracker.getService(IExpressions.class);
- IExpressionDMContext expressionDMC = expressions.createExpression(frame, expression);
- FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, IFormattedValues.NATURAL_FORMAT);
- expressions.getFormattedExpressionValue(formattedValueContext,
- new DataRequestMonitor<FormattedValueDMData>(session.getExecutor(), rm) {
- @Override
- protected void handleSuccess() {
- rm.setData(getData());
- rm.done();
- }
-
- @Override
- protected void handleFailure() {
- rm.done();
- }
- });
- }
- }
-
- protected IFrameDMContext getFrame() {
- if (fSelection instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) fSelection;
- if (selection.size() == 1) {
- Object element = selection.getFirstElement();
- if (element instanceof IAdaptable) {
- return (IFrameDMContext) ((IAdaptable) element).getAdapter(IFrameDMContext.class);
- }
- }
- }
- return null;
- }
-
- @Override
- protected boolean canEvaluate() {
- return getFrame() != null;
- }
-
- @Override
- protected String evaluateExpression(String expression) {
- IFrameDMContext frame = getFrame();
- String sessionId = frame.getSessionId();
- DsfServicesTracker dsfServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), sessionId);
- GetExpressionValueQuery query = new GetExpressionValueQuery(frame, expression, dsfServicesTracker);
- DsfSession session = DsfSession.getSession(sessionId);
- session.getExecutor().execute(query);
- try {
- FormattedValueDMData data = query.get();
- if (data != null)
- return data.getFormattedValue();
- } catch (Exception e) {
- }
- return null;
- }
-
-}