| Index: plugins/org.chromium.sdk.wipbackend.protocol_1_0/src/org/chromium/sdk/internal/wip/WipContextBuilder.java
|
| diff --git a/plugins/org.chromium.sdk.wipbackend.protocol_1_0/src/org/chromium/sdk/internal/wip/WipContextBuilder.java b/plugins/org.chromium.sdk.wipbackend.protocol_1_0/src/org/chromium/sdk/internal/wip/WipContextBuilder.java
|
| index 5e9da2c726c1bc29dbc17db635e9ba438b5cb860..4fa37275b7db89d9cc74cf957908466f7dfed275 100644
|
| --- a/plugins/org.chromium.sdk.wipbackend.protocol_1_0/src/org/chromium/sdk/internal/wip/WipContextBuilder.java
|
| +++ b/plugins/org.chromium.sdk.wipbackend.protocol_1_0/src/org/chromium/sdk/internal/wip/WipContextBuilder.java
|
| @@ -22,6 +22,10 @@ import org.chromium.sdk.Breakpoint;
|
| import org.chromium.sdk.CallFrame;
|
| import org.chromium.sdk.DebugContext;
|
| import org.chromium.sdk.DebugContext.StepAction;
|
| +import org.chromium.sdk.JsScope.Declarative;
|
| +import org.chromium.sdk.JsScope.ObjectBased;
|
| +import org.chromium.sdk.JsScope.Type;
|
| +import org.chromium.sdk.JsScope.Visitor;
|
| import org.chromium.sdk.ExceptionData;
|
| import org.chromium.sdk.JavascriptVm;
|
| import org.chromium.sdk.JsEvaluateContext;
|
| @@ -447,34 +451,40 @@ class WipContextBuilder {
|
| }
|
|
|
| JsScope createScope(ScopeValue scopeData, JsScope.Type type) {
|
| - if (type == JsScope.Type.WITH) {
|
| - return new WithScopeImpl(scopeData);
|
| + if (type == JsScope.Type.WITH || type == JsScope.Type.GLOBAL) {
|
| + return new ObjectScopeImpl(scopeData, type);
|
| } else {
|
| - return new ScopeImpl(scopeData, type);
|
| + return new DeclarativeScopeImpl(scopeData, type);
|
| }
|
| }
|
|
|
| - private class ScopeImpl implements JsScope {
|
| + private class DeclarativeScopeImpl implements JsScope.Declarative {
|
| private final AsyncFutureRef<Getter<ScopeVariables>> propertiesRef =
|
| new AsyncFutureRef<Getter<ScopeVariables>>();
|
| private final String objectId;
|
| private final Type type;
|
|
|
| - public ScopeImpl(ScopeValue scopeData, Type type) {
|
| + public DeclarativeScopeImpl(ScopeValue scopeData, Type type) {
|
| this.type = type;
|
| this.objectId = scopeData.object().objectId();
|
| }
|
|
|
| - @Override
|
| - public Type getType() {
|
| + @Override public Type getType() {
|
| return type;
|
| }
|
|
|
| - @Override
|
| - public WithScope asWithScope() {
|
| + @Override public Declarative asDeclarativeScope() {
|
| + return this;
|
| + }
|
| +
|
| + @Override public ObjectBased asObjectBased() {
|
| return null;
|
| }
|
|
|
| + @Override public <R> R accept(Visitor<R> visitor) {
|
| + return visitor.visitDeclarative(this);
|
| + }
|
| +
|
| @Override
|
| public List<? extends JsVariable> getVariables() throws MethodIsBlockingException {
|
| int currentCacheState = valueLoader.getCacheState();
|
| @@ -542,35 +552,38 @@ class WipContextBuilder {
|
| }
|
| }
|
|
|
| - private class WithScopeImpl implements JsScope.WithScope {
|
| + private class ObjectScopeImpl implements JsScope.ObjectBased {
|
| private final JsValue jsValue;
|
| + private final JsScope.Type type;
|
|
|
| - WithScopeImpl(ScopeValue scopeData) {
|
| + ObjectScopeImpl(ScopeValue scopeData, JsScope.Type type) {
|
| jsValue = valueLoader.getValueBuilder().wrap(scopeData.object(), null);
|
| + 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() {
|
| 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) {
|
| + 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;
|
| }
|
| }
|
|
|
|
|