mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:11:12 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user