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

Function GetLineAndLineOffset

eval/public/source_position.cc:28–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace {
27
28std::pair<int, int32_t> GetLineAndLineOffset(const SourceInfo* source_info,
29 int32_t position) {
30 int line = 0;
31 int32_t line_offset = 0;
32 if (source_info != nullptr) {
33 for (const auto& curr_line_offset : source_info->line_offsets()) {
34 if (curr_line_offset > position) {
35 break;
36 }
37 line_offset = curr_line_offset;
38 line++;
39 }
40 }
41 if (line == 0) {
42 line++;
43 }
44 return std::pair<int, int32_t>(line, line_offset);
45}
46
47} // namespace
48

Callers 2

lineMethod · 0.85
columnMethod · 0.85

Calls 1

line_offsetsMethod · 0.80

Tested by

no test coverage detected