1919import dev .cel .expr .Decl .FunctionDecl .Overload ;
2020import dev .cel .expr .Expr ;
2121import dev .cel .expr .Type ;
22+ import com .google .common .annotations .VisibleForTesting ;
2223import com .google .common .base .Preconditions ;
2324import com .google .common .collect .ImmutableList ;
2425import com .google .common .collect .ImmutableMap ;
3233import dev .cel .common .CelFunctionDecl ;
3334import dev .cel .common .CelOptions ;
3435import dev .cel .common .CelOverloadDecl ;
35- import dev .cel .common .ExprFeatures ;
3636import dev .cel .common .annotations .Internal ;
3737import dev .cel .common .ast .CelConstant ;
3838import dev .cel .common .ast .CelExpr ;
@@ -97,6 +97,12 @@ public class Env {
9797 /** CEL Feature flags. */
9898 private final CelOptions celOptions ;
9999
100+ private static final CelOptions LEGACY_TYPE_CHECKER_OPTIONS =
101+ CelOptions .newBuilder ()
102+ .disableCelStandardEquality (false )
103+ .enableNamespacedDeclarations (false )
104+ .build ();
105+
100106 private Env (
101107 Errors errors , TypeProvider typeProvider , DeclGroup declGroup , CelOptions celOptions ) {
102108 this .celOptions = celOptions ;
@@ -106,111 +112,51 @@ private Env(
106112 }
107113
108114 /**
109- * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
110- * operators with a reference to the feature flags enabled in the environment.
111- *
112- * @deprecated use {@code unconfigured} with {@code CelOptions} instead.
113- */
114- @ Deprecated
115- public static Env unconfigured (Errors errors , ExprFeatures ... exprFeatures ) {
116- return unconfigured (errors , new DescriptorTypeProvider (), ImmutableSet .copyOf (exprFeatures ));
117- }
118-
119- /**
120- * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
121- * operators using a custom {@code typeProvider}.
122- *
123- * @deprecated use {@code unconfigured} with {@code CelOptions} instead.
124- */
125- @ Deprecated
126- public static Env unconfigured (
127- Errors errors , TypeProvider typeProvider , ExprFeatures ... exprFeatures ) {
128- return unconfigured (errors , typeProvider , ImmutableSet .copyOf (exprFeatures ));
129- }
130-
131- /**
132- * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
133- * operators using a custom {@code typeProvider}. The set of enabled {@code exprFeatures} is also
134- * provided.
135- *
136- * @deprecated use {@code unconfigured} with {@code CelOptions} instead.
115+ * @deprecated Do not use. This exists for compatibility reasons. Migrate to CEL-Java fluent APIs.
116+ * See {@code CelCompilerFactory}.
137117 */
138118 @ Deprecated
139- public static Env unconfigured (
140- Errors errors , TypeProvider typeProvider , ImmutableSet <ExprFeatures > exprFeatures ) {
141- return unconfigured (errors , typeProvider , CelOptions .fromExprFeatures (exprFeatures ));
119+ public static Env unconfigured (Errors errors ) {
120+ return unconfigured (errors , LEGACY_TYPE_CHECKER_OPTIONS );
142121 }
143122
144123 /**
145124 * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
146125 * operators with a reference to the configured {@code celOptions}.
147126 */
148- public static Env unconfigured (Errors errors , CelOptions celOptions ) {
127+ @ VisibleForTesting
128+ static Env unconfigured (Errors errors , CelOptions celOptions ) {
149129 return unconfigured (errors , new DescriptorTypeProvider (), celOptions );
150130 }
151131
152132 /**
153133 * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
154- * operators using a custom {@code typeProvider}. The {@code CelOptions} are provided as well.
155- */
156- public static Env unconfigured (Errors errors , TypeProvider typeProvider , CelOptions celOptions ) {
157- return new Env (errors , typeProvider , new DeclGroup (), celOptions );
158- }
159-
160- /**
161- * Creates an {@code Env} value configured with the standard types, functions, and operators with
162- * a reference to the set of {@code exprFeatures} enabled in the environment.
163- *
164- * <p>Note: standard declarations are configured in an isolated scope, and may be shadowed by
165- * subsequent declarations.
134+ * operators using a custom {@code typeProvider}.
166135 *
167- * @deprecated use {@code standard} with {@code CelOptions} instead.
136+ * @deprecated Do not use. This exists for compatibility reasons. Migrate to CEL-Java fluent APIs.
137+ * See {@code CelCompilerFactory}.
168138 */
169139 @ Deprecated
170- public static Env standard (Errors errors , ExprFeatures ... exprFeatures ) {
171- return standard (errors , new DescriptorTypeProvider (), exprFeatures );
140+ public static Env unconfigured (Errors errors , TypeProvider typeProvider , CelOptions celOptions ) {
141+ return new Env (errors , typeProvider , new DeclGroup (), celOptions );
172142 }
173143
174144 /**
175- * Creates an {@code Env} value configured with the standard types, functions, and operators,
176- * configured with a custom {@code typeProvider}.
177- *
178- * <p>Note: standard declarations are configured in an isolated scope, and may be shadowed by
179- * subsequent declarations with the same signature.
180- *
181- * @deprecated use {@code standard} with {@code CelOptions} instead.
145+ * @deprecated Do not use. This exists for compatibility reasons. Migrate to CEL-Java fluent APIs.
146+ * See {@code CelCompilerFactory}.
182147 */
183148 @ Deprecated
184- public static Env standard (
185- Errors errors , TypeProvider typeProvider , ExprFeatures ... exprFeatures ) {
186- return standard (errors , typeProvider , ImmutableSet .copyOf (exprFeatures ));
149+ public static Env standard (Errors errors ) {
150+ return standard (errors , new DescriptorTypeProvider ());
187151 }
188152
189153 /**
190- * Creates an {@code Env} value configured with the standard types, functions, and operators,
191- * configured with a custom {@code typeProvider} and a reference to the set of {@code
192- * exprFeatures} enabled in the environment.
193- *
194- * <p>Note: standard declarations are configured in an isolated scope, and may be shadowed by
195- * subsequent declarations with the same signature.
196- *
197- * @deprecated use {@code standard} with {@code CelOptions} instead.
154+ * @deprecated Do not use. This exists for compatibility reasons. Migrate to CEL-Java fluent APIs.
155+ * See {@code CelCompilerFactory}.
198156 */
199157 @ Deprecated
200- public static Env standard (
201- Errors errors , TypeProvider typeProvider , ImmutableSet <ExprFeatures > exprFeatures ) {
202- return standard (errors , typeProvider , CelOptions .fromExprFeatures (exprFeatures ));
203- }
204-
205- /**
206- * Creates an {@code Env} value configured with the standard types, functions, and operators and a
207- * reference to the configured {@code celOptions}.
208- *
209- * <p>Note: standard declarations are configured in an isolated scope, and may be shadowed by
210- * subsequent declarations with the same signature.
211- */
212- public static Env standard (Errors errors , CelOptions celOptions ) {
213- return standard (errors , new DescriptorTypeProvider (), celOptions );
158+ public static Env standard (Errors errors , TypeProvider typeProvider ) {
159+ return standard (errors , typeProvider , LEGACY_TYPE_CHECKER_OPTIONS );
214160 }
215161
216162 /**
@@ -220,7 +166,11 @@ public static Env standard(Errors errors, CelOptions celOptions) {
220166 *
221167 * <p>Note: standard declarations are configured in an isolated scope, and may be shadowed by
222168 * subsequent declarations with the same signature.
169+ *
170+ * @deprecated Do not use. This exists for compatibility reasons. Migrate to CEL-Java fluent APIs.
171+ * See {@code CelCompilerFactory}.
223172 */
173+ @ Deprecated
224174 public static Env standard (Errors errors , TypeProvider typeProvider , CelOptions celOptions ) {
225175 CelStandardDeclarations celStandardDeclaration =
226176 CelStandardDeclarations .newBuilder ()
0 commit comments