|
34 | 34 | #include "absl/memory/memory.h" |
35 | 35 | #include "absl/status/status.h" |
36 | 36 | #include "absl/status/statusor.h" |
| 37 | +#include "absl/strings/match.h" |
37 | 38 | #include "absl/strings/str_cat.h" |
38 | 39 | #include "absl/strings/string_view.h" |
| 40 | +#include "absl/strings/strip.h" |
39 | 41 | #include "absl/types/optional.h" |
40 | 42 | #include "absl/types/span.h" |
41 | 43 | #include "checker/optional.h" |
@@ -623,6 +625,13 @@ class ModernConformanceServiceImpl : public ConformanceServiceInterface { |
623 | 625 | CEL_ASSIGN_OR_RETURN(std::unique_ptr<cel::Ast> ast, |
624 | 626 | cel::extensions::CreateAstFromParsedExpr(parsed_expr)); |
625 | 627 |
|
| 628 | + absl::string_view location = parsed_expr.source_info().location(); |
| 629 | + std::unique_ptr<cel::Source> source; |
| 630 | + if (absl::StartsWith(location, "Source: ")) { |
| 631 | + location = absl::StripPrefix(location, "Source: "); |
| 632 | + CEL_ASSIGN_OR_RETURN(source, cel::NewSource(location)); |
| 633 | + } |
| 634 | + |
626 | 635 | cel::TypeCheckerBuilder builder; |
627 | 636 |
|
628 | 637 | builder.AddTypeProvider( |
@@ -672,7 +681,11 @@ class ModernConformanceServiceImpl : public ConformanceServiceInterface { |
672 | 681 | for (const auto& checker_issue : validation_result.GetIssues()) { |
673 | 682 | auto* issue = response.add_issues(); |
674 | 683 | issue->set_code(ToGrpcCode(absl::StatusCode::kInvalidArgument)); |
675 | | - issue->set_message(checker_issue.message()); |
| 684 | + if (source) { |
| 685 | + issue->set_message(checker_issue.ToDisplayString(*source)); |
| 686 | + } else { |
| 687 | + issue->set_message(checker_issue.message()); |
| 688 | + } |
676 | 689 | } |
677 | 690 |
|
678 | 691 | const cel::Ast* checked_ast = validation_result.GetAst(); |
|
0 commit comments