Class CelAbstractSyntaxTree


  • @Immutable
    public final class CelAbstractSyntaxTree
    extends java.lang.Object
    Represents a checked or unchecked expression, its source, and related metadata such as source position information.

    Note: Use CelProtoAbstractSyntaxTree if you need access to the protobuf equivalent ASTs, such as ParsedExpr and CheckedExpr from syntax.proto or checked.proto.

    • Constructor Detail

      • CelAbstractSyntaxTree

        @Internal
        public CelAbstractSyntaxTree​(CelExpr celExpr,
                                     CelSource celSource)
        Internal: Consumers should not be creating an instance of this class directly.
      • CelAbstractSyntaxTree

        @Internal
        public CelAbstractSyntaxTree​(CelExpr celExpr,
                                     CelSource celSource,
                                     java.util.Map<java.lang.Long,​CelReference> references,
                                     java.util.Map<java.lang.Long,​CelType> types)
        Internal: Consumers should not be creating an instance of this class directly.
    • Method Detail

      • getProtoExpr

        @Deprecated
        @InlineMe(replacement="CelProtoAbstractSyntaxTree.fromCelAst(this).getExpr()",
                  imports="dev.cel.common.CelProtoAbstractSyntaxTree")
        public Expr getProtoExpr()
        Deprecated.
        Returns the underlying com.google.api.expr.Expr representation of the abstract syntax tree.
      • getExpr

        public CelExpr getExpr()
        Returns the underlying CelExpr representation of the abstract syntax tree.
      • isChecked

        public boolean isChecked()
        Tests whether the underlying abstract syntax tree has been type checked or not.
      • getResultType

        public CelType getResultType()
        For a type checked abstract syntax tree the resulting type is returned. Otherwise, the dynamic type is returned.
      • getProtoResultType

        public Type getProtoResultType()
        For a type checked abstract syntax tree the resulting type is returned in proto format described in checked.proto. Otherwise, the dynamic type is returned.
      • getSource

        public CelSource getSource()
        Returns the CelSource that was used during construction of the abstract syntax tree.
      • toParsedExpr

        @Deprecated
        @InlineMe(replacement="CelProtoAbstractSyntaxTree.fromCelAst(this).toParsedExpr()",
                  imports="dev.cel.common.CelProtoAbstractSyntaxTree")
        public ParsedExpr toParsedExpr()
        Returns the underlying com.google.api.expr.ParsedExpr representation of the abstract syntax tree.
      • toCheckedExpr

        @CheckReturnValue
        @Deprecated
        @InlineMe(replacement="CelProtoAbstractSyntaxTree.fromCelAst(this).toCheckedExpr()",
                  imports="dev.cel.common.CelProtoAbstractSyntaxTree")
        public CheckedExpr toCheckedExpr()
        Returns the underlying com.google.api.expr.CheckedExpr representation of the abstract syntax tree. Throws IllegalStateException if isChecked() is false.
      • getType

        public java.util.Optional<CelType> getType​(long exprId)
      • getTypeMap

        public com.google.common.collect.ImmutableMap<java.lang.Long,​CelType> getTypeMap()
      • getReference

        public java.util.Optional<CelReference> getReference​(long exprId)
      • getReferenceMap

        public com.google.common.collect.ImmutableMap<java.lang.Long,​CelReference> getReferenceMap()
      • getReferenceOrThrow

        public CelReference getReferenceOrThrow​(long exprId)