Class ObjectProperty

  • All Implemented Interfaces:
    java.lang.Comparable<AstNode>, java.lang.Iterable<Node>

    public class ObjectProperty
    extends InfixExpression
    AST node for a single name:value entry in an Object literal. For simple entries, the node type is Token.COLON, and the name (left side expression) is either a Name, a StringLiteral or a NumberLiteral.

    This node type is also used for getter/setter properties in object literals. In this case the node bounds include the "get" or "set" keyword. The left-hand expression in this case is always a Name, and the overall node type is Token.GET or Token.SET, as appropriate.

    The operatorPosition field is meaningless if the node is a getter or setter.

    ObjectProperty :
           PropertyName : AssignmentExpression
     PropertyName :
           Identifier
           StringLiteral
           NumberLiteral
    • Constructor Detail

      • ObjectProperty

        public ObjectProperty()
      • ObjectProperty

        public ObjectProperty​(int pos)
      • ObjectProperty

        public ObjectProperty​(int pos,
                              int len)
    • Method Detail

      • setNodeType

        public void setNodeType​(int nodeType)
        Sets the node type. Must be one of Token.COLON, Token.GET, or Token.SET.
        Throws:
        java.lang.IllegalArgumentException - if nodeType is invalid
      • setIsGetterMethod

        public void setIsGetterMethod()
        Marks this node as a "getter" property.
      • isGetterMethod

        public boolean isGetterMethod()
        Returns true if this is a getter function.
      • setIsSetterMethod

        public void setIsSetterMethod()
        Marks this node as a "setter" property.
      • isSetterMethod

        public boolean isSetterMethod()
        Returns true if this is a setter function.
      • setIsNormalMethod

        public void setIsNormalMethod()
      • isNormalMethod

        public boolean isNormalMethod()
      • isMethod

        public boolean isMethod()
      • toSource

        public java.lang.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.

        Overrides:
        toSource in class InfixExpression
        Parameters:
        depth - the current recursion depth, typically beginning at 0 when called on the root node.