Rename DiagnosticLocationTranslator -> DiagnosticConverter (#3804)

Since the addition of TranslateArg, I don't think this type is going to
go away (cutting a TODO). Refactoring names slightly to fit the current
role, and adding const to ConvertLocation.
This commit is contained in:
Jon Ross-Perkins
2024-03-21 23:35:04 +00:00
committed by GitHub
parent 033c68c45b
commit 0bd45f0d6b
22 changed files with 204 additions and 211 deletions
+4 -4
View File
@@ -345,8 +345,8 @@ auto TokenIterator::Print(llvm::raw_ostream& output) const -> void {
output << token_.index;
}
auto TokenizedBuffer::SourceBufferLocationTranslator::GetLocation(
const char* loc) -> DiagnosticLocation {
auto TokenizedBuffer::SourceBufferDiagnosticConverter::ConvertLocation(
const char* loc) const -> DiagnosticLocation {
CARBON_CHECK(StringRefContainsPointer(buffer_->source_->text(), loc))
<< "location not within buffer";
int64_t offset = loc - buffer_->source_->text().begin();
@@ -390,7 +390,7 @@ auto TokenizedBuffer::SourceBufferLocationTranslator::GetLocation(
.column_number = column_number + 1};
}
auto TokenLocationTranslator::GetLocation(TokenIndex token)
auto TokenDiagnosticConverter::ConvertLocation(TokenIndex token) const
-> DiagnosticLocation {
// Map the token location into a position within the source buffer.
const auto& token_info = buffer_->GetTokenInfo(token);
@@ -402,7 +402,7 @@ auto TokenLocationTranslator::GetLocation(TokenIndex token)
// TODO: Should we somehow indicate in the diagnostic location if this token
// is a recovery token that doesn't correspond to the original source?
DiagnosticLocation loc =
TokenizedBuffer::SourceBufferLocationTranslator(buffer_).GetLocation(
TokenizedBuffer::SourceBufferDiagnosticConverter(buffer_).ConvertLocation(
token_start);
loc.length = buffer_->GetTokenText(token).size();
return loc;