Files
carbon-lang/toolchain/diagnostics/mocks.cpp
T
Jon Ross-Perkins 4421a75c36 file_name -> filename (#3791)
I wanted to choose one or the other. I think some code has been using
each from early on. We're predominately using `filename`, so
consolidating on that. This conveniently matches the [Google dev doc
style guide](https://developers.google.com/style/word-list#filename)
(which we use for docs) which says "filename: Not file name".

In toolchain:

```
╚╡git grep file_name . | wc -l
35
╚╡git grep filename . | wc -l
489
```
2024-03-18 17:26:24 +00:00

33 lines
970 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/diagnostics/mocks.h"
namespace Carbon {
void PrintTo(const Diagnostic& diagnostic, std::ostream* os) {
*os << "Diagnostic{" << diagnostic.message.kind << ", ";
PrintTo(diagnostic.level, os);
*os << ", " << diagnostic.message.location.filename << ":"
<< diagnostic.message.location.line_number << ":"
<< diagnostic.message.location.column_number << ", \""
<< diagnostic.message.format_fn(diagnostic.message) << "\"}";
}
void PrintTo(DiagnosticLevel level, std::ostream* os) {
switch (level) {
case DiagnosticLevel::Note:
*os << "Note";
break;
case DiagnosticLevel::Warning:
*os << "Warning";
break;
case DiagnosticLevel::Error:
*os << "Error";
break;
}
}
} // namespace Carbon