1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added new methods to ICVariable to vizualize arrays and structures based on the new CDI types.

This commit is contained in:
Mikhail Khodjaiants 2003-05-29 19:18:51 +00:00
parent 1a8a38360a
commit a295e9b86c
3 changed files with 59 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2003-05-29 Mikhail Khodjaiants
Added new methods to ICVariable to vizualize arrays and structures based
on the new CDI types.
* ICVariable.java
* CVariable.java
2003-05-27 Mikhail Khodjaiants
Check if the location of breakpoint is eligible for the target
when setting, removing or changing the propeties.

View file

@ -25,4 +25,10 @@ public interface ICVariable extends IVariable
boolean isEditable();
boolean hasChildren();
boolean isArray();
int[] getArrayDimensions();
boolean isStructure();
}

View file

@ -15,6 +15,10 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.core.model.ICastToArray;
@ -615,4 +619,47 @@ public abstract class CVariable extends CDebugElement
{
return isEditable() && hasChildren();
}
public boolean isArray()
{
return ( getType() instanceof ICDIArrayType );
}
public int[] getArrayDimensions()
{
int length = 0;
ICDIType type = getType();
while( type instanceof ICDIArrayType )
{
++length;
type = ( type instanceof ICDIDerivedType ) ? ((ICDIDerivedType)type).getComponentType() : null;
}
int[] dims = new int[length];
type = getType();
for ( int i = length; i > 0; --i )
{
dims[i - 1] = ((ICDIArrayType)type).getDimension();
type = ((ICDIDerivedType)type).getComponentType();
}
return dims;
}
public boolean isStructure()
{
return ( getType() instanceof ICDIStructType );
}
private ICDIType getType()
{
ICDIType type = null;
try
{
if ( getCDIVariable() != null )
type = getCDIVariable().getType();
}
catch( CDIException e )
{
}
return type;
}
}