mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
Source: Restructure Source::File
Add Source::FileContent to hold the file source content and per-line data. Have Source hold an optional pointer to a FileContent, and add a file_path field. This allows us to kill the `FreeInternalCompilerErrors()` filth as we're now able to construct Sources that hold a file path without file content. Change-Id: I03556795d7d4161c3d34cef32cb685c45ad04a3d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42026 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
41e58d89ea
commit
1d98236770
@@ -160,12 +160,12 @@ void Formatter::format(const Diagnostic& diag, State& state) const {
|
||||
std::vector<TextAndColor> prefix;
|
||||
prefix.reserve(6);
|
||||
|
||||
if (style_.print_file && src.file != nullptr && !src.file->path.empty()) {
|
||||
if (style_.print_file && !src.file_path.empty()) {
|
||||
if (rng.begin.line > 0) {
|
||||
prefix.emplace_back(TextAndColor{src.file->path + ":" + to_str(rng.begin),
|
||||
prefix.emplace_back(TextAndColor{src.file_path + ":" + to_str(rng.begin),
|
||||
Color::kDefault});
|
||||
} else {
|
||||
prefix.emplace_back(TextAndColor{src.file->path, Color::kDefault});
|
||||
prefix.emplace_back(TextAndColor{src.file_path, Color::kDefault});
|
||||
}
|
||||
} else if (rng.begin.line > 0) {
|
||||
prefix.emplace_back(TextAndColor{to_str(rng.begin), Color::kDefault});
|
||||
@@ -208,15 +208,15 @@ void Formatter::format(const Diagnostic& diag, State& state) const {
|
||||
}
|
||||
state << diag.message;
|
||||
|
||||
if (style_.print_line && src.file != nullptr && rng.begin.line > 0) {
|
||||
if (style_.print_line && src.file_content != nullptr && rng.begin.line > 0) {
|
||||
state.newline();
|
||||
state.set_style({Color::kDefault, false});
|
||||
|
||||
for (size_t line = rng.begin.line; line <= rng.end.line; line++) {
|
||||
if (line < src.file->lines.size() + 1) {
|
||||
auto len = src.file->lines[line - 1].size();
|
||||
if (line < src.file_content->lines.size() + 1) {
|
||||
auto len = src.file_content->lines[line - 1].size();
|
||||
|
||||
state << src.file->lines[line - 1];
|
||||
state << src.file_content->lines[line - 1];
|
||||
|
||||
state.newline();
|
||||
state.set_style({Color::kCyan, false});
|
||||
|
||||
Reference in New Issue
Block a user