Skip to content

Commit c90e451

Browse files
l46kokcopybara-github
authored andcommitted
Internal Changes
PiperOrigin-RevId: 788086447
1 parent 55662ab commit c90e451

29 files changed

Lines changed: 173 additions & 141 deletions

File tree

bundle/src/main/java/dev/cel/bundle/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ java_library(
6464
"//bundle:cel",
6565
"//checker:standard_decl",
6666
"//common:compiler_common",
67+
"//common:container",
6768
"//common:options",
6869
"//common:source",
6970
"//common/types",

bundle/src/main/java/dev/cel/bundle/CelEnvironment.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import dev.cel.checker.CelStandardDeclarations;
3131
import dev.cel.checker.CelStandardDeclarations.StandardFunction;
3232
import dev.cel.checker.CelStandardDeclarations.StandardOverload;
33+
import dev.cel.common.CelContainer;
3334
import dev.cel.common.CelFunctionDecl;
3435
import dev.cel.common.CelOptions;
3536
import dev.cel.common.CelOverloadDecl;
@@ -195,7 +196,7 @@ public CelCompiler extend(CelCompiler celCompiler, CelOptions celOptions)
195196
celCompiler
196197
.toCompilerBuilder()
197198
.setTypeProvider(celTypeProvider)
198-
.setContainer(container())
199+
.setContainer(CelContainer.ofName(container()))
199200
.addVarDeclarations(
200201
variables().stream()
201202
.map(v -> v.toCelVarDecl(celTypeProvider))
@@ -206,7 +207,7 @@ public CelCompiler extend(CelCompiler celCompiler, CelOptions celOptions)
206207
.collect(toImmutableList()));
207208

208209
if (!container().isEmpty()) {
209-
compilerBuilder.setContainer(container());
210+
compilerBuilder.setContainer(CelContainer.ofName(container()));
210211
}
211212

212213
addAllCompilerExtensions(compilerBuilder, celOptions);
@@ -240,8 +241,10 @@ private void addAllCompilerExtensions(
240241
for (ExtensionConfig extensionConfig : extensions()) {
241242
CanonicalCelExtension extension = getExtensionOrThrow(extensionConfig.name());
242243
if (extension.compilerExtensionProvider() != null) {
243-
CelCompilerLibrary celCompilerLibrary = extension.compilerExtensionProvider()
244-
.getCelCompilerLibrary(celOptions, extensionConfig.version());
244+
CelCompilerLibrary celCompilerLibrary =
245+
extension
246+
.compilerExtensionProvider()
247+
.getCelCompilerLibrary(celOptions, extensionConfig.version());
245248
celCompilerBuilder.addLibraries(celCompilerLibrary);
246249
}
247250
}
@@ -252,8 +255,10 @@ private void addAllRuntimeExtensions(CelRuntimeBuilder celRuntimeBuilder, CelOpt
252255
for (ExtensionConfig extensionConfig : extensions()) {
253256
CanonicalCelExtension extension = getExtensionOrThrow(extensionConfig.name());
254257
if (extension.runtimeExtensionProvider() != null) {
255-
CelRuntimeLibrary celRuntimeLibrary = extension.runtimeExtensionProvider()
256-
.getCelRuntimeLibrary(celOptions, extensionConfig.version());
258+
CelRuntimeLibrary celRuntimeLibrary =
259+
extension
260+
.runtimeExtensionProvider()
261+
.getCelRuntimeLibrary(celOptions, extensionConfig.version());
257262
celRuntimeBuilder.addLibraries(celRuntimeLibrary);
258263
}
259264
}
@@ -697,9 +702,7 @@ enum CanonicalCelExtension {
697702
SETS(
698703
(options, version) -> CelExtensions.sets(options),
699704
(options, version) -> CelExtensions.sets(options)),
700-
LISTS(
701-
(options, version) -> CelExtensions.lists(),
702-
(options, version) -> CelExtensions.lists());
705+
LISTS((options, version) -> CelExtensions.lists(), (options, version) -> CelExtensions.lists());
703706

704707
@SuppressWarnings("ImmutableEnumChecker")
705708
private final CompilerExtensionProvider compilerExtensionProvider;
@@ -737,8 +740,7 @@ RuntimeExtensionProvider runtimeExtensionProvider() {
737740
}
738741

739742
/**
740-
* LibrarySubset indicates a subset of the macros and function supported by a subsettable
741-
* library.
743+
* LibrarySubset indicates a subset of the macros and function supported by a subsettable library.
742744
*/
743745
@AutoValue
744746
public abstract static class LibrarySubset {
@@ -766,6 +768,7 @@ public abstract static class LibrarySubset {
766768
* IncludeFunctions specifies a set of functions to include in the subset.
767769
*
768770
* <p>Note: the overloads specified in the subset need only specify their ID.
771+
*
769772
* <p>Note: if IncludedFunctions is non-empty, then ExcludedFunctions is ignored.
770773
*/
771774
public abstract ImmutableSet<FunctionSelector> includedFunctions();

bundle/src/test/java/dev/cel/bundle/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ java_library(
2727
"//common:cel_ast",
2828
"//common:cel_source",
2929
"//common:compiler_common",
30+
"//common:container",
3031
"//common:error_codes",
3132
"//common:options",
3233
"//common:proto_ast",

bundle/src/test/java/dev/cel/bundle/CelImplTest.java

Lines changed: 38 additions & 36 deletions
Large diffs are not rendered by default.

checker/src/test/java/dev/cel/checker/CelProtoExprVisitorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import dev.cel.expr.Expr;
2222
import com.google.auto.value.AutoValue;
2323
import dev.cel.common.CelAbstractSyntaxTree;
24+
import dev.cel.common.CelContainer;
2425
import dev.cel.common.types.SimpleType;
2526
import dev.cel.compiler.CelCompiler;
2627
import dev.cel.compiler.CelCompilerFactory;
@@ -163,7 +164,7 @@ public void visitSelect() throws Exception {
163164
CelCompiler celCompiler =
164165
CelCompilerFactory.standardCelCompilerBuilder()
165166
.addMessageTypes(TestAllTypes.getDescriptor())
166-
.setContainer(TestAllTypes.getDescriptor().getFullName())
167+
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
167168
.build();
168169
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{}.single_int64").getAst();
169170

@@ -215,7 +216,7 @@ public void visitCreateStruct() throws Exception {
215216
CelCompiler celCompiler =
216217
CelCompilerFactory.standardCelCompilerBuilder()
217218
.addMessageTypes(TestAllTypes.getDescriptor())
218-
.setContainer(TestAllTypes.getDescriptor().getFullName())
219+
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
219220
.build();
220221
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{}").getAst();
221222

codelab/src/main/codelab/solutions/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ java_library(
1414
"//bundle:cel",
1515
"//common:cel_ast",
1616
"//common:compiler_common",
17+
"//common:container",
1718
"//common:proto_json_adapter",
1819
"//common/ast",
1920
"//common/navigation",

codelab/src/main/codelab/solutions/Exercise6.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.google.rpc.context.AttributeContext.Request;
1818
import dev.cel.common.CelAbstractSyntaxTree;
19+
import dev.cel.common.CelContainer;
1920
import dev.cel.common.CelValidationException;
2021
import dev.cel.common.types.SimpleType;
2122
import dev.cel.common.types.StructTypeReference;
@@ -44,7 +45,7 @@ final class Exercise6 {
4445
CelAbstractSyntaxTree compile(String expression) {
4546
CelCompiler celCompiler =
4647
CelCompilerFactory.standardCelCompilerBuilder()
47-
.setContainer("google.rpc.context.AttributeContext")
48+
.setContainer(CelContainer.ofName("google.rpc.context.AttributeContext"))
4849
.addVar("jwt", SimpleType.DYN)
4950
.addVar("now", SimpleType.TIMESTAMP)
5051
.addMessageTypes(Request.getDescriptor())

common/src/test/java/dev/cel/common/ast/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ java_library(
1414
"//:java_truth",
1515
"//common:cel_ast",
1616
"//common:compiler_common",
17+
"//common:container",
1718
"//common:mutable_ast",
1819
"//common:mutable_source",
1920
"//common:options",

common/src/test/java/dev/cel/common/ast/CelExprFormatterTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.testing.junit.testparameterinjector.TestParameter;
2020
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
2121
import dev.cel.common.CelAbstractSyntaxTree;
22+
import dev.cel.common.CelContainer;
2223
import dev.cel.common.CelFunctionDecl;
2324
import dev.cel.common.CelOptions;
2425
import dev.cel.common.CelOverloadDecl;
@@ -174,7 +175,7 @@ public void list() throws Exception {
174175
public void struct() throws Exception {
175176
CelCompiler celCompiler =
176177
CelCompilerFactory.standardCelCompilerBuilder()
177-
.setContainer("cel.expr.conformance.proto3")
178+
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
178179
.addMessageTypes(TestAllTypes.getDescriptor())
179180
.addLibraries(CelOptionalLibrary.INSTANCE)
180181
.build();
@@ -224,7 +225,7 @@ public void struct() throws Exception {
224225
public void map() throws Exception {
225226
CelCompiler celCompiler =
226227
CelCompilerFactory.standardCelCompilerBuilder()
227-
.setContainer("cel.expr.conformance.proto3")
228+
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
228229
.addMessageTypes(TestAllTypes.getDescriptor())
229230
.addLibraries(CelOptionalLibrary.INSTANCE)
230231
.build();

common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.auto.value.AutoValue;
2121
import com.google.common.collect.ImmutableList;
2222
import dev.cel.common.CelAbstractSyntaxTree;
23+
import dev.cel.common.CelContainer;
2324
import dev.cel.common.CelOptions;
2425
import dev.cel.common.ast.CelExpr.CelCall;
2526
import dev.cel.common.ast.CelExpr.CelComprehension;
@@ -195,7 +196,7 @@ public void visitSelect() throws Exception {
195196
CelCompiler celCompiler =
196197
CelCompilerFactory.standardCelCompilerBuilder()
197198
.addMessageTypes(TestAllTypes.getDescriptor())
198-
.setContainer(TestAllTypes.getDescriptor().getFullName())
199+
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
199200
.build();
200201
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{}.single_int64").getAst();
201202

@@ -246,9 +247,8 @@ public void visitCall() throws Exception {
246247
public void visitStruct_fieldkey() throws Exception {
247248
CelCompiler celCompiler =
248249
CelCompilerFactory.standardCelCompilerBuilder()
249-
250250
.addMessageTypes(TestAllTypes.getDescriptor())
251-
.setContainer(TestAllTypes.getDescriptor().getFullName())
251+
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
252252
.build();
253253
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{single_int64: 1}").getAst();
254254

0 commit comments

Comments
 (0)