Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Unified Diff: plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/StackFrame.java

Issue 11602013: Redesign scope API, separate declarative and object scopes. (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: patching other backends Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/ValueBase.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/StackFrame.java
diff --git a/plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/StackFrame.java b/plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/StackFrame.java
index c1d1b89c7cffe9ff2eeb7dda35ad6a147730f90f..e85347313edc69f0a5344a1654b748ab9dd7f139 100755
--- a/plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/StackFrame.java
+++ b/plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/StackFrame.java
@@ -17,6 +17,8 @@ import org.chromium.debug.core.sourcemap.SourcePositionMap;
import org.chromium.debug.core.sourcemap.SourcePositionMap.TranslateDirection;
import org.chromium.sdk.CallFrame;
import org.chromium.sdk.JsScope;
+import org.chromium.sdk.JsScope.Declarative;
+import org.chromium.sdk.JsScope.ObjectBased;
import org.chromium.sdk.JsVariable;
import org.chromium.sdk.RestartFrameExtension;
import org.chromium.sdk.Script;
@@ -102,9 +104,36 @@ public class StackFrame extends StackFrameBase implements IDropToFrame {
return vars.toArray(new IVariable[vars.size()]);
}
- static IVariable[] wrapScopes(EvaluateContext evaluateContext, List<? extends JsScope> jsScopes,
- JsVariable receiverVariable, ExpressionTracker.ScopeAndVariableFactory trackerNodeFactory) {
- List<Variable> vars = new ArrayList<Variable>();
+ static IVariable[] wrapScopes(final EvaluateContext evaluateContext,
+ List<? extends JsScope> jsScopes, JsVariable receiverVariable,
+ final ExpressionTracker.ScopeAndVariableFactory trackerNodeFactory) {
+ final List<Variable> vars = new ArrayList<Variable>();
+
+ JsScope.Visitor<Void> scopeVisitor = new JsScope.Visitor<Void>() {
+ @Override
+ public Void visitDeclarative(Declarative declarativeScope) {
+ int startPos = vars.size();
+ for (JsVariable var : declarativeScope.getVariables()) {
+ vars.add(Variable.forRealValue(evaluateContext, var, false,
+ trackerNodeFactory.createVariableNode(var, false)));
+ }
+ // TODO: consider not sorting them once V8 native protocol returns locals ordered.
+ final boolean sortVariables = true;
+ if (sortVariables) {
+ int endPos = vars.size();
+ List<Variable> sublist = vars.subList(startPos, endPos);
+ Collections.sort(sublist, VARIABLE_COMPARATOR);
+ }
+ return null;
+ }
+
+ @Override
+ public Void visitObject(ObjectBased objectScope) {
+ vars.add(Variable.forObjectScope(evaluateContext, objectScope,
+ trackerNodeFactory.createScopeNode()));
+ return null;
+ }
+ };
for (JsScope scope : jsScopes) {
if (scope.getType() == JsScope.Type.GLOBAL) {
@@ -115,22 +144,8 @@ public class StackFrame extends StackFrameBase implements IDropToFrame {
expressionTrackerNode));
receiverVariable = null;
}
- ExpressionTracker.Node scopeValueNode = trackerNodeFactory.createScopeNode();
- vars.add(Variable.forScope(evaluateContext, scope, scopeValueNode));
- } else if (scope.asWithScope() != null) {
- JsScope.WithScope withScope = scope.asWithScope();
- vars.add(Variable.forWithScope(evaluateContext, withScope,
- trackerNodeFactory.createScopeNode()));
- } else {
- int startPos = vars.size();
- for (JsVariable var : scope.getVariables()) {
- vars.add(Variable.forRealValue(evaluateContext, var, false,
- trackerNodeFactory.createVariableNode(var, false)));
- }
- int endPos = vars.size();
- List<Variable> sublist = vars.subList(startPos, endPos);
- Collections.sort(sublist, VARIABLE_COMPARATOR);
}
+ scope.accept(scopeVisitor);
}
if (receiverVariable != null) {
vars.add(Variable.forRealValue(evaluateContext, receiverVariable, false,
« no previous file with comments | « no previous file | plugins/org.chromium.debug.core/src/org/chromium/debug/core/model/ValueBase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698