diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 5e22d0d4823..4041c78fca5 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2003-03-17 Mikhail Khodjaiants + Replace range by start index and length in 'Display As Array' action. + * ICDIVariableManager.java + * ICastToArray.java + * CVariable.java + 2003-03-14 Mikhail Khodjaiants Added the 'isEditable' and 'hasChildren' methods to the 'ICVariable' interface. * ICVariable.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIVariableManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIVariableManager.java index 692fb3a1883..b0c7116f541 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIVariableManager.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/ICDIVariableManager.java @@ -52,13 +52,13 @@ public interface ICDIVariableManager extends ICDIManager { ICDIVariableObject getVariableObject(ICDIStackFrame stack, String name) throws CDIException; /** - * Consider the variable object as an Array of type and range[start, end] + * Consider the variable object as an Array of type and range[start, start + length - 1] * @param stack * @param name * @return ICDIVariableObject * @throws CDIException */ - ICDIVariableObject getVariableObjectAsArray(ICDIVariableObject var, String type, int start, int end) throws CDIException; + ICDIVariableObject getVariableObjectAsArray(ICDIVariableObject var, String type, int start, int length) throws CDIException; /** * Consider the variable object as type. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java index e531d071eca..cbfca37f368 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICastToArray.java @@ -17,5 +17,5 @@ public interface ICastToArray extends ICastToType { boolean supportsCastToArray(); - void castToArray( String type, int startIndex, int endIndex ) throws DebugException; + void castToArray( String type, int startIndex, int length ) throws DebugException; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index e302db25269..baef519c2ec 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -517,11 +517,11 @@ public abstract class CVariable extends CDebugElement return null; } - private ICDIVariable createShadow( ICDIStackFrame cdiFrame, String type, int start, int end ) throws DebugException + private ICDIVariable createShadow( ICDIStackFrame cdiFrame, String type, int start, int length ) throws DebugException { try { - ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsArray( getOriginalCDIVariable(), type, start, end ); + ICDIVariableObject varObject = getCDISession().getVariableManager().getVariableObjectAsArray( getOriginalCDIVariable(), type, start, length ); return getCDISession().getVariableManager().createVariable( varObject ); } catch( CDIException e ) @@ -554,11 +554,11 @@ public abstract class CVariable extends CDebugElement /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICastToArray#castToArray(java.lang.String, int, int) */ - public void castToArray( String type, int startIndex, int endIndex ) throws DebugException + public void castToArray( String type, int startIndex, int length ) throws DebugException { try { - ICDIVariable newVar = createShadow( getOriginalCDIVariable().getStackFrame(), type, startIndex, endIndex ); + ICDIVariable newVar = createShadow( getOriginalCDIVariable().getStackFrame(), type, startIndex, length ); ICDIVariable oldVar = getShadow(); setShadow( newVar ); if ( oldVar != null ) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index a6d217a2f9f..fb94a851c8a 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2003-03-17 Mikhail Khodjaiants + Replace range by start index and length in 'Display As Array' action. + * CastToArrayActionDelegate.java + 2003-03-14 Mikhail Khodjaiants Fix for the 'Restore Default Type' action. * RestoreDefaultTypeActionDelegate.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java index 6da316cc8ee..e65e872d772 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/CastToArrayActionDelegate.java @@ -46,21 +46,21 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject { private String fType = ""; private int fFirstIndex = 0; - private int fLastIndex = 0; + private int fLength = 0; private Button fOkButton; private Label fErrorMessageLabel; private Text fTypeText; private Text fFirstIndexText; - private Text fLastIndexText; + private Text fLengthText; - public CastToArrayDialog( Shell parentShell, String initialType, int initialStart, int initialEnd ) + public CastToArrayDialog( Shell parentShell, String initialType, int initialStart, int initialLength ) { super( parentShell ); fType = ( initialType == null ) ? "" : initialType; fFirstIndex = initialStart; - fLastIndex = initialEnd; + fLength = initialLength; } protected String getType() @@ -73,9 +73,9 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject return fFirstIndex; } - protected int getLastIndex() + protected int getLength() { - return fLastIndex; + return fLength; } /* (non-Javadoc) @@ -103,7 +103,7 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject fTypeText.setText( fType ); fTypeText.selectAll(); fFirstIndexText.setText( String.valueOf( fFirstIndex ) ); - fLastIndexText.setText( String.valueOf( fLastIndex ) ); + fLengthText.setText( String.valueOf( fLength ) ); } } @@ -150,7 +150,7 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject } } ); - Label label = ControlFactory.createLabel( composite, "First index:" ); + Label label = ControlFactory.createLabel( composite, "Start index:" ); ((GridData)label.getLayoutData()).horizontalSpan = 3; fFirstIndexText = ControlFactory.createTextField( composite ); fFirstIndexText.addModifyListener( @@ -162,10 +162,10 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject } } ); - label = ControlFactory.createLabel( composite, "Last index:" ); + label = ControlFactory.createLabel( composite, "Length:" ); ((GridData)label.getLayoutData()).horizontalSpan = 3; - fLastIndexText = ControlFactory.createTextField( composite ); - fLastIndexText.addModifyListener( + fLengthText = ControlFactory.createTextField( composite ); + fLengthText.addModifyListener( new ModifyListener() { public void modifyText( ModifyEvent e ) @@ -194,45 +194,38 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject } else { - int first = -1; try { - first = Integer.parseInt( firstIndex ); + Integer.parseInt( firstIndex ); } catch( NumberFormatException e ) - { - } - if ( first < 0 ) { message = "Invalid first index."; enabled = false; } - else + if ( enabled ) { - String lastIndex = fLastIndexText.getText().trim(); - if ( lastIndex.length() == 0 ) + String lengthText = fLengthText.getText().trim(); + if ( lengthText.length() == 0 ) { message = "The 'Last index' field must not be empty."; enabled = false; } else { - int last = -1; + int length = -1; try { - last = Integer.parseInt( lastIndex ); + length = Integer.parseInt( lengthText ); } catch( NumberFormatException e ) - { - } - if ( last < 0 ) { message = "Invalid last index."; enabled = false; } - else if ( last < first ) + if ( enabled && length < 1 ) { - message = "The first index must not be greater than the last index."; + message = "The length must be greater than 0."; enabled = false; } } @@ -252,16 +245,16 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject { fType = fTypeText.getText().trim(); String firstIndex = fFirstIndexText.getText().trim(); - String lastIndex = fLastIndexText.getText().trim(); + String lengthText = fLengthText.getText().trim(); try { fFirstIndex = Integer.parseInt( firstIndex ); - fLastIndex = Integer.parseInt( lastIndex ); + fLength = Integer.parseInt( lengthText ); } catch( NumberFormatException e ) { fFirstIndex = 0; - fLastIndex = 0; + fLength = 0; } } else @@ -370,12 +363,12 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject protected void doAction( ICastToArray castToArray ) throws DebugException { String currentType = castToArray.getCurrentType().trim(); - CastToArrayDialog dialog = new CastToArrayDialog( CDebugUIPlugin.getActiveWorkbenchShell(), currentType, 0, 0 ); + CastToArrayDialog dialog = new CastToArrayDialog( CDebugUIPlugin.getActiveWorkbenchShell(), currentType, 0, 1 ); if ( dialog.open() == Window.OK ) { String newType = dialog.getType().trim(); int firstIndex = dialog.getFirstIndex(); - int lastIndex = dialog.getLastIndex(); + int lastIndex = dialog.getLength(); castToArray.castToArray( newType, firstIndex, lastIndex ); } }