diff options
author | Eugene Tarassov | 2014-06-09 04:44:54 +0000 |
---|---|---|
committer | Eugene Tarassov | 2014-06-09 04:57:39 +0000 |
commit | 358190072abe0bee7ec391fb586ecbb9cc0c384f (patch) | |
tree | 853e376fa17fa83eecc32f4aec36e7329facc716 /plugins/org.eclipse.tcf.debug.ui | |
parent | 4fb0fff415659d1dcca7bf791061c8700af223bd (diff) | |
download | org.eclipse.tcf-358190072abe0bee7ec391fb586ecbb9cc0c384f.tar.gz org.eclipse.tcf-358190072abe0bee7ec391fb586ecbb9cc0c384f.tar.xz org.eclipse.tcf-358190072abe0bee7ec391fb586ecbb9cc0c384f.zip |
Bug 436842 - Expression view does not report array lower bound different from 0
Diffstat (limited to 'plugins/org.eclipse.tcf.debug.ui')
2 files changed, 47 insertions, 7 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeArrayPartition.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeArrayPartition.java index 0cd3aa37b..0af940820 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeArrayPartition.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeArrayPartition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2014 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,11 +10,16 @@ *******************************************************************************/ package org.eclipse.tcf.internal.debug.ui.model; +import java.math.BigInteger; + import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate; import org.eclipse.tcf.internal.debug.ui.ImageCache; +import org.eclipse.tcf.protocol.JSON; +import org.eclipse.tcf.services.ISymbols; +import org.eclipse.tcf.util.TCFDataCache; public class TCFNodeArrayPartition extends TCFNode { @@ -37,6 +42,19 @@ public class TCFNodeArrayPartition extends TCFNode { return size; } + private BigInteger getLowerBound(Runnable done) { + TCFNode n = parent; + while (n instanceof TCFNodeArrayPartition) n = n.parent; + TCFDataCache<ISymbols.Symbol> t = ((TCFNodeExpression)n).getType(); + if (!t.validate(done)) return null; + ISymbols.Symbol s = t.getData(); + if (s != null) { + Number l = s.getLowerBound(); + if (l != null) return JSON.toBigInteger(l); + } + return BigInteger.valueOf(0); + } + @Override protected boolean getData(IChildrenCountUpdate result, Runnable done) { if (!children.validate(done)) return false; @@ -57,9 +75,12 @@ public class TCFNodeArrayPartition extends TCFNode { @Override protected boolean getData(ILabelUpdate result, Runnable done) { + BigInteger lower_bound = getLowerBound(done); + if (lower_bound == null) return false; result.setImageDescriptor(ImageCache.getImageDescriptor(ImageCache.IMG_ARRAY_PARTITION), 0); String[] cols = result.getColumnIds(); - String name = "[" + offs + ".." + (offs + size - 1) + "]"; + BigInteger index = lower_bound.add(BigInteger.valueOf(offs)); + String name = "[" + index + ".." + (index.add(BigInteger.valueOf(size - 1))) + "]"; if (cols == null || cols.length <= 1) { result.setLabel(name, 0); } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java index 5e8b95aa9..99760cb14 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java @@ -176,11 +176,13 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT if (field_id != null) { e = "(" + e + ")" + (deref ? "->" : ".") + "${" + field_id + "}"; } - else if (index == 0) { + else if (index == 0 && deref) { e = "*(" + e + ")"; } - else if (index > 0) { - e = "(" + e + ")[" + index + "]"; + else if (index >= 0) { + BigInteger lower_bound = getLowerBound(this); + if (lower_bound == null) return false; + e = "(" + e + ")[" + lower_bound.add(BigInteger.valueOf(index)) + "]"; } set(null, null, e); return true; @@ -250,7 +252,9 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT expr_text = "*" + parent_text; } else { - expr_text = parent_text + "[" + index + "]"; + BigInteger lower_bound = getLowerBound(this); + if (lower_bound == null) return false; + expr_text = parent_text + "[" + lower_bound.add(BigInteger.valueOf(index)) + "]"; } } if (expr_text == null && field != null) { @@ -1141,6 +1145,19 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT return attribute != null && attribute; } + private BigInteger getLowerBound(Runnable done) { + TCFNode n = parent; + while (n instanceof TCFNodeArrayPartition) n = n.parent; + TCFDataCache<ISymbols.Symbol> t = ((TCFNodeExpression)n).getType(); + if (!t.validate(done)) return null; + ISymbols.Symbol s = t.getData(); + if (s != null) { + Number l = s.getLowerBound(); + if (l != null) return JSON.toBigInteger(l); + } + return BigInteger.valueOf(0); + } + @Override protected boolean getData(ILabelUpdate result, Runnable done) { if (is_empty) { @@ -1177,7 +1194,9 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT name = "*"; } else { - name = "[" + index + "]"; + BigInteger lower_bound = getLowerBound(done); + if (lower_bound == null) return false; + name = "[" + lower_bound.add(BigInteger.valueOf(index)) + "]"; } } if (name == null && field != null) { |