Add aliasing support to type-checker by copybara-service[bot] · Pull Request #757 · cel-expr/cel-java · GitHub
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
12 changes: 10 additions & 2 deletions bundle/src/main/java/dev/cel/bundle/CelBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.protobuf.Message;
import dev.cel.checker.ProtoTypeMask;
import dev.cel.checker.TypeProvider;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelVarDecl;
Expand Down Expand Up @@ -81,12 +82,19 @@ public interface CelBuilder {
CelBuilder addMacros(Iterable<CelMacro> macros);

/**
* Set the {@code container} name to use as the namespace for resolving CEL expression variables
* and functions.
* @deprecated Use {@link #setContainer(CelContainer)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
CelBuilder setContainer(String container);

/**
* Set the {@link CelContainer} to use as the namespace for resolving CEL expression variables and
* functions.
*/
@CanIgnoreReturnValue
CelBuilder setContainer(CelContainer container);

/** Add a variable declaration with a given {@code name} and {@link Type}. */
@CanIgnoreReturnValue
CelBuilder addVar(String name, Type type);
Expand Down
7 changes: 7 additions & 0 deletions bundle/src/main/java/dev/cel/bundle/CelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import dev.cel.checker.ProtoTypeMask;
import dev.cel.checker.TypeProvider;
import dev.cel.common.CelAbstractSyntaxTree;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelSource;
Expand Down Expand Up @@ -194,6 +195,12 @@ public CelBuilder setContainer(String container) {
return this;
}

@Override
public CelBuilder setContainer(CelContainer container) {
compilerBuilder.setContainer(container);
return this;
}

@Override
public CelBuilder addVar(String name, Type type) {
compilerBuilder.addVar(name, type);
Expand Down
3 changes: 3 additions & 0 deletions checker/src/main/java/dev/cel/checker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ java_library(
"//common:cel_descriptors",
"//common:cel_source",
"//common:compiler_common",
"//common:container",
"//common:options",
"//common:source_location",
"//common/annotations",
Expand Down Expand Up @@ -104,6 +105,7 @@ java_library(
":standard_decl",
"//common:cel_ast",
"//common:compiler_common",
"//common:container",
"//common:options",
"//common/types:type_providers",
"@cel_spec//proto/cel/expr:checked_java_proto",
Expand Down Expand Up @@ -175,6 +177,7 @@ java_library(
"//:auto_value",
"//common:cel_ast",
"//common:compiler_common",
"//common:container",
"//common:options",
"//common:proto_ast",
"//common/annotations",
Expand Down
12 changes: 10 additions & 2 deletions checker/src/main/java/dev/cel/checker/CelCheckerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.protobuf.DescriptorProtos.FileDescriptorSet;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FileDescriptor;
import dev.cel.common.CelContainer;
import dev.cel.common.CelFunctionDecl;
import dev.cel.common.CelOptions;
import dev.cel.common.CelVarDecl;
Expand All @@ -35,12 +36,19 @@ public interface CelCheckerBuilder {
CelCheckerBuilder setOptions(CelOptions options);

/**
* Set the {@code container} name to use as the namespace for resolving CEL expression variables
* and functions.
* @deprecated Use {@link #setContainer(CelContainer)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
CelCheckerBuilder setContainer(String container);

/**
* Set the {@link CelContainer} to use as the namespace for resolving CEL expression variables and
* functions.
*/
@CanIgnoreReturnValue
CelCheckerBuilder setContainer(CelContainer container);

/** Add variable and function {@code declarations} to the CEL environment. */
@CanIgnoreReturnValue
CelCheckerBuilder addDeclarations(Decl... declarations);
Expand Down
86 changes: 51 additions & 35 deletions checker/src/main/java/dev/cel/checker/CelCheckerLegacyImpl.java
Loading
Loading