Package dev.cel.common
Class CelAbstractSyntaxTree
- java.lang.Object
-
- dev.cel.common.CelAbstractSyntaxTree
-
@Immutable public abstract 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 Summary
Constructors Constructor Description CelAbstractSyntaxTree()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CelExpr
getExpr()
Returns the underlyingCelExpr
representation of the abstract syntax tree.java.util.Optional<CelReference>
getReference(long exprId)
com.google.common.collect.ImmutableMap<java.lang.Long,CelReference>
getReferenceMap()
CelReference
getReferenceOrThrow(long exprId)
CelType
getResultType()
For a type checked abstract syntax tree the resulting type is returned.CelSource
getSource()
Returns theCelSource
that 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()
boolean
isChecked()
Tests whether the underlying abstract syntax tree has been type checked or not.static CelAbstractSyntaxTree
newCheckedAst(CelExpr celExpr, CelSource celSource, java.util.Map<java.lang.Long,CelReference> references, java.util.Map<java.lang.Long,CelType> types)
Constructs a new instance of CelAbstractSyntaxTree that represent a checked expression.static CelAbstractSyntaxTree
newParsedAst(CelExpr celExpr, CelSource celSource)
Constructs a new instance of CelAbstractSyntaxTree that represent a parsed expression.
-
-
-
Method Detail
-
newParsedAst
public static CelAbstractSyntaxTree newParsedAst(CelExpr celExpr, CelSource celSource)
Constructs a new instance of CelAbstractSyntaxTree that represent a parsed expression.Note that ASTs should not be manually constructed except for special circumstances such as validating or optimizing an AST.
-
newCheckedAst
@Internal public static CelAbstractSyntaxTree newCheckedAst(CelExpr celExpr, CelSource celSource, java.util.Map<java.lang.Long,CelReference> references, java.util.Map<java.lang.Long,CelType> types)
Constructs a new instance of CelAbstractSyntaxTree that represent a checked expression.CEL Library Internals. Do not construct a type-checked AST by hand. Use a CelCompiler to type-check a parsed AST instead.
-
getExpr
public CelExpr getExpr()
Returns the underlyingCelExpr
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.
-
getSource
public CelSource getSource()
Returns theCelSource
that was used during construction of the abstract syntax tree.
-
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)
-
-