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

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

public class JSFunction
extends FunctionBase

Author:
Robin Debreuil, Kevin Lindsey

Field Summary
 
Fields inherited from class com.aptana.ide.editor.js.runtime.FunctionBase
EmptyArgs
 
Fields inherited from class com.aptana.ide.editor.js.runtime.ObjectBase
NULL, UNDEFINED
 
Constructor Summary
JSFunction()
          Create a new instance of JSFunction
JSFunction(IRange sourceRegion)
          Create a new instance of JSFunction
 
Method Summary
 IObject construct(Environment environment, IObject[] arguments, int fileIndex, IRange sourceRegion)
          Creates an instance of this native type from a function instance, and sets the appropriate prototype for it.
 IScope getBodyScope()
          Get the scope used for the body of this function
 java.lang.String getClassName()
          Returns the class name of this object.
 JSObject getGuessedMemberObject()
          Gets the guessed object that is the prototype for this member.
 java.lang.String getMemberOf()
           
 java.lang.String[] getParameterNames()
          Return a string array of the parameters for this IFunction
 IObject invoke(Environment environment, IObject[] arguments, int fileIndex, IRange sourceRegion)
          Invoke this method with the specified parameters
 void setBodyScope(IScope scope)
          Set the scope used for the body of this function
 void setGuessedMemberObject(JSObject classObject)
          Sets the guessed object that is the prototype for this member.
 void setParameterNames(java.lang.String[] parameters)
          Set the parameter names used to define this IFunction
 void setParameters(java.lang.String[] parameters)
          Set the list of parameters for this function
 
Methods inherited from class com.aptana.ide.editor.js.runtime.FunctionBase
getInvokeTypeProvider, setInvokeTypeProvider
 
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
 

Constructor Detail

JSFunction

public JSFunction()
Create a new instance of JSFunction


JSFunction

public JSFunction(IRange sourceRegion)
Create a new instance of JSFunction

Parameters:
sourceRegion - The region in the source file that defines this object instance
Method Detail

getBodyScope

public IScope getBodyScope()
Get the scope used for the body of this function

Returns:
This function body's scope object

setBodyScope

public void setBodyScope(IScope scope)
Set the scope used for the body of this function

Parameters:
scope - The new function body scope

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
Overrides:
getClassName in class FunctionBase
Returns:
This object's class name
See Also:
FunctionBase.getClassName()

setParameterNames

public void setParameterNames(java.lang.String[] parameters)
Description copied from interface: IFunction
Set the parameter names used to define this IFunction

Parameters:
parameters - A string array of parameters names
See Also:
IFunction.setParameterNames(java.lang.String[])

getParameterNames

public java.lang.String[] getParameterNames()
Description copied from interface: IFunction
Return a string array of the parameters for this IFunction

Specified by:
getParameterNames in interface IFunction
Overrides:
getParameterNames in class FunctionBase
Returns:
Returns a string array of parameter names
See Also:
FunctionBase.getParameterNames()

construct

public IObject construct(Environment environment,
                         IObject[] arguments,
                         int fileIndex,
                         IRange sourceRegion)
Creates an instance of this native type from a function instance, and sets the appropriate prototype for it.

Specified by:
construct in interface IFunction
Specified by:
construct in class FunctionBase
Parameters:
environment - The environment
arguments - The arguments to use in constructing the new object.
fileIndex - The file index
sourceRegion - The region of source code that is constructing this new instance
Returns:
Returns a JSObject instance of this type.
See Also:
IFunction.construct(com.aptana.ide.editor.js.runtime.Environment, com.aptana.ide.editor.js.runtime.IObject[], int, IRange)

invoke

public IObject invoke(Environment environment,
                      IObject[] arguments,
                      int fileIndex,
                      IRange sourceRegion)
Description copied from interface: IFunction
Invoke this method with the specified parameters

Specified by:
invoke in interface IFunction
Specified by:
invoke in class FunctionBase
arguments - The arguments to use in constructing the new object.
fileIndex - The file index
sourceRegion - The region of text within the source file that represents the construction of this instance
Returns:
Returns a newly constructed object.
See Also:
FunctionBase.invoke(com.aptana.ide.editor.js.runtime.Environment, com.aptana.ide.editor.js.runtime.IObject[], int, IRange)

setParameters

public void setParameters(java.lang.String[] parameters)
Set the list of parameters for this function

Parameters:
parameters -

getMemberOf

public java.lang.String getMemberOf()
Returns:
Returns the dotted name of the class that this function belongs to (based on docs), or null.

getGuessedMemberObject

public JSObject getGuessedMemberObject()
Gets the guessed object that is the prototype for this member. This can be assigned to when seeing patterns such as xx.prototype.fn(){}. Docs (@memberOf) will always override this guess.

Returns:
Gets the guessed object that is the prototype for this member.

setGuessedMemberObject

public void setGuessedMemberObject(JSObject classObject)
Sets the guessed object that is the prototype for this member. This can be assigned to when seeing patterns such as xx.prototype.fn(){}. Docs (@memberOf) will always override this guess.

Parameters:
classObject -