1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +02:00

Added new method equals().

This commit is contained in:
Alain Magloire 2003-09-30 20:33:53 +00:00
parent 1a408fd237
commit d296af351f
3 changed files with 47 additions and 0 deletions

View file

@ -70,4 +70,13 @@ public interface ICDIVariableObject extends ICDIObject {
* @throws CDIException if this method fails. Reasons include:
*/
String getQualifiedName() throws CDIException;
/**
* Returns true if the variable Object are the same,
* For example event if the name is the same because of
* casting this may return false;
* @return true if the same
*/
boolean equals(ICDIVariableObject varObject);
}

View file

@ -164,6 +164,13 @@ public abstract class CVariable extends CDebugElement
{
return ( fVariableObject != null ) ? fVariableObject.getQualifiedName() : null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#equals(org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject)
*/
public boolean equals(ICDIVariableObject varObject) {
return super.equals(varObject);
}
}
class InternalVariable

View file

@ -288,4 +288,35 @@ public class VariableObject extends CObject implements ICDIVariableObject {
return qualifiedName;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#equals(ICDIVariableObject)
*/
public boolean equals(ICDIVariableObject varObj) {
if (varObj instanceof VariableObject) {
VariableObject var = (VariableObject) varObj;
if (var.getName().equals(getName())
&& var.getCastingArrayStart() == getCastingArrayStart()
&& var.getCastingArrayEnd() == getCastingArrayEnd()
&& ((var.getCastingType() == null && getCastingType() == null)
|| (var.getCastingType() != null && getCastingType() != null && var.getCastingType().equals(getCastingType())))) {
ICDIStackFrame varFrame = null;
ICDIStackFrame ourFrame = null;
try {
varFrame = var.getStackFrame();
ourFrame = getStackFrame();
} catch (CDIException e) {
}
if (ourFrame == null && varFrame == null) {
return true;
} else if (varFrame != null && ourFrame != null && varFrame.equals(ourFrame)) {
if (var.getStackDepth() == getStackDepth()) {
if (var.getPosition() == getPosition()) {
return true;
}
}
}
}
}
return super.equals(varObj);
}
}