Chromium Code Reviews| Index: plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/wip/WipContextBuilder.java |
| diff --git a/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/wip/WipContextBuilder.java b/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/wip/WipContextBuilder.java |
| index 856605cd437eaf0600b37eab302c163b7bff34ca..6f0c347ad55f051d4910186fe8019393454ea0e3 100644 |
| --- a/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/wip/WipContextBuilder.java |
| +++ b/plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/wip/WipContextBuilder.java |
| @@ -24,9 +24,7 @@ import org.chromium.sdk.DebugContext; |
| import org.chromium.sdk.DebugContext.StepAction; |
| import org.chromium.sdk.ExceptionData; |
| import org.chromium.sdk.JavascriptVm; |
| -import org.chromium.sdk.JsArray; |
| import org.chromium.sdk.JsEvaluateContext; |
| -import org.chromium.sdk.JsFunction; |
| import org.chromium.sdk.JsObject; |
| import org.chromium.sdk.JsScope; |
| import org.chromium.sdk.JsValue; |
| @@ -570,14 +568,14 @@ class WipContextBuilder { |
| if (type == null) { |
| type = JsScope.Type.UNKNOWN; |
| } |
| - if (type == JsScope.Type.WITH) { |
| - return new WithScopeImpl(scopeData, valueLoader); |
| + if (type == JsScope.Type.WITH || type == JsScope.Type.GLOBAL) { |
| + return new ObjectScopeImpl(scopeData, type, valueLoader); |
| } else { |
| return new ScopeImpl(scopeData, type, valueLoader); |
| } |
| } |
| - private static class ScopeImpl implements JsScope { |
| + private static class ScopeImpl implements JsScope.Declarative { |
| private final AsyncFutureRef<Getter<ScopeVariables>> propertiesRef = |
| new AsyncFutureRef<Getter<ScopeVariables>>(); |
| private final String objectId; |
| @@ -590,15 +588,19 @@ class WipContextBuilder { |
| this.valueLoader = valueLoader; |
| } |
| - @Override |
| - public Type getType() { |
| + @Override public Type getType() { |
| return type; |
| } |
| - @Override |
| - public WithScope asWithScope() { |
| + @Override public Declarative asDeclarativeScope() { |
| + return this; |
| + } |
| + @Override public ObjectBased asObjectBased() { |
|
apavlov
2012/12/27 08:02:16
blank line above
Peter Rybin
2013/01/09 15:30:31
Done.
|
| return null; |
| } |
| + @Override public <R> R accept(Visitor<R> visitor) { |
|
apavlov
2012/12/27 08:02:16
ditto
Peter Rybin
2013/01/09 15:30:31
Done.
|
| + return visitor.visitDeclarative(this); |
| + } |
| @Override |
| public List<? extends JsVariable> getVariables() throws MethodIsBlockingException { |
| @@ -670,35 +672,36 @@ class WipContextBuilder { |
| } |
| } |
| - private static class WithScopeImpl implements JsScope.WithScope { |
| + private static class ObjectScopeImpl implements JsScope.ObjectBased { |
| private final JsValue jsValue; |
| + private final JsScope.Type type; |
| - WithScopeImpl(ScopeValue scopeData, WipValueLoader valueLoader) { |
| - jsValue = valueLoader.getValueBuilder().wrap(scopeData.object()); |
| + ObjectScopeImpl(ScopeValue scopeData, JsScope.Type type, WipValueLoader valueLoader) { |
| + this.jsValue = valueLoader.getValueBuilder().wrap(scopeData.object()); |
| + this.type = type; |
| } |
| - @Override |
| - public Type getType() { |
| - return Type.WITH; |
| + @Override public Type getType() { |
| + return type; |
| } |
| - @Override |
| - public WithScope asWithScope() { |
| + @Override public Declarative asDeclarativeScope() { |
| + return null; |
| + } |
| + @Override public ObjectBased asObjectBased() { |
|
apavlov
2012/12/27 08:02:16
ditto
Peter Rybin
2013/01/09 15:30:31
Done.
|
| return this; |
| } |
| - |
| - @Override |
| - public List<? extends JsVariable> getVariables() throws MethodIsBlockingException { |
| - JsObject asObject = jsValue.asObject(); |
| - if (asObject == null) { |
| - return Collections.emptyList(); |
| - } |
| - return new ArrayList<JsVariable>(asObject.getProperties()); |
| + @Override public <R> R accept(Visitor<R> visitor) { |
|
apavlov
2012/12/27 08:02:16
ditto
Peter Rybin
2013/01/09 15:30:31
Done.
|
| + return visitor.visitObject(this); |
| } |
| @Override |
| - public JsValue getWithArgument() { |
| - return jsValue; |
| + public JsObject getScopeObject() throws MethodIsBlockingException { |
| + JsObject jsObject = jsValue.asObject(); |
| + if (jsObject == null) { |
| + throw new RuntimeException("Received scope object value is not an object"); |
| + } |
| + return jsObject; |
| } |
| } |