com.aptana.ide.editor.js.runtime
Class JSScope

java.lang.Object
  extended by com.aptana.ide.editor.js.runtime.ObjectBase
      extended by com.aptana.ide.editor.js.runtime.JSScope
All Implemented Interfaces:
IObject, IScope, IRange, IDocumentationContainer

public class JSScope
extends ObjectBase
implements IScope

Author:
Kevin Lindsey, Robin Debreuil

Field Summary
protected  IScope _parentScope
          This scope's parent scope
 
Fields inherited from class com.aptana.ide.editor.js.runtime.ObjectBase
NULL, UNDEFINED
 
Constructor Summary
JSScope()
           
 
Method Summary
 java.lang.String getClassName()
          Returns the class name of this object.
 IFunction getEnclosingFunction()
          Gets the enclosing function of this object, or null if global
 java.lang.String[] getLocalVariableNames()
          Get all variable names that exist on this scope only (does not follow scope chain)
 IScope getOwningScope(java.lang.String variableName)
          Returns the IScope object that holds the specified variable name
 IScope getParentScope()
          Returns the parent scope of this object.
 Property getVariable(java.lang.String variableName)
          Get the Property object for the associated variable name
 java.lang.String[] getVariableNames()
          Return all variable names in this scope and in all parent scopes.
 Reference getVariableReference(java.lang.String variableName)
          Get a reference object that points to the specified property name
 IObject getVariableValue(java.lang.String variableName, int fileIndex, int offset)
          Get the named variable.
 boolean hasVariable(java.lang.String variableName)
          Determine if the specified variable name is in the current scope chain
 void putVariableValue(java.lang.String variableName, IObject value, int fileIndex)
          Set the named variable to the specified value.
 void setEnclosingFunction(IFunction enclosingFunction)
          Sets the enclosing function of this object, or null if global
 void setParentScope(IScope parentScope)
          Sets the parent scope of this object
 void unputVariableName(java.lang.String variableName)
          Remove a reference to the specified variable name.
 
Methods inherited from class com.aptana.ide.editor.js.runtime.ObjectBase
canPut, containsOffset, deletePropertyName, getDocumentation, getEndingOffset, getInstance, getLength, getLocalProperty, getLocalPropertyCount, getLocalPropertyNames, getProperty, getPropertyNames, getPropertyNames, getPropertyValue, getPrototype, getRange, getStartingOffset, hasDocumentation, hasLocalProperty, hasProperty, isEmpty, putLocalProperty, putPropertyValue, putPropertyValue, setDocumentation, setPrototype, unputPropertyName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.aptana.ide.editor.js.runtime.IObject
canPut, deletePropertyName, getInstance, getLocalProperty, getLocalPropertyCount, getLocalPropertyNames, getProperty, getPropertyNames, getPropertyNames, getPropertyValue, getPrototype, hasLocalProperty, hasProperty, putLocalProperty, putPropertyValue, putPropertyValue, setPrototype, unputPropertyName
 
Methods inherited from interface com.aptana.ide.lexer.IRange
containsOffset, getEndingOffset, getLength, getStartingOffset, isEmpty
 
Methods inherited from interface com.aptana.ide.metadata.IDocumentationContainer
getDocumentation, hasDocumentation, setDocumentation
 

Field Detail

_parentScope

protected IScope _parentScope
This scope's parent scope

Constructor Detail

JSScope

public JSScope()
Method Detail

getClassName

public java.lang.String getClassName()
Description copied from interface: IObject
Returns the class name of this object. This implements [[Class]] from the ECMA specification

Specified by:
getClassName in interface IObject
Specified by:
getClassName in class ObjectBase
Returns:
This object's class name
See Also:
IObject.getClassName()

getLocalVariableNames

public java.lang.String[] getLocalVariableNames()
Description copied from interface: IScope
Get all variable names that exist on this scope only (does not follow scope chain)

Specified by:
getLocalVariableNames in interface IScope
Returns:
An array of variable names
See Also:
IScope.getLocalVariableNames()

getParentScope

public IScope getParentScope()
Description copied from interface: IScope
Returns the parent scope of this object.

