Class FunctionCall

All Implemented Interfaces:
Comparable<AstNode>, Iterable<Node>
Direct Known Subclasses:
NewExpression

public class FunctionCall extends AstNode
AST node for a function call. Node type is Token.CALL.
  • Field Details

    • NO_ARGS

      protected static final List<AstNode> NO_ARGS
    • target

      protected AstNode target
    • arguments

      protected List<AstNode> arguments
    • lp

      protected int lp
    • rp

      protected int rp
    • optionalCall

      protected boolean optionalCall
  • Constructor Details

    • FunctionCall

      public FunctionCall()
    • FunctionCall

      public FunctionCall(int pos)
    • FunctionCall

      public FunctionCall(int pos, int len)
  • Method Details

    • getTarget

      public AstNode getTarget()
      Returns node evaluating to the function to call
    • setTarget

      public void setTarget(AstNode target)
      Sets node evaluating to the function to call, and sets its parent to this node.
      Parameters:
      target - node evaluating to the function to call.
      Throws:
      IllegalArgumentException - } if target is null
    • getArguments

      public List<AstNode> getArguments()
      Returns function argument list
      Returns:
      function argument list, or an empty immutable list if there are no arguments.
    • setArguments

      public void setArguments(List<AstNode> arguments)
      Sets function argument list
      Parameters:
      arguments - function argument list. Can be null, in which case any existing args are removed.
    • addArgument

      public void addArgument(AstNode arg)
      Adds an argument to the list, and sets its parent to this node.
      Parameters:
      arg - the argument node to add to the list
      Throws:
      IllegalArgumentException - } if arg is null
    • getLp

      public int getLp()
      Returns left paren position, -1 if missing
    • setLp

      public void setLp(int lp)
      Sets left paren position
      Parameters:
      lp - left paren position
    • getRp

      public int getRp()
      Returns right paren position, -1 if missing
    • setRp

      public void setRp(int rp)
      Sets right paren position
    • setParens

      public void setParens(int lp, int rp)
      Sets both paren positions
    • markIsOptionalCall

      public void markIsOptionalCall()
      Marks that the call is preceded by the optional chaining operator ?.
    • isOptionalCall

      public boolean isOptionalCall()
      Returns whether the call is preceded by the optional chaining operator ?.
    • toSource

      public String toSource(int depth)
      Description copied from class: AstNode
      Emits source code for this node. Callee is responsible for calling this function recursively on children, incrementing indent as appropriate.

      Note: if the parser was in error-recovery mode, some AST nodes may have null children that are expected to be non-null when no errors are present. In this situation, the behavior of the toSource method is undefined: toSource implementations may assume that the AST node is error-free, since it is intended to be invoked only at runtime after a successful parse.

      Specified by:
      toSource in class AstNode
      Parameters:
      depth - the current recursion depth, typically beginning at 0 when called on the root node.
    • visit

      public void visit(NodeVisitor v)
      Visits this node, the target object, and the arguments.
      Specified by:
      visit in class AstNode
      Parameters:
      v - the object to call with this node and its children