| 499 | } |
| 500 | |
| 501 | absl::optional<std::string> Source::Snippet(int32_t line) const { |
| 502 | auto content = this->content(); |
| 503 | auto start = FindLinePosition(line); |
| 504 | if (ABSL_PREDICT_FALSE(!start.has_value() || content.empty())) { |
| 505 | return absl::nullopt; |
| 506 | } |
| 507 | auto end = FindLinePosition(line + 1); |
| 508 | if (end.has_value()) { |
| 509 | return content.ToString(*start, *end - 1); |
| 510 | } |
| 511 | return content.ToString(*start); |
| 512 | } |
| 513 | |
| 514 | std::string Source::DisplayErrorLocation(SourceLocation location) const { |
| 515 | constexpr char32_t kDot = '.'; |
no test coverage detected