diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/AbstractDMContext.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/AbstractDMContext.java index 2c5dd2b6fd5..a6d052dabfc 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/AbstractDMContext.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/datamodel/AbstractDMContext.java @@ -35,6 +35,8 @@ import org.eclipse.core.runtime.PlatformObject; abstract public class AbstractDMContext extends PlatformObject implements IDMContext { + public static final IDMContext[] EMPTY_PARENTS_ARRAY = new IDMContext[0]; + private final String fSessionId; private final IDMContext[] fParents; @@ -70,9 +72,10 @@ abstract public class AbstractDMContext extends PlatformObject } private boolean areParentsEqual(IDMContext[] otherParents) { - if ( !(fParents.length == otherParents.length) ) return false; - for (int i = 0; i < fParents.length; i++) { - if (!fParents[i].equals(otherParents[i])) { + IDMContext[] parents = getParents(); + if ( !(parents.length == otherParents.length) ) return false; + for (int i = 0; i < parents.length; i++) { + if (!parents[i].equals(otherParents[i])) { return false; } } @@ -95,14 +98,14 @@ abstract public class AbstractDMContext extends PlatformObject */ protected String baseToString() { StringBuilder retVal = new StringBuilder(); - for (IDMContext parent : fParents) { + for (IDMContext parent : getParents()) { retVal.append(parent); retVal.append(','); } if (retVal.length() > 0) { retVal.deleteCharAt(retVal.length() - 1); // remove trailing comma } - if (fParents.length > 1) { + if (getParents().length > 1) { retVal.insert(0, '('); retVal.insert(retVal.length(), ')'); } diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IFormattedValues.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IFormattedValues.java index 4d8deb4ead5..a82fd3f86af 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IFormattedValues.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IFormattedValues.java @@ -73,7 +73,6 @@ public interface IFormattedValues extends IDsfService { * DMC that represents a value with specific format. The format ID can be * persisted and used for comparison. */ - public static class FormattedValueDMContext extends AbstractDMContext { private final String fFormatID; @@ -81,16 +80,26 @@ public interface IFormattedValues extends IDsfService { /** * @since 2.0 */ - public FormattedValueDMContext(IDsfService service, IDMContext parent, String formatId) { - super(service, new IDMContext[] { parent }); + public FormattedValueDMContext(IDsfService service, IDMContext parentValue, String formatId) { + super(service, new IDMContext[] { parentValue }); fFormatID = formatId; } - public FormattedValueDMContext(String sessionId, IDMContext parent, String formatId) { - super(sessionId, new IDMContext[] { parent }); + public FormattedValueDMContext(String sessionId, IDMContext parentValue, String formatId) { + super(sessionId, new IDMContext[] { parentValue }); fFormatID = formatId; } + /** + * Returns the parent context which represents the value on which this + * formatted value is based on. + * + * @since 2.2 + */ + public IDMContext getParentValueDMContext() { + return getParents()[0]; + } + public String getFormatID() { return fFormatID; }