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

Method FindLinePosition

common/source.cc:555–567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555absl::optional<SourcePosition> Source::FindLinePosition(int32_t line) const {
556 if (ABSL_PREDICT_FALSE(line < 1)) {
557 return absl::nullopt;
558 }
559 if (line == 1) {
560 return SourcePosition{0};
561 }
562 const auto line_offsets = this->line_offsets();
563 if (ABSL_PREDICT_TRUE(line <= static_cast<int32_t>(line_offsets.size()))) {
564 return line_offsets[static_cast<size_t>(line - 2)];
565 }
566 return absl::nullopt;
567}
568
569absl::optional<std::pair<int32_t, SourcePosition>> Source::FindLine(
570 SourcePosition position) const {

Callers

nothing calls this directly

Calls 2

line_offsetsMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected