mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Implementation of the 'Change Variable Value' action.
This commit is contained in:
parent
377485b1dd
commit
71d62cdd6e
3 changed files with 49 additions and 31 deletions
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue