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

Side by Side Diff: plugins/org.chromium.sdk/src/org/chromium/sdk/JsScope.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.sdk; 5 package org.chromium.sdk;
6 6
7 import java.util.List; 7 import java.util.List;
8 8
9 import org.chromium.sdk.util.MethodIsBlockingException; 9 import org.chromium.sdk.util.MethodIsBlockingException;
10 10
11 /** 11 /**
12 * An object that represents a scope in JavaScript. 12 * An object that represents a scope in JavaScript. It could be either declarati ve or object
13 * TODO: consider adding object getter for both with and global scopes. 13 * scope.
14 */ 14 */
15 public interface JsScope { 15 public interface JsScope {
16 16
17 enum Type { 17 enum Type {
18 GLOBAL, 18 GLOBAL,
19 LOCAL, 19 LOCAL,
20 WITH, 20 WITH,
21 CLOSURE, 21 CLOSURE,
22 CATCH, 22 CATCH,
23 UNKNOWN 23 UNKNOWN
24 // TODO: add "block" type (corresponds to block scope in JavaScript 1.7). 24 // TODO: add "block" type (corresponds to block scope in JavaScript 1.7).
25 } 25 }
26 26
27 /** 27 /**
28 * @return type of the scope 28 * @return type of the scope
29 */ 29 */
30 Type getType(); 30 Type getType();
31 31
32 /** 32 /**
33 * @return optional subtype when type is a native JavaScript scope and null ot herwise
34 */
35 Declarative asDeclarativeScope();
36
37 /**
33 * @return optional subtype when type is {@link Type#WITH} and null otherwise 38 * @return optional subtype when type is {@link Type#WITH} and null otherwise
34 */ 39 */
35 WithScope asWithScope(); 40 ObjectBased asObjectBased();
41
42 <R> R accept(Visitor<R> visitor);
43
44 interface Visitor<R> {
45 R visitDeclarative(Declarative declarativeScope);
46 R visitObject(ObjectBased objectScope);
47 }
36 48
37 /** 49 /**
38 * @return the variables known in this scope, in lexicographical order 50 * Mirrors <i>declarative</i> scope. It's all scopes except 'with' and 'global '. This scope
39 * @throws MethodIsBlockingException because it may need to load value from re mote 51 * has a well-defined set of variables.
40 */ 52 */
41 List<? extends JsVariable> getVariables() throws MethodIsBlockingException; 53 interface Declarative extends JsScope {
54 /**
55 * @return the variables known in this scope, in lexicographical order
56 * @throws MethodIsBlockingException because it may need to load value from remote
57 */
58 List<? extends JsVariable> getVariables() throws MethodIsBlockingException;
59 }
42 60
43 /** 61 /**
44 * Subtype that exposes the value of the 'with' statement expression (the valu e might be 62 * Mirrors <i>object</i> scope, i.e. the one built above a JavaScript object. It's either
45 * already converted by ToObject). 63 * 'with' or 'global' scope. Such scope contains all properties of the object, including
64 * indirect ones from the prototype chain.
46 */ 65 */
47 interface WithScope extends JsScope { 66 interface ObjectBased extends JsScope {
48 /** 67 /**
49 * @throws MethodIsBlockingException because it may need to load value from remote 68 * @throws MethodIsBlockingException because it may need to load value from remote
50 */ 69 */
51 JsValue getWithArgument() throws MethodIsBlockingException; 70 JsObject getScopeObject() throws MethodIsBlockingException;
52 } 71 }
53 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698