MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / CheckImpl

Function CheckImpl

conformance/service.cc:263–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263absl::Status CheckImpl(google::protobuf::Arena* arena,
264 const conformance::v1alpha1::CheckRequest& request,
265 conformance::v1alpha1::CheckResponse& response) {
266 cel::expr::ParsedExpr parsed_expr;
267
268 ABSL_CHECK(ConvertWireCompatProto(request.parsed_expr(), // Crash OK
269 &parsed_expr));
270
271 CEL_ASSIGN_OR_RETURN(std::unique_ptr<cel::Ast> ast,
272 cel::CreateAstFromParsedExpr(parsed_expr));
273
274 absl::string_view location = parsed_expr.source_info().location();
275 std::unique_ptr<cel::Source> source;
276 if (absl::StartsWith(location, "Source: ")) {
277 location = absl::StripPrefix(location, "Source: ");
278 CEL_ASSIGN_OR_RETURN(source, cel::NewSource(location));
279 }
280
281 CEL_ASSIGN_OR_RETURN(
282 std::unique_ptr<cel::TypeCheckerBuilder> builder,
283 cel::CreateTypeCheckerBuilder(google::protobuf::DescriptorPool::generated_pool()));
284
285 if (!request.no_std_env()) {
286 CEL_RETURN_IF_ERROR(builder->AddLibrary(cel::StandardCheckerLibrary()));
287 CEL_RETURN_IF_ERROR(builder->AddLibrary(cel::OptionalCheckerLibrary()));
288 CEL_RETURN_IF_ERROR(
289 builder->AddLibrary(cel::extensions::StringsCheckerLibrary()));
290 CEL_RETURN_IF_ERROR(
291 builder->AddLibrary(cel::extensions::MathCheckerLibrary()));
292 CEL_RETURN_IF_ERROR(
293 builder->AddLibrary(cel::extensions::EncodersCheckerLibrary()));
294 CEL_RETURN_IF_ERROR(
295 builder->AddLibrary(cel::extensions::ComprehensionsV2CheckerLibrary()));
296 }
297
298 for (const auto& decl : request.type_env()) {
299 const auto& name = decl.name();
300 if (decl.has_function()) {
301 CEL_ASSIGN_OR_RETURN(
302 auto fn_decl, cel::FunctionDeclFromV1Alpha1Proto(
303 name, decl.function(),
304 google::protobuf::DescriptorPool::generated_pool(), arena));
305 CEL_RETURN_IF_ERROR(builder->AddFunction(std::move(fn_decl)));
306 } else if (decl.has_ident()) {
307 CEL_ASSIGN_OR_RETURN(
308 auto var_decl, cel::VariableDeclFromV1Alpha1Proto(
309 name, decl.ident(),
310 google::protobuf::DescriptorPool::generated_pool(), arena));
311 CEL_RETURN_IF_ERROR(builder->AddVariable(std::move(var_decl)));
312 }
313 }
314 builder->set_container(request.container());
315
316 CEL_ASSIGN_OR_RETURN(auto checker, std::move(*builder).Build());
317
318 CEL_ASSIGN_OR_RETURN(auto validation_result, checker->Check(std::move(ast)));
319
320 for (const auto& checker_issue : validation_result.GetIssues()) {

Callers 2

CheckMethod · 0.85
CheckMethod · 0.85

Calls 15

ConvertWireCompatProtoFunction · 0.85
CreateTypeCheckerBuilderFunction · 0.85
StandardCheckerLibraryFunction · 0.85
OptionalCheckerLibraryFunction · 0.85
MathCheckerLibraryFunction · 0.85
EncodersCheckerLibraryFunction · 0.85
ToGrpcCodeFunction · 0.85
AstToCheckedExprFunction · 0.85
locationMethod · 0.80
source_infoMethod · 0.80
has_functionMethod · 0.80

Tested by

no test coverage detected