Specified by:
getParentScope in interface IScope
Returns:
This object's parent scope
See Also:
IScope.getParentScope()

setParentScope

public void setParentScope(IScope parentScope)
Description copied from interface: IScope
Sets the parent scope of this object

Specified by:
setParentScope in interface IScope
Parameters:
parentScope - The new parent scope
See Also:
IScope.setParentScope(com.aptana.ide.editor.js.runtime.IScope)

getOwningScope

public IScope getOwningScope(java.lang.String variableName)
Description copied from interface: IScope
Returns the IScope object that holds the specified variable name

Specified by:
getOwningScope in interface IScope
Parameters:
variableName - The name of the variable to look up
Returns:
Returns the IScope object that contains the specified variable name
See Also:
IScope.getOwningScope(java.lang.String)

hasVariable

public boolean hasVariable(java.lang.String variableName)
Description copied from interface: IScope
Determine if the specified variable name is in the current scope chain

Specified by:
hasVariable in interface IScope
Parameters:
variableName - The name of the variable to look up
Returns:
Returns true if the variable exists in this scope object or in any of its ancestor scope objects
See Also:
IScope.hasVariable(java.lang.String)

getVariableValue

public IObject getVariableValue(java.lang.String variableName,
                                int fileIndex,
                                int offset)
Description copied from interface: IScope
Get the named variable. If necessary, the current scope chain will be traversed until either the scope is null or the identifier is located. This implements [[Scope]] from the ECMA specification

Specified by:
getVariableValue in interface IScope
Parameters:
variableName - The name of the variable to lookup in the current scope
fileIndex - The file index
offset - The file offset
Returns:
The value of the specified variable name
See Also:
IScope.getVariableValue(java.lang.String, int, int)

getVariable

public Property getVariable(java.lang.String variableName)
Description copied from interface: IScope
Get the Property object for the associated variable name

Specified by:
getVariable in interface IScope
Parameters:
variableName - The name of the Property to return
Returns:
The Property object associated with the specified name
See Also:
IScope.getVariable(java.lang.String)

getVariableReference

public Reference getVariableReference(java.lang.String variableName)
Description copied from interface: IScope
Get a reference object that points to the specified property name

Specified by:
getVariableReference in interface IScope
Parameters:
variableName - The name of the property to refer to
Returns:
Returns a reference object that points to the specified property name
See Also:
IScope.getVariableReference(java.lang.String)

getVariableNames

public java.lang.String[] getVariableNames()
Description copied from interface: IScope
Return all variable names in this scope and in all parent scopes.

Specified by:
getVariableNames in interface IScope
Returns:
An array of variable names
See Also:
IScope.getVariableNames()

putVariableValue

public void putVariableValue(java.lang.String variableName,
                             IObject value,
                             int fileIndex)
Description copied from interface: IScope
Set the named variable to the specified value. The scope chain will be traversed to locate

Specified by:
putVariableValue in interface IScope
Parameters:
variableName - The name of the variable to set
value - The value of the variable
fileIndex - The file index
See Also:
IScope.putVariableValue(java.lang.String, com.aptana.ide.editor.js.runtime.IObject, int)

unputVariableName

public void unputVariableName(java.lang.String variableName)
Description copied from interface: IScope
Remove a reference to the specified variable name. If the variable no longer has references, it will be removed from this scope

Specified by:
unputVariableName in interface IScope
Parameters:
variableName - The name of the variable to unput
See Also:
IScope.unputVariableName(java.lang.String)

getEnclosingFunction

public IFunction getEnclosingFunction()
Description copied from interface: IScope
Gets the enclosing function of this object, or null if global

Specified by:
getEnclosingFunction in interface IScope
Returns:
JSFunction
See Also:
IScope.getEnclosingFunction()

setEnclosingFunction

public void setEnclosingFunction(IFunction enclosingFunction)
Description copied from interface: IScope
Sets the enclosing function of this object, or null if global

Specified by:
setEnclosingFunction in interface IScope
See Also:
IScope.setEnclosingFunction(com.aptana.ide.editor.js.runtime.IFunction)