Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundle/src/main/java/dev/cel/bundle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ java_library(
"//bundle:cel",
"//checker:standard_decl",
"//common:compiler_common",
"//common:container",
"//common:options",
"//common:source",
"//common/types",
Expand Down
25 changes: 14 additions & 11 deletions bundle/src/main/java/dev/cel/bundle/CelEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import dev.cel.checker.CelStandardDeclarations;
import dev.cel.checker.CelStandardDeclarations.StandardFunction;
import dev.cel.checker.CelStandardDeclarations.StandardOverload;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelOverloadDecl;
Expand Down Expand Up @@ -195,7 +196,7 @@ public CelCompiler extend(CelCompiler celCompiler, CelOptions celOptions)
celCompiler
.toCompilerBuilder()
.setTypeProvider(celTypeProvider)
.setContainer(container())
.setContainer(CelContainer.ofName(container()))
.addVarDeclarations(
variables().stream()
.map(v -> v.toCelVarDecl(celTypeProvider))
Expand All @@ -206,7 +207,7 @@ public CelCompiler extend(CelCompiler celCompiler, CelOptions celOptions)
.collect(toImmutableList()));

if (!container().isEmpty()) {
compilerBuilder.setContainer(container());
compilerBuilder.setContainer(CelContainer.ofName(container()));
}

addAllCompilerExtensions(compilerBuilder, celOptions);
Expand Down Expand Up @@ -240,8 +241,10 @@ private void addAllCompilerExtensions(
for (ExtensionConfig extensionConfig : extensions()) {
CanonicalCelExtension extension = getExtensionOrThrow(extensionConfig.name());
if (extension.compilerExtensionProvider() != null) {
CelCompilerLibrary celCompilerLibrary = extension.compilerExtensionProvider()
.getCelCompilerLibrary(celOptions, extensionConfig.version());
CelCompilerLibrary celCompilerLibrary =
extension
.compilerExtensionProvider()
.getCelCompilerLibrary(celOptions, extensionConfig.version());
celCompilerBuilder.addLibraries(celCompilerLibrary);
}
}
Expand All @@ -252,8 +255,10 @@ private void addAllRuntimeExtensions(CelRuntimeBuilder celRuntimeBuilder, CelOpt
for (ExtensionConfig extensionConfig : extensions()) {
CanonicalCelExtension extension = getExtensionOrThrow(extensionConfig.name());
if (extension.runtimeExtensionProvider() != null) {
CelRuntimeLibrary celRuntimeLibrary = extension.runtimeExtensionProvider()
.getCelRuntimeLibrary(celOptions, extensionConfig.version());
CelRuntimeLibrary celRuntimeLibrary =
extension
.runtimeExtensionProvider()
.getCelRuntimeLibrary(celOptions, extensionConfig.version());
celRuntimeBuilder.addLibraries(celRuntimeLibrary);
}
}
Expand Down Expand Up @@ -697,9 +702,7 @@ enum CanonicalCelExtension {
SETS(
(options, version) -> CelExtensions.sets(options),
(options, version) -> CelExtensions.sets(options)),
LISTS(
(options, version) -> CelExtensions.lists(),
(options, version) -> CelExtensions.lists());
LISTS((options, version) -> CelExtensions.lists(), (options, version) -> CelExtensions.lists());

@SuppressWarnings("ImmutableEnumChecker")
private final CompilerExtensionProvider compilerExtensionProvider;
Expand Down Expand Up @@ -737,8 +740,7 @@ RuntimeExtensionProvider runtimeExtensionProvider() {
}

/**
* LibrarySubset indicates a subset of the macros and function supported by a subsettable
* library.
* LibrarySubset indicates a subset of the macros and function supported by a subsettable library.
*/
@AutoValue
public abstract static class LibrarySubset {
Expand Down Expand Up @@ -766,6 +768,7 @@ public abstract static class LibrarySubset {
* IncludeFunctions specifies a set of functions to include in the subset.
*
* <p>Note: the overloads specified in the subset need only specify their ID.
*
* <p>Note: if IncludedFunctions is non-empty, then ExcludedFunctions is ignored.
*/
public abstract ImmutableSet<FunctionSelector> includedFunctions();
Expand Down
1 change: 1 addition & 0 deletions bundle/src/test/java/dev/cel/bundle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ java_library(
"//common:cel_ast",
"//common:cel_source",
"//common:compiler_common",
"//common:container",
"//common:error_codes",
"//common:options",
"//common:proto_ast",
Expand Down
74 changes: 38 additions & 36 deletions bundle/src/test/java/dev/cel/bundle/CelImplTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import dev.cel.expr.Expr;
import com.google.auto.value.AutoValue;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.types.SimpleType;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
Expand Down Expand Up @@ -163,7 +164,7 @@ public void visitSelect() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer(TestAllTypes.getDescriptor().getFullName())
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
.build();
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{}.single_int64").getAst();

Expand Down Expand Up @@ -215,7 +216,7 @@ public void visitCreateStruct() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer(TestAllTypes.getDescriptor().getFullName())
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
.build();
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{}").getAst();

Expand Down
1 change: 1 addition & 0 deletions codelab/src/main/codelab/solutions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
"//bundle:cel",
"//common:cel_ast",
"//common:compiler_common",
"//common:container",
"//common:proto_json_adapter",
"//common/ast",
"//common/navigation",
Expand Down
3 changes: 2 additions & 1 deletion codelab/src/main/codelab/solutions/Exercise6.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.google.rpc.context.AttributeContext.Request;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelValidationException;
import dev.cel.common.types.SimpleType;
import dev.cel.common.types.StructTypeReference;
Expand Down Expand Up @@ -44,7 +45,7 @@ final class Exercise6 {
CelAbstractSyntaxTree compile(String expression) {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.setContainer("google.rpc.context.AttributeContext")
.setContainer(CelContainer.ofName("google.rpc.context.AttributeContext"))
.addVar("jwt", SimpleType.DYN)
.addVar("now", SimpleType.TIMESTAMP)
.addMessageTypes(Request.getDescriptor())
Expand Down
1 change: 1 addition & 0 deletions common/src/test/java/dev/cel/common/ast/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
"//:java_truth",
"//common:cel_ast",
"//common:compiler_common",
"//common:container",
"//common:mutable_ast",
"//common:mutable_source",
"//common:options",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.testing.junit.testparameterinjector.TestParameter;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelOverloadDecl;
Expand Down Expand Up @@ -174,7 +175,7 @@ public void list() throws Exception {
public void struct() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.addMessageTypes(TestAllTypes.getDescriptor())
.addLibraries(CelOptionalLibrary.INSTANCE)
.build();
Expand Down Expand Up @@ -224,7 +225,7 @@ public void struct() throws Exception {
public void map() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.addMessageTypes(TestAllTypes.getDescriptor())
.addLibraries(CelOptionalLibrary.INSTANCE)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelOptions;
import dev.cel.common.ast.CelExpr.CelCall;
import dev.cel.common.ast.CelExpr.CelComprehension;
Expand Down Expand Up @@ -195,7 +196,7 @@ public void visitSelect() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer(TestAllTypes.getDescriptor().getFullName())
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
.build();
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{}.single_int64").getAst();

Expand Down Expand Up @@ -246,9 +247,8 @@ public void visitCall() throws Exception {
public void visitStruct_fieldkey() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()

.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer(TestAllTypes.getDescriptor().getFullName())
.setContainer(CelContainer.ofName(TestAllTypes.getDescriptor().getFullName()))
.build();
CelAbstractSyntaxTree ast = celCompiler.compile("TestAllTypes{single_int64: 1}").getAst();

Expand Down
1 change: 1 addition & 0 deletions common/src/test/java/dev/cel/common/navigation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ java_library(
"//:java_truth",
"//common:cel_ast",
"//common:compiler_common",
"//common:container",
"//common:mutable_ast",
"//common:options",
"//common/ast",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import com.google.testing.junit.testparameterinjector.TestParameters;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelOptions;
import dev.cel.common.ast.CelConstant;
import dev.cel.common.ast.CelExpr;
Expand Down Expand Up @@ -580,7 +581,7 @@ public void messageConstruction_allNodesReturned() throws Exception {
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand All @@ -603,7 +604,7 @@ public void messageConstruction_filterStruct_allNodesReturned() throws Exception
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand Down Expand Up @@ -631,7 +632,7 @@ public void messageConstruction_preOrder_heightSet() throws Exception {
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand All @@ -651,7 +652,7 @@ public void messageConstruction_postOrder_heightSet() throws Exception {
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand All @@ -672,7 +673,7 @@ public void messageConstruction_maxIdsSet(@TestParameter TraversalOrder traversa
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand Down
1 change: 1 addition & 0 deletions conformance/src/test/java/dev/cel/conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ java_library(
"//:java_truth",
"//checker:checker_builder",
"//common:compiler_common",
"//common:container",
"//common:options",
"//common/types:cel_proto_types",
"//compiler",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import dev.cel.checker.CelChecker;
import dev.cel.common.CelContainer;
import dev.cel.common.CelOptions;
import dev.cel.common.CelValidationResult;
import dev.cel.common.types.CelProtoTypes;
Expand Down Expand Up @@ -100,7 +101,7 @@ private static CelChecker getChecker(SimpleTest test) throws Exception {
}
return CelCompilerFactory.standardCelCheckerBuilder()
.setOptions(OPTIONS)
.setContainer(test.getContainer())
.setContainer(CelContainer.ofName(test.getContainer()))
.addDeclarations(decls.build())
.addFileTypes(dev.cel.expr.conformance.proto2.TestAllTypesExtensions.getDescriptor())
.addLibraries(
Expand Down
1 change: 1 addition & 0 deletions extensions/src/test/java/dev/cel/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ java_library(
"//bundle:cel",
"//common:cel_ast",
"//common:compiler_common",
"//common:container",
"//common:options",
"//common/internal:proto_time_utils",
"//common/types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import dev.cel.bundle.CelBuilder;
import dev.cel.bundle.CelFactory;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelOverloadDecl;
Expand Down Expand Up @@ -96,7 +97,7 @@ private static CelBuilder newCelBuilder() {
return CelFactory.standardCelBuilder()
.setOptions(CelOptions.current().enableTimestampEpoch(true).build())
.setStandardMacros(CelStandardMacro.STANDARD_MACROS)
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.addMessageTypes(TestAllTypes.getDescriptor())
.addRuntimeLibraries(CelOptionalLibrary.INSTANCE)
.addCompilerLibraries(CelOptionalLibrary.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import dev.cel.bundle.Cel;
import dev.cel.bundle.CelFactory;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOverloadDecl;
import dev.cel.common.CelValidationException;
Expand Down Expand Up @@ -55,7 +56,7 @@ public final class CelProtoExtensionsTest {
.setStandardMacros(CelStandardMacro.STANDARD_MACROS)
.addFileTypes(TestAllTypesExtensions.getDescriptor())
.addVar("msg", StructTypeReference.create("cel.expr.conformance.proto2.TestAllTypes"))
.setContainer("cel.expr.conformance.proto2")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto2"))
.build();

private static final CelRuntime CEL_RUNTIME =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import com.google.testing.junit.testparameterinjector.TestParameters;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelOverloadDecl;
Expand All @@ -47,7 +48,7 @@ public final class CelSetsExtensionsTest {
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setOptions(CEL_OPTIONS)
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.addLibraries(CelExtensions.sets(CEL_OPTIONS))
.addVar("list", ListType.create(SimpleType.INT))
.addVar("subList", ListType.create(SimpleType.INT))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import dev.cel.bundle.Cel;
import dev.cel.bundle.CelFactory;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelMutableAst;
import dev.cel.common.CelOptions;
Expand Down Expand Up @@ -64,7 +65,7 @@ public class AstMutatorTest {
.addMessageTypes(TestAllTypes.getDescriptor())
.addCompilerLibraries(CelOptionalLibrary.INSTANCE, CelExtensions.bindings())
.addRuntimeLibraries(CelOptionalLibrary.INSTANCE)
.setContainer("cel.expr.conformance.proto3")
.setContainer(CelContainer.ofName("cel.expr.conformance.proto3"))
.addVar("msg", StructTypeReference.create(TestAllTypes.getDescriptor().getFullName()))
.addVar("x", SimpleType.INT)
.build();
Expand Down
1 change: 1 addition & 0 deletions optimizer/src/test/java/dev/cel/optimizer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ java_library(
"//common:cel_ast",
"//common:cel_source",
"//common:compiler_common",
"//common:container",
"//common:mutable_ast",
"//common:options",
"//common/ast",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
"//common:cel_ast",
"//common:cel_source",
"//common:compiler_common",
"//common:container",
"//common:mutable_ast",
"//common:options",
"//common/ast",
Expand Down
Loading
Loading