Change TokenKind's Print overload to a format_provider. (#2534)

Fundamentally this `.Print()` is wrong for debug output at present because `.fixed_spelling()` can be empty. It's also inconsistent with other enums to use it. We frequently print tokens for debugging, and it's easy to forget to specify `.name()` there.

Diagnostics use formatv, so we can provide a format_provider and address it in one spot that way. It also makes it harder to just forget to do the right thing.
This commit is contained in:
Jon Ross-Perkins
2023-01-18 12:20:56 -08:00
committed by GitHub
parent b936bf9e04
commit 94872ef6da
9 changed files with 36 additions and 37 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ auto ParseTree::PrintNode(llvm::raw_ostream& output, Node n, int depth,
if (preorder) {
output << "node_index: " << n << ", ";
}
output << "kind: '" << n_impl.kind.name() << "', text: '"
output << "kind: '" << n_impl.kind << "', text: '"
<< tokens_->GetTokenText(n_impl.token) << "'";
if (n_impl.has_error) {