Package dev.cel.common
Class CelAbstractSyntaxTree
- java.lang.Object
-
- dev.cel.common.CelAbstractSyntaxTree
-
@Immutable public final class CelAbstractSyntaxTree extends java.lang.ObjectRepresents a checked or unchecked expression, its source, and related metadata such as source position information.Note: Use
CelProtoAbstractSyntaxTreeif you need access to the protobuf equivalent ASTs, such as ParsedExpr and CheckedExpr from syntax.proto or checked.proto.
-
-
Constructor Summary
Constructors Constructor Description CelAbstractSyntaxTree(CelExpr celExpr, CelSource celSource)Internal: Consumers should not be creating an instance of this class directly.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static CelAbstractSyntaxTreefromCheckedExpr(CheckedExpr checkedExpr)Deprecated.static CelAbstractSyntaxTreefromParsedExpr(ParsedExpr parsedExpr)Deprecated.CelExprgetExpr()Returns the underlyingCelExprrepresentation of the abstract syntax tree.ExprgetProtoExpr()Deprecated.UseCelProtoAbstractSyntaxTree.getExpr()instead.TypegetProtoResultType()For a type checked abstract syntax tree the resulting type is returned in proto format described in checked.proto.java.util.Optional<CelReference>getReference(long exprId)com.google.common.collect.ImmutableMap<java.lang.Long,CelReference>getReferenceMap()CelReferencegetReferenceOrThrow(long exprId)CelTypegetResultType()For a type checked abstract syntax tree the resulting type is returned.CelSourcegetSource()Returns theCelSourcethat was used during construction of the abstract syntax tree.java.util.Optional<CelType>getType(long exprId)com.google.common.collect.ImmutableMap<java.lang.Long,CelType>getTypeMap()booleanisChecked()Tests whether the underlying abstract syntax tree has been type checked or not.CheckedExprtoCheckedExpr()Deprecated.UseCelProtoAbstractSyntaxTree.toCheckedExpr()instead.ParsedExprtoParsedExpr()Deprecated.UseCelProtoAbstractSyntaxTree.toParsedExpr()} instead.
-
-
-
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.UseCelProtoAbstractSyntaxTree.getExpr()instead.Returns the underlyingcom.google.api.expr.Exprrepresentation of the abstract syntax tree.
-
getExpr
public CelExpr getExpr()
Returns the underlyingCelExprrepresentation 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 theCelSourcethat 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()Deprecated.UseCelProtoAbstractSyntaxTree.toParsedExpr()} instead.Returns the underlyingcom.google.api.expr.ParsedExprrepresentation of the abstract syntax tree.
-
toCheckedExpr
@CheckReturnValue @Deprecated @InlineMe(replacement="CelProtoAbstractSyntaxTree.fromCelAst(this).toCheckedExpr()", imports="dev.cel.common.CelProtoAbstractSyntaxTree") public CheckedExpr toCheckedExpr()Deprecated.UseCelProtoAbstractSyntaxTree.toCheckedExpr()instead.Returns the underlyingcom.google.api.expr.CheckedExprrepresentation of the abstract syntax tree. ThrowsIllegalStateExceptionifisChecked()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)
-
fromCheckedExpr
@Deprecated @InlineMe(replacement="CelProtoAbstractSyntaxTree.fromCheckedExpr(checkedExpr).getAst()", imports="dev.cel.common.CelProtoAbstractSyntaxTree") public static CelAbstractSyntaxTree fromCheckedExpr(CheckedExpr checkedExpr)Deprecated.Construct an abstract syntax tree from acom.google.api.expr.CheckedExpr.
-
fromParsedExpr
@Deprecated @InlineMe(replacement="CelProtoAbstractSyntaxTree.fromParsedExpr(parsedExpr).getAst()", imports="dev.cel.common.CelProtoAbstractSyntaxTree") public static CelAbstractSyntaxTree fromParsedExpr(ParsedExpr parsedExpr)Deprecated.Construct an abstract syntax tree from acom.google.api.expr.ParsedExpr.
-
-