Package dev.cel.common
Class CelMutableAst
- java.lang.Object
-
- dev.cel.common.CelMutableAst
-
public final class CelMutableAst extends java.lang.ObjectAn 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 immutableCelAbstractSyntaxTree.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 CelMutableExprexpr()Returns the underlyingCelMutableExprrepresentation of the abstract syntax tree.static CelMutableAstfromCelAst(dev.cel.common.CelAbstractSyntaxTree ast)Constructs an instance ofCelMutableAstwith the incomingCelAbstractSyntaxTree.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 CelMutableAstof(CelMutableExpr mutableExpr, CelMutableSource mutableSource)Constructs an instance ofCelMutableAstwith the mutable expression and its source builder.CelMutableSourcesource()Returns theCelMutableSourcethat was used during construction of the abstract syntax tree.dev.cel.common.CelAbstractSyntaxTreetoParsedAst()Converts this mutable AST into a parsedCelAbstractSyntaxTree.dev.cel.common.CelAbstractSyntaxTreetoParsedAst(boolean retainSourcePositions)Converts this mutable AST into a parsedCelAbstractSyntaxTree.
-
-
-
Method Detail
-
expr
public CelMutableExpr expr()
Returns the underlyingCelMutableExprrepresentation of the abstract syntax tree.
-
source
public CelMutableSource source()
Returns theCelMutableSourcethat was used during construction of the abstract syntax tree.
-
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
CelReferenceorOptional.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
CelTypeorOptional.empty()if the type does not exist at the ID.
-
toParsedAst
public dev.cel.common.CelAbstractSyntaxTree toParsedAst()
Converts this mutable AST into a parsedCelAbstractSyntaxTree.
-
toParsedAst
public dev.cel.common.CelAbstractSyntaxTree toParsedAst(boolean retainSourcePositions)
Converts this mutable AST into a parsedCelAbstractSyntaxTree.- 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 ofCelMutableAstwith the incomingCelAbstractSyntaxTree.
-
of
public static CelMutableAst of(CelMutableExpr mutableExpr, CelMutableSource mutableSource)
Constructs an instance ofCelMutableAstwith the mutable expression and its source builder.
-
-