com.google.javascript.jscomp
Class CallGraph.Function

java.lang.Object
  extended by com.google.javascript.jscomp.CallGraph.Function
Enclosing class:
CallGraph

public class CallGraph.Function
extends Object

An inner class that represents functions in the call graph. A Function knows how to get its AST node and what Callsites it contains.


Method Summary
 Node getAstNode()
          Returns the underlying AST node for the function.
 Node getBodyNode()
          Returns the AST node for the body of the function.
 Collection<CallGraph.Callsite> getCallsitesInFunction()
          Returns the callsites in this function.
 Collection<CallGraph.Callsite> getCallsitesPossiblyTargetingFunction()
          Returns a collection of callsites that might call this function.
 String getName()
          Gets the name of this function.
 boolean isAliased()
          Returns true if the function is aliased.
 boolean isExposedToCallOrApply()
          Returns true if the function is ever exposed to ".call" or ".apply".
 boolean isMain()
          Does this function represent the global "main" function?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isMain

public boolean isMain()
Does this function represent the global "main" function?


getAstNode

public Node getAstNode()
Returns the underlying AST node for the function. This usually has type Token.FUNCTION but in the case of the "main" function will have type Token.BLOCK.


getBodyNode

public Node getBodyNode()
Returns the AST node for the body of the function. If this function is the main function, it will return the global block.


getName

public String getName()
Gets the name of this function. Returns null if the function is anonymous.


getCallsitesInFunction

public Collection<CallGraph.Callsite> getCallsitesInFunction()
Returns the callsites in this function.


getCallsitesPossiblyTargetingFunction

public Collection<CallGraph.Callsite> getCallsitesPossiblyTargetingFunction()
Returns a collection of callsites that might call this function. getCallsitesPossiblyTargetingFunction() is a best effort only: the collection may include callsites that do not actually call this function and if this function is exported or aliased may be missing actual targets. This method should not be called on a Function from a CallGraph that was constructed with computeBackwardGraph false.


isAliased

public boolean isAliased()
Returns true if the function is aliased.


isExposedToCallOrApply

public boolean isExposedToCallOrApply()
Returns true if the function is ever exposed to ".call" or ".apply".