Class CelMutableAst


  • public final class CelMutableAst
    extends java.lang.Object
    An abstract representation of CEL Abstract Syntax tree that allows mutation in any of its properties. This class is semantically the same as that of the immutable CelAbstractSyntaxTree.

    This should only be used within optimizers to augment an AST.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CelMutableExpr expr()
      Returns the underlying CelMutableExpr representation of the abstract syntax tree.
      static CelMutableAst fromCelAst​(dev.cel.common.CelAbstractSyntaxTree ast)
      Constructs an instance of CelMutableAst with the incoming CelAbstractSyntaxTree.
      java.util.Optional<dev.cel.common.ast.CelReference> getReference​(long exprId)
      Returns the resolved reference to a declaration at expression ID for a type-checked AST.
      java.util.Optional<dev.cel.common.types.CelType> getType​(long exprId)
      Returns the type of the expression node for a type-checked AST.
      static CelMutableAst of​(CelMutableExpr mutableExpr, CelMutableSource mutableSource)
      Constructs an instance of CelMutableAst with the mutable expression and its source builder.
      CelMutableSource source()
      Returns the CelMutableSource that was used during construction of the abstract syntax tree.
      dev.cel.common.CelAbstractSyntaxTree toParsedAst()
      Converts this mutable AST into a parsed CelAbstractSyntaxTree.
      dev.cel.common.CelAbstractSyntaxTree toParsedAst​(boolean retainSourcePositions)
      Converts this mutable AST into a parsed CelAbstractSyntaxTree.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getReference

        public java.util.Optional<dev.cel.common.ast.CelReference> getReference​(long exprId)
        Returns the resolved reference to a declaration at expression ID for a type-checked AST.
        Returns:
        Optional of CelReference or Optional.empty() if the reference does not exist at the ID.
      • getType

        public java.util.Optional<dev.cel.common.types.CelType> getType​(long exprId)
        Returns the type of the expression node for a type-checked AST.
        Returns:
        Optional of CelType or Optional.empty() if the type does not exist at the ID.
      • toParsedAst

        public dev.cel.common.CelAbstractSyntaxTree toParsedAst()
        Converts this mutable AST into a parsed CelAbstractSyntaxTree.
      • toParsedAst

        public dev.cel.common.CelAbstractSyntaxTree toParsedAst​(boolean retainSourcePositions)
        Converts this mutable AST into a parsed CelAbstractSyntaxTree.
        Parameters:
        retainSourcePositions - If true, the source positions (line offsets, code points) will be retained in the resulting AST. If false, they will be scrubbed.
      • fromCelAst

        public static CelMutableAst fromCelAst​(dev.cel.common.CelAbstractSyntaxTree ast)
        Constructs an instance of CelMutableAst with the incoming CelAbstractSyntaxTree.