| 1408 | } |
| 1409 | |
| 1410 | absl::optional<std::pair<int32_t, int32_t>> GetLocation(int64_t id) const { |
| 1411 | absl::optional<std::pair<int32_t, int32_t>> location; |
| 1412 | const auto& positions = source_info_.positions(); |
| 1413 | if (positions.find(id) == positions.end()) { |
| 1414 | return location; |
| 1415 | } |
| 1416 | int32_t pos = positions.at(id); |
| 1417 | |
| 1418 | int32_t line = 1; |
| 1419 | for (int i = 0; i < source_info_.line_offsets_size(); ++i) { |
| 1420 | if (source_info_.line_offsets(i) > pos) { |
| 1421 | break; |
| 1422 | } else { |
| 1423 | line += 1; |
| 1424 | } |
| 1425 | } |
| 1426 | int32_t col = pos; |
| 1427 | if (line > 1) { |
| 1428 | col = pos - source_info_.line_offsets(line - 2); |
| 1429 | } |
| 1430 | return std::make_pair(line, col); |
| 1431 | } |
| 1432 | |
| 1433 | const cel::expr::SourceInfo& source_info_; |
| 1434 | }; |
no test coverage detected