|
From: <caw...@us...> - 2007-08-23 18:40:30
|
Revision: 3061
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3061&view=rev
Author: cawilliams
Date: 2007-08-23 11:40:25 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
first stab at implementing #4928 - add support for interacting at breakpoint.
Add Display view which allows users to type in Ruby code and execute/inspect the results
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,48 @@
+/**********************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.display;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DisplayMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.rubypeople.rdt.internal.debug.ui.display.DisplayMessages";//$NON-NLS-1$
+
+ public static String ClearDisplay_description;
+ public static String ClearDisplay_label;
+ public static String ClearDisplay_tooltip;
+
+ public static String DisplayView_Co_ntent_Assist_Ctrl_Space_1;
+ public static String DisplayView_Content_Assist_2;
+ public static String DisplayView_Copy_description;
+ public static String DisplayCompletionProcessor_0;
+ public static String DisplayCompletionProcessor_1;
+ public static String DisplayView_Copy_label;
+ public static String DisplayView_Copy_tooltip;
+ public static String DisplayView_Cut_description;
+ public static String DisplayView_Cut_label;
+ public static String DisplayView_Cut_tooltip;
+ public static String DisplayView_Paste_Description;
+ public static String DisplayView_Paste_label;
+ public static String DisplayView_Paste_tooltip;
+ public static String DisplayView_SelectAll_description;
+ public static String DisplayView_SelectAll_label;
+ public static String DisplayView_SelectAll_tooltip;
+
+ public static String find_replace_action_label;
+ public static String find_replace_action_tooltip;
+ public static String find_replace_action_image;
+ public static String find_replace_action_description;
+ public static String JavaInspectExpression_0;
+
+ static {
+ // load message values from bundle file
+ NLS.initializeMessages(BUNDLE_NAME, DisplayMessages.class);
+ }
+}
\ No newline at end of file
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,37 @@
+###############################################################################
+# Copyright (c) 2000, 2005 IBM Corporation 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+ClearDisplay_description=Clear the Display
+ClearDisplay_label=Clea&r
+ClearDisplay_tooltip=Clear Display
+
+DisplayView_Co_ntent_Assist_Ctrl_Space_1=Co&ntent Assist
+DisplayView_Content_Assist_2=Content Assist
+DisplayView_Copy_description=Copy
+DisplayCompletionProcessor_0=Unable to resolve selected stack frame
+DisplayCompletionProcessor_1=Unable to resolve enclosing type
+DisplayView_Copy_label=&Copy
+DisplayView_Copy_tooltip=Copy
+DisplayView_Cut_description=Cut
+DisplayView_Cut_label=Cu&t
+DisplayView_Cut_tooltip=Cut
+DisplayView_Paste_Description=Paste
+DisplayView_Paste_label=&Paste
+DisplayView_Paste_tooltip=Paste
+DisplayView_SelectAll_description=Select All
+DisplayView_SelectAll_label=Select &All
+DisplayView_SelectAll_tooltip=Select
+
+find_replace_action_label=&Find/Replace...
+find_replace_action_tooltip=Find/Replace
+find_replace_action_image=
+find_replace_action_description=Find/Replace
+JavaInspectExpression_0=An exception occurred: {0}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.display;
+
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.ui.texteditor.IUpdate;
+
+
+public class DisplayViewAction extends Action implements IUpdate {
+
+ /** The text operation code */
+ private int fOperationCode= -1;
+ /** The text operation target */
+ private ITextOperationTarget fOperationTarget;
+ /** The text operation target provider */
+ private IAdaptable fTargetProvider;
+
+
+ public DisplayViewAction(ITextOperationTarget target, int operationCode) {
+ super();
+ fOperationTarget= target;
+ fOperationCode= operationCode;
+ update();
+ }
+
+ public DisplayViewAction(IAdaptable targetProvider, int operationCode) {
+ super();
+ fTargetProvider= targetProvider;
+ fOperationCode= operationCode;
+ update();
+ }
+
+ /**
+ * The <code>TextOperationAction</code> implementation of this
+ * <code>IAction</code> method runs the operation with the current
+ * operation code.
+ */
+ public void run() {
+ if (fOperationCode != -1 && fOperationTarget != null)
+ fOperationTarget.doOperation(fOperationCode);
+ }
+
+ /**
+ * The <code>TextOperationAction</code> implementation of this
+ * <code>IUpdate</code> method discovers the operation through the current
+ * editor's <code>ITextOperationTarget</code> adapter, and sets the
+ * enabled state accordingly.
+ */
+ public void update() {
+ if (fOperationTarget == null && fTargetProvider != null && fOperationCode != -1){
+ fOperationTarget= (ITextOperationTarget) fTargetProvider.getAdapter(ITextOperationTarget.class);
+ }
+
+ boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
+ setEnabled(isEnabled);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.display;
+
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.text.RubySourceViewerConfiguration;
+
+/**
+ * The source viewer configuration for the Display view
+ */
+public class DisplayViewerConfiguration extends RubySourceViewerConfiguration {
+
+ public DisplayViewerConfiguration() {
+ super(RdtDebugUiPlugin.getDefault().getRubyTextTools().getColorManager(),
+ new ChainedPreferenceStore(new IPreferenceStore[] {
+ PreferenceConstants.getPreferenceStore(),
+ EditorsUI.getPreferenceStore()}),
+ null, null);
+ }
+
+ /**
+ * Returns the preference store this source viewer configuration is associated with.
+ *
+ * @return
+ */
+ public IPreferenceStore getTextPreferenceStore() {
+ return fPreferenceStore;
+ }
+
+ public IContentAssistProcessor getContentAssistantProcessor() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+
+ ContentAssistant assistant = new ContentAssistant();
+ assistant.setContentAssistProcessor(
+ getContentAssistantProcessor(),
+ IDocument.DEFAULT_CONTENT_TYPE);
+
+// JDIContentAssistPreference.configure(assistant, getColorManager());
+
+ assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
+ assistant.setInformationControlCreator(
+ getInformationControlCreator(sourceViewer));
+
+ return assistant;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDoubleClickStrategy(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+ */
+ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
+ ITextDoubleClickStrategy clickStrat = new ITextDoubleClickStrategy() {
+ // Highlight the whole line when double clicked. See Bug#45481
+ public void doubleClicked(ITextViewer viewer) {
+ try {
+ IDocument doc = viewer.getDocument();
+ int caretOffset = viewer.getSelectedRange().x;
+ int lineNum = doc.getLineOfOffset(caretOffset);
+ int start = doc.getLineOffset(lineNum);
+ int length = doc.getLineLength(lineNum);
+ viewer.setSelectedRange(start, length);
+ } catch (BadLocationException e) {
+ RdtDebugUiPlugin.log(e);
+ }
+ }
+ };
+ return clickStrat;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/DisplayViewerConfiguration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.debug.ui.display;
+
+
+public interface IDataDisplay {
+
+ /**
+ * Clears the content of this data display.
+ */
+ public void clear();
+
+ /**
+ * Displays the expression in the content of this data
+ * display.
+ */
+ public void displayExpression(String expression);
+
+ /**
+ * Displays the expression valur in the content of this data
+ * display.
+ */
+ public void displayExpressionValue(String value);
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/IDataDisplay.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java 2007-08-23 18:40:25 UTC (rev 3061)
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.display;
+
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugElement;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IErrorReportingExpression;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.core.model.IValue;
+import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
+
+/**
+ * An implementation of an expression produced from the
+ * inspect action. An inspect expression removes
+ * itself from the expression manager when its debug
+ * target terminates.
+ */
+public class RubyInspectExpression extends PlatformObject implements IErrorReportingExpression, IDebugEventSetListener {
+
+ /**
+ * The value of this expression
+ */
+ private IValue fValue;
+
+ /**
+ * The code snippet for this expression.
+ */
+ private String fExpression;
+
+ private IEvaluationResult fResult;
+
+ /**
+ * Constructs a new inspect result for the given
+ * expression and resulting value. Starts listening
+ * to debug events such that this element will remove
+ * itself from the expression manager when its debug
+ * target terminates.
+ *
+ * @param expression code snippet
+ * @param value value of the expression
+ */
+ public RubyInspectExpression(String expression, IValue value) {
+ fValue = value;
+ fExpression = expression;
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ }
+
+ /**
+ * Constructs a new inspect result for the given
+ * evaluation result, which provides a snippet, value,
+ * and error messages, if any.
+ *
+ * @param result the evaluation result
+ */
+ public RubyInspectExpression(IEvaluationResult result) {
+ this(result.getSnippet(), result.getValue());
+ fResult= result;
+ }
+
+ /**
+ * @see IExpression#getExpressionText()
+ */
+ public String getExpressionText() {
+ return fExpression;
+ }
+
+ /**
+ * @see IExpression#getValue()
+ */
+ public IValue getValue() {
+ return fValue;
+ }
+
+ /**
+ * @see IDebugElement#getDebugTarget()
+ */
+ public IDebugTarget getDebugTarget() {
+ IValue value= getValue();
+ if (value != null) {
+ return getValue().getDebugTarget();
+ }
+ if (fResult != null) {
+ return fResult.getThread().getDebugTarget();
+ }
+ // An expression should never be created with a null value *and*
+ // a null result.
+ return null;
+ }
+
+ /**
+ * @see IDebugElement#getModelIdentifier()
+ */
+ public String getModelIdentifier() {
+ return getDebugTarget().getModelIdentifier();
+ }
+
+ /**
+ * @see IDebugElement#getLaunch()
+ */
+ public ILaunch getLaunch() {
+ return getDebugTarget().getLaunch();
+ }
+
+ /**
+ * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ switch (event.getKind()) {
+ case DebugEvent.TERMINATE:
+ if (event.getSource().equals(getDebugTarget())) {
+ DebugPlugin.getDefault().getExpressionManager().removeExpression(this);
+ }
+ break;
+ case DebugEvent.SUSPEND:
+ if (event.getDetail() != DebugEvent.EVALUATION_IMPLICIT) {
+ if (event.getSource() instanceof IDebugElement) {
+ IDebugElement source = (IDebugElement) event.getSource();
+ if (source.getDebugTarget().equals(getDebugTarget())) {
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT)});
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * @see IExpression#dispose()
+ */
+ public void dispose() {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+
+ /**
+ * @see org.eclipse.debug.core.model.IErrorReportingExpression#hasErrors()
+ */
+ public boolean hasErrors() {
+ return fResult != null && fResult.hasErrors();
+ }
+
+ /**
+ * @see org.eclipse.debug.core.model.IErrorReportingExpression#getErrorMessages()
+ */
+ public String[] getErrorMessages() {
+ return getErrorMessages(fResult);
+ }
+
+ public static String[] getErrorMessages(IEvaluationResult result) {
+ if (result == null) {
+ return new String[0];
+ }
+ String messages[]= result.getErrorMessages();
+ if (messages.length > 0) {
+ return messages;
+ }
+ DebugException exception= result.getException();
+ if (exception != null ) {
+ return new String[] { exception.getMessage() };
+ }
+ return new String[0];
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/display/RubyInspectExpression.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|