1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- package dev .cel .common . ast ;
15+ package dev .cel .common ;
1616
17- import dev .cel .common .CelAbstractSyntaxTree ;
18- import dev .cel .common .CelSource ;
17+ import dev .cel .common .ast .CelMutableExpr ;
18+ import dev .cel .common .ast .CelMutableExprConverter ;
19+ import dev .cel .common .ast .CelReference ;
1920import dev .cel .common .types .CelType ;
2021import java .util .HashMap ;
2122import java .util .Map ;
3031 */
3132public final class CelMutableAst {
3233 private final CelMutableExpr mutatedExpr ;
33- private final CelSource . Builder source ;
34+ private final CelMutableSource source ;
3435 private final Map <Long , CelReference > references ;
3536 private final Map <Long , CelType > types ;
3637
@@ -40,9 +41,10 @@ public CelMutableExpr expr() {
4041 }
4142
4243 /**
43- * Returns the {@link CelSource} that was used during construction of the abstract syntax tree.
44+ * Returns the {@link CelMutableSource} that was used during construction of the abstract syntax
45+ * tree.
4446 */
45- public CelSource . Builder source () {
47+ public CelMutableSource source () {
4648 return source ;
4749 }
4850
@@ -69,7 +71,7 @@ public Optional<CelType> getType(long exprId) {
6971 /** Converts this mutable AST into a parsed {@link CelAbstractSyntaxTree}. */
7072 public CelAbstractSyntaxTree toParsedAst () {
7173 return CelAbstractSyntaxTree .newParsedAst (
72- CelMutableExprConverter .fromMutableExpr (mutatedExpr ), source .build ());
74+ CelMutableExprConverter .fromMutableExpr (mutatedExpr ), source .toCelSource ());
7375 }
7476
7577 /**
@@ -79,7 +81,7 @@ public CelAbstractSyntaxTree toParsedAst() {
7981 public static CelMutableAst fromCelAst (CelAbstractSyntaxTree ast ) {
8082 return new CelMutableAst (
8183 CelMutableExprConverter .fromCelExpr (ast .getExpr ()),
82- ast .getSource (). toBuilder ( ),
84+ CelMutableSource . fromCelSource ( ast .getSource ()),
8385 ast .getReferenceMap (),
8486 ast .getTypeMap ());
8587 }
@@ -88,21 +90,21 @@ public static CelMutableAst fromCelAst(CelAbstractSyntaxTree ast) {
8890 * Constructs an instance of {@link CelMutableAst} with the mutable expression and its source
8991 * builder.
9092 */
91- public static CelMutableAst of (CelMutableExpr mutableExpr , CelSource . Builder sourceBuilder ) {
92- return new CelMutableAst (mutableExpr , sourceBuilder );
93+ public static CelMutableAst of (CelMutableExpr mutableExpr , CelMutableSource mutableSource ) {
94+ return new CelMutableAst (mutableExpr , mutableSource );
9395 }
9496
95- private CelMutableAst (CelMutableExpr mutatedExpr , CelSource . Builder source ) {
96- this (mutatedExpr , source , new HashMap <>(), new HashMap <>());
97+ private CelMutableAst (CelMutableExpr mutatedExpr , CelMutableSource mutableSource ) {
98+ this (mutatedExpr , mutableSource , new HashMap <>(), new HashMap <>());
9799 }
98100
99101 private CelMutableAst (
100102 CelMutableExpr mutatedExpr ,
101- CelSource . Builder source ,
103+ CelMutableSource mutableSource ,
102104 Map <Long , CelReference > references ,
103105 Map <Long , CelType > types ) {
104106 this .mutatedExpr = mutatedExpr ;
105- this .source = source ;
107+ this .source = mutableSource ;
106108 this .references = new HashMap <>(references );
107109 this .types = new HashMap <>(types );
108110 }
0 commit comments