1919import dev .cel .expr .Decl .FunctionDecl .Overload ;
2020import dev .cel .expr .Expr ;
2121import dev .cel .expr .Type ;
22- import com .google .common .annotations .VisibleForTesting ;
2322import com .google .common .base .Preconditions ;
2423import com .google .common .collect .ImmutableList ;
2524import com .google .common .collect .ImmutableMap ;
4342import dev .cel .common .types .CelKind ;
4443import dev .cel .common .types .CelProtoTypes ;
4544import dev .cel .common .types .CelType ;
45+ import dev .cel .common .types .CelTypeProvider ;
4646import dev .cel .common .types .CelTypes ;
47+ import dev .cel .common .types .ProtoMessageTypeProvider ;
4748import dev .cel .common .types .SimpleType ;
4849import dev .cel .parser .CelStandardMacro ;
4950import java .util .ArrayList ;
@@ -78,7 +79,7 @@ public class Env {
7879 CelFunctionDecl .newBuilder ().setName ("*error*" ).build ();
7980
8081 /** Type provider responsible for resolving CEL message references to strong types. */
81- private final TypeProvider typeProvider ;
82+ private final CelTypeProvider typeProvider ;
8283
8384 /**
8485 * Stack of declaration groups where each entry in stack represents a scope capable of hinding
@@ -105,7 +106,7 @@ public class Env {
105106 .build ();
106107
107108 private Env (
108- Errors errors , TypeProvider typeProvider , DeclGroup declGroup , CelOptions celOptions ) {
109+ Errors errors , CelTypeProvider typeProvider , DeclGroup declGroup , CelOptions celOptions ) {
109110 this .celOptions = celOptions ;
110111 this .errors = Preconditions .checkNotNull (errors );
111112 this .typeProvider = Preconditions .checkNotNull (typeProvider );
@@ -118,27 +119,10 @@ private Env(
118119 */
119120 @ Deprecated
120121 public static Env unconfigured (Errors errors ) {
121- return unconfigured (errors , LEGACY_TYPE_CHECKER_OPTIONS );
122+ return unconfigured (errors , new ProtoMessageTypeProvider (), LEGACY_TYPE_CHECKER_OPTIONS );
122123 }
123124
124- /**
125- * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
126- * operators with a reference to the configured {@code celOptions}.
127- */
128- @ VisibleForTesting
129- static Env unconfigured (Errors errors , CelOptions celOptions ) {
130- return unconfigured (errors , new DescriptorTypeProvider (), celOptions );
131- }
132-
133- /**
134- * Creates an unconfigured {@code Env} value without the standard CEL types, functions, and
135- * operators using a custom {@code typeProvider}.
136- *
137- * @deprecated Do not use. This exists for compatibility reasons. Migrate to CEL-Java fluent APIs.
138- * See {@code CelCompilerFactory}.
139- */
140- @ Deprecated
141- public static Env unconfigured (Errors errors , TypeProvider typeProvider , CelOptions celOptions ) {
125+ static Env unconfigured (Errors errors , CelTypeProvider typeProvider , CelOptions celOptions ) {
142126 return new Env (errors , typeProvider , new DeclGroup (), celOptions );
143127 }
144128
@@ -148,7 +132,7 @@ public static Env unconfigured(Errors errors, TypeProvider typeProvider, CelOpti
148132 */
149133 @ Deprecated
150134 public static Env standard (Errors errors ) {
151- return standard (errors , new DescriptorTypeProvider () );
135+ return standard (errors , new ProtoMessageTypeProvider (), LEGACY_TYPE_CHECKER_OPTIONS );
152136 }
153137
154138 /**
@@ -173,6 +157,11 @@ public static Env standard(Errors errors, TypeProvider typeProvider) {
173157 */
174158 @ Deprecated
175159 public static Env standard (Errors errors , TypeProvider typeProvider , CelOptions celOptions ) {
160+ CelTypeProvider adapted = new TypeProviderLegacyImpl (typeProvider );
161+ return standard (errors , adapted , celOptions );
162+ }
163+
164+ static Env standard (Errors errors , CelTypeProvider typeProvider , CelOptions celOptions ) {
176165 CelStandardDeclarations celStandardDeclaration =
177166 CelStandardDeclarations .newBuilder ()
178167 .filterFunctions (
@@ -209,10 +198,10 @@ public static Env standard(Errors errors, TypeProvider typeProvider, CelOptions
209198 return standard (celStandardDeclaration , errors , typeProvider , celOptions );
210199 }
211200
212- public static Env standard (
201+ static Env standard (
213202 CelStandardDeclarations celStandardDeclaration ,
214203 Errors errors ,
215- TypeProvider typeProvider ,
204+ CelTypeProvider typeProvider ,
216205 CelOptions celOptions ) {
217206 Env env = Env .unconfigured (errors , typeProvider , celOptions );
218207 // Isolate the standard declarations into their own scope for forward compatibility.
@@ -228,8 +217,8 @@ public Errors getErrorContext() {
228217 return errors ;
229218 }
230219
231- /** Returns the {@code TypeProvider }. */
232- public TypeProvider getTypeProvider () {
220+ /** Returns the {@code CelTypeProvider }. */
221+ public CelTypeProvider getTypeProvider () {
233222 return typeProvider ;
234223 }
235224
@@ -491,7 +480,7 @@ public Env add(String name, Type type) {
491480
492481 // Next try to import the name as a reference to a message type.
493482 // This is done via the type provider.
494- Optional <CelType > type = typeProvider .lookupCelType (cand );
483+ Optional <CelType > type = typeProvider .findType (cand );
495484 if (type .isPresent ()) {
496485 decl = CelIdentDecl .newIdentDeclaration (cand , type .get ());
497486 decls .get (0 ).putIdent (decl );
@@ -500,7 +489,8 @@ public Env add(String name, Type type) {
500489
501490 // Next try to import this as an enum value by splitting the name in a type prefix and
502491 // the enum inside.
503- Integer enumValue = typeProvider .lookupEnumValue (cand );
492+ // Integer enumValue = typeProvider.lookupEnumValue(cand);
493+ Integer enumValue = 0 ;
504494 if (enumValue != null ) {
505495 decl =
506496 CelIdentDecl .newBuilder ()
0 commit comments