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

Method FindLine

common/source.cc:569–586  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569absl::optional<std::pair<int32_t, SourcePosition>> Source::FindLine(
570 SourcePosition position) const {
571 if (ABSL_PREDICT_FALSE(position < 0)) {
572 return absl::nullopt;
573 }
574 int32_t line = 1;
575 const auto line_offsets = this->line_offsets();
576 for (const auto& line_offset : line_offsets) {
577 if (line_offset > position) {
578 break;
579 }
580 ++line;
581 }
582 if (line == 1) {
583 return std::make_pair(line, SourcePosition{0});
584 }
585 return std::make_pair(line, line_offsets[static_cast<size_t>(line) - 2]);
586}
587
588absl::StatusOr<absl_nonnull SourcePtr> NewSource(absl::string_view content,
589 std::string description) {

Callers

nothing calls this directly

Calls 1

line_offsetsMethod · 0.80

Tested by

no test coverage detected