summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamrat Dhillon2012-08-24 17:54:30 (EDT)
committer Mike Rennie2012-08-24 17:54:30 (EDT)
commit3dcdaba35ccb9fe70fe2cd0a12810ea80ccdb16e (patch)
treeb140c59e1faac78fb4e98bd0ba125d7e1969bc6f
parent37bafda5d7d586d8f0104a437c3f7725e81010f5 (diff)
downloadeclipse.jdt.debug-3dcdaba35ccb9fe70fe2cd0a12810ea80ccdb16e.zip
eclipse.jdt.debug-3dcdaba35ccb9fe70fe2cd0a12810ea80ccdb16e.tar.gz
eclipse.jdt.debug-3dcdaba35ccb9fe70fe2cd0a12810ea80ccdb16e.tar.bz2
Bug 384458 - debug shows value of variable in another scopev20120824-215430
-rw-r--r--org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java
index 0cd2d25..2c6981b 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Samrat Dhillon samrat.dhillon@gmail.com - Bug 384458 - debug shows value of variable in another scope
*******************************************************************************/
package org.eclipse.jdt.internal.debug.core.model;
@@ -689,17 +690,27 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame {
return null;
}
IVariable[] variables = getVariables();
+ List<IJavaVariable> possibleMatches = new ArrayList<IJavaVariable>();
IJavaVariable thisVariable = null;
for (IVariable variable : variables) {
IJavaVariable var = (IJavaVariable) variable;
if (var.getName().equals(varName)) {
- return var;
+ possibleMatches.add(var);
}
if (var instanceof JDIThisVariable) {
// save for later - check for instance and static variables
thisVariable = var;
}
}
+ for(IJavaVariable variable: possibleMatches){
+ // Local Variable has more preference than Field Variable
+ if(variable instanceof JDILocalVariable){
+ return variable;
+ }
+ }
+ if(possibleMatches.size() > 0) {
+ return possibleMatches.get(0);
+ }
if (thisVariable != null) {
IVariable[] thisChildren = thisVariable.getValue().getVariables();
@@ -710,9 +721,7 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame {
}
}
}
-
return null;
-
}
/**