| java.lang.Object com.google.gwt.dev.js.ast.JsScope
All known Subclasses: com.google.gwt.dev.js.ast.JsCatchScope, com.google.gwt.dev.js.ast.JsRootScope,
JsScope | public class JsScope (Code) | | A scope is a factory for creating and allocating
com.google.gwt.dev.js.ast.JsName s. A JavaScript AST is built
in terms of abstract name objects without worrying about obfuscation,
keyword/identifier blacklisting, and so on.
Scopes are associated with
com.google.gwt.dev.js.ast.JsFunction s,
but the two are not equivalent. Functions have scopes, but a scope
does not necessarily have an associated Function. Examples of this include
the
com.google.gwt.dev.js.ast.JsRootScope and synthetic scopes that
might be created by a client.
Scopes can have parents to provide constraints when allocating actual
identifiers for names. Specifically, names in child scopes are chosen such
that they do not conflict with names in their parent scopes. The ultimate
parent is usually the global scope (see
com.google.gwt.dev.js.ast.JsProgram.getGlobalScope ), but
parentless scopes are useful for managing names that are always accessed with
a qualifier and could therefore never be confused with the global scope
hierarchy.
|
Constructor Summary | |
public | JsScope(JsScope parent, String description) Create a scope with parent. | protected | JsScope(String description) Subclasses can be parentless. |
Method Summary | |
public JsName | declareName(String ident) Gets a name object associated with the specified ident in this scope,
creating it if necessary. | public JsName | declareName(String ident, String shortIdent) Gets a name object associated with the specified ident in this scope,
creating it if necessary. | protected JsName | doCreateName(String ident, String shortIdent) Creates a new name in this scope. | final public JsName | findExistingName(String ident) Attempts to find the name object for the specified ident, searching in this
scope, and if not found, in the parent scopes. | protected JsName | findExistingNameNoRecurse(String ident) Attempts to find the name object for the specified ident, searching in this
scope only. | final public JsName | findExistingUnobfuscatableName(String ident) Attempts to find an unobfuscatable name object for the specified ident,
searching in this scope, and if not found, in the parent scopes. | public Iterator<JsName> | getAllNames() Returns an iterator for all the names defined by this scope. | final public List<JsScope> | getChildren() Returns a list of this scope's child scopes. | final public JsScope | getParent() Returns the parent scope of this scope, or null if this is
the root scope. | public JsProgram | getProgram() Returns the associated program. | final public String | toString() |
JsScope | protected JsScope(String description)(Code) | | Subclasses can be parentless.
|
declareName | public JsName declareName(String ident)(Code) | | Gets a name object associated with the specified ident in this scope,
creating it if necessary.
Parameters: ident - An identifier that is unique within this scope. |
declareName | public JsName declareName(String ident, String shortIdent)(Code) | | Gets a name object associated with the specified ident in this scope,
creating it if necessary.
Parameters: ident - An identifier that is unique within this scope. Parameters: shortIdent - A "pretty" name that does not have to be unique. throws: IllegalArgumentException - if ident already exists in this scope butthe requested short name does not match the existing short name. |
findExistingName | final public JsName findExistingName(String ident)(Code) | | Attempts to find the name object for the specified ident, searching in this
scope, and if not found, in the parent scopes.
null if the identifier has no associated name |
findExistingNameNoRecurse | protected JsName findExistingNameNoRecurse(String ident)(Code) | | Attempts to find the name object for the specified ident, searching in this
scope only.
null if the identifier has no associated name |
findExistingUnobfuscatableName | final public JsName findExistingUnobfuscatableName(String ident)(Code) | | Attempts to find an unobfuscatable name object for the specified ident,
searching in this scope, and if not found, in the parent scopes.
null if the identifier has no associated name |
getAllNames | public Iterator<JsName> getAllNames()(Code) | | Returns an iterator for all the names defined by this scope.
|
getChildren | final public List<JsScope> getChildren()(Code) | | Returns a list of this scope's child scopes.
|
getParent | final public JsScope getParent()(Code) | | Returns the parent scope of this scope, or null if this is
the root scope.
|
getProgram | public JsProgram getProgram()(Code) | | Returns the associated program.
|
|
|