|
From: <caw...@us...> - 2007-08-23 18:18:32
|
Revision: 3059
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3059&view=rev
Author: cawilliams
Date: 2007-08-23 11:18:29 -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
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java 2007-08-23 18:18:22 UTC (rev 3058)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RdtDebugCorePlugin.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -97,4 +97,8 @@
public static boolean isRubyDebuggerVerbose() {
return isRubyDebuggerVerbose;
}
+
+ public static String getPluginIdentifier() {
+ return PLUGIN_ID;
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 18:18:22 UTC (rev 3058)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -13,8 +13,10 @@
import org.rubypeople.rdt.internal.debug.core.commands.ClassicDebuggerConnection;
import org.rubypeople.rdt.internal.debug.core.commands.GenericCommand;
import org.rubypeople.rdt.internal.debug.core.commands.RubyDebugConnection;
+import org.rubypeople.rdt.internal.debug.core.model.IEvaluationResult;
import org.rubypeople.rdt.internal.debug.core.model.IRubyDebugTarget;
import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyEvaluationResult;
import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
@@ -224,13 +226,15 @@
}
public RubyVariable readInspectExpression(RubyStackFrame frame, String expression) throws RubyProcessingException {
- try {
- expression = expression.replaceAll("\n", "\\\\n");
+ try {
+ expression = expression.replaceAll("\\n", "\\\\n");
+ RubyEvaluationResult result = new RubyEvaluationResult(expression, frame.getThread());
this.println(commandFactory.createInspect(frame, expression));
RubyVariable[] variables = new VariableReader(getMultiReaderStrategy()).readVariables(frame);
if (variables.length == 0) {
return null;
} else {
+ result.setValue(variables[0].getValue());
return variables[0];
}
} catch (IOException ioex) {
@@ -238,6 +242,23 @@
throw new RuntimeException(ioex.getMessage());
}
}
+
+ public IEvaluationResult evaluate(RubyStackFrame frame, String expression) throws RubyProcessingException {
+ expression = expression.replaceAll("\\n", "\\\\n");
+ RubyEvaluationResult result = new RubyEvaluationResult(expression, frame.getThread());
+ try {
+ this.println(commandFactory.createInspect(frame, expression));
+ RubyVariable[] variables = new VariableReader(getMultiReaderStrategy()).readVariables(frame);
+ if (variables.length > 0) {
+ result.setValue(variables[0].getValue());
+ }
+ } catch (IOException ioex) {
+ // TODO Set DebugException
+ ioex.printStackTrace();
+ throw new RuntimeException(ioex.getMessage());
+ }
+ return result;
+ }
public void sendStepOverEnd(RubyStackFrame stackFrame) {
try {
Added: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.core.model;
+
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+
+/**
+ * The result of an evaluation. An evaluation result may
+ * contain problems and/or a result value.
+ * <p>
+ * Clients are not intended to implement this interface.
+ * </p>
+ * @see IRubyValue
+ * @since 2.0
+ */
+
+public interface IEvaluationResult {
+
+ /**
+ * Returns the value representing the result of the
+ * evaluation, or <code>null</code> if the
+ * associated evaluation failed. If
+ * the associated evaluation failed, there will
+ * be problems, or an exception in this result.
+ *
+ * @return the resulting value, possibly
+ * <code>null</code>
+ */
+ public IValue getValue();
+
+ /**
+ * Returns whether the evaluation had any problems
+ * or if an exception occurred while performing the
+ * evaluation.
+ *
+ * @return whether there were any problems.
+ * @see #getErrors()
+ * @see #getException()
+ */
+ public boolean hasErrors();
+
+ /**
+ * Returns an array of problem messages. Each message describes a problem that
+ * occurred while compiling the snippet.
+ *
+ * @return compilation error messages, or an empty array if no errors occurred
+ * @since 2.1
+ */
+ public String[] getErrorMessages();
+
+ /**
+ * Returns the snippet that was evaluated.
+ *
+ * @return The string code snippet.
+ */
+ public String getSnippet();
+
+ /**
+ * Returns any exception that occurred while performing the evaluation
+ * or <code>null</code> if an exception did not occur.
+ * The exception will be a debug exception or a debug exception
+ * that wrappers a JDI exception that indicates a problem communicating
+ * with the target or with actually performing some action in the target.
+ *
+ * @return The exception that occurred during the evaluation
+ * @see com.sun.jdi.InvocationException
+ * @see org.eclipse.debug.core.DebugException
+ */
+ public DebugException getException();
+
+ /**
+ * Returns the thread in which the evaluation was performed.
+ *
+ * @return the thread in which the evaluation was performed
+ */
+ public IThread getThread();
+}
Property changes on: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IEvaluationResult.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.java 2007-08-23 18:18:29 UTC (rev 3059)
@@ -0,0 +1,52 @@
+package org.rubypeople.rdt.internal.debug.core.model;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+
+public class RubyEvaluationResult implements IEvaluationResult {
+
+ private String fSnippet;
+ private IThread fThread;
+ private IValue fValue;
+ private DebugException debugException;
+
+ public RubyEvaluationResult(String expression, IThread thread) {
+ this.fSnippet = expression;
+ this.fThread = thread;
+ }
+
+ public String[] getErrorMessages() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DebugException getException() {
+ return debugException;
+ }
+
+ public void setException(DebugException e) {
+ this.debugException = e;
+ }
+
+ public String getSnippet() {
+ return fSnippet;
+ }
+
+ public IThread getThread() {
+ return fThread;
+ }
+
+ public IValue getValue() {
+ return fValue;
+ }
+
+ public void setValue(IValue value) {
+ this.fValue = value;
+ }
+
+ public boolean hasErrors() {
+ return false;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyEvaluationResult.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.
|