From 71d62cdd6ecd4d817ef639047a3753d14aae72bc Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Thu, 12 Sep 2002 18:10:03 +0000 Subject: [PATCH] Implementation of the 'Change Variable Value' action. --- .../cdt/debug/core/CDebugCorePlugin.java | 14 ++++++ .../internal/core/model/CDebugElement.java | 19 ++++++++ .../core/model/CModificationVariable.java | 47 +++++++------------ 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index c4f6ce9935e..c7146154d2b 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -116,6 +116,20 @@ public class CDebugCorePlugin extends Plugin getDefault().getLog().log( status ); } + /** + * Logs the specified message with this plug-in's log. + * + * @param status status to log + */ + public static void log( String message ) + { + getDefault().getLog().log( new Status( IStatus.ERROR, + CDebugModel.getPluginIdentifier(), + INTERNAL_ERROR, + message, + null ) ); + } + private void initializeDebugConfiguration() { IPluginDescriptor descriptor= getDefault().getDescriptor(); IExtensionPoint extensionPoint= descriptor.getExtensionPoint("CDebugger"); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java index 5dfdb209d72..c9a537d4fdd 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java @@ -79,6 +79,16 @@ public class CDebugElement extends PlatformObject logError( e ); } + /** + * Logs the given message. + * + * @param message the message + */ + public void internalError( String message ) + { + logError( message ); + } + /** * Convenience method to log errors * @@ -88,6 +98,15 @@ public class CDebugElement extends PlatformObject CDebugCorePlugin.log( e ); } + /** + * Convenience method to log errors + * + */ + protected void logError( String message ) + { + CDebugCorePlugin.log( message ); + } + /** * Fires a debug event * diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java index b5c44291043..2c2e6c2474e 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java @@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; import org.eclipse.cdt.debug.core.cdi.model.ICDIStringValue; import org.eclipse.cdt.debug.core.cdi.model.ICDIStructureValue; import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IValue; @@ -64,30 +65,7 @@ public abstract class CModificationVariable extends CVariable */ public boolean verifyValue( String expression ) { - try - { - ICDIValue vmValue = generateValue( expression ); - return vmValue != null; - } - catch( DebugException e ) - { - logError( e ); - return false; - } - } - - protected ICDIValue generateValue( String expression ) throws DebugException - { - ICDIValue value = null; - try - { - value = getCDITarget().evaluateExpressionToValue( expression ); - } - catch( CDIException e ) - { - targetRequestFailed( MessageFormat.format( ERROR_MESSAGE, new String[] { expression } ), null ); - } - return value; + return true; } /** @@ -103,19 +81,26 @@ public abstract class CModificationVariable extends CVariable */ public final void setValue( String expression ) throws DebugException { - ICDIValue value = generateValue( expression ); - - if ( value == null ) + ICDIVariable cdiVariable = getCDIVariable(); + if ( cdiVariable == null ) { - targetRequestFailed( MessageFormat.format( ERROR_MESSAGE, new String[] { expression } ), null ); + logError( "Error in IValueModification#setValue: no cdi variable." ); + requestFailed( "Unable to set value.", null ); + } + try + { + cdiVariable.setValue( expression ); + } + catch( CDIException e ) + { + targetRequestFailed( e.getMessage(), null ); } - - setValue( value ); - fireChangeEvent( DebugEvent.CONTENT ); } /** * Set this variable's value to the given value */ protected abstract void setValue( ICDIValue value ) throws DebugException; + + protected abstract ICDIVariable getCDIVariable(); }