[fidlc] make error messages more editor friendly
Make them look like gcc/clang errors so editors and IDEs that
parse the error strings will correctly find and show them.
Test: build, manually verify error parseability
Change-Id: Ia8d9183f4e41c6c4f338ba149b64de075b38e1d9
diff --git a/system/host/fidl/lib/flat_ast.cpp b/system/host/fidl/lib/flat_ast.cpp
index d966a33..0d065d3 100644
--- a/system/host/fidl/lib/flat_ast.cpp
+++ b/system/host/fidl/lib/flat_ast.cpp
@@ -306,7 +306,9 @@
}
bool Library::Fail(const SourceLocation& location, StringView message) {
- auto formatted_message = location.position() + ": " + std::string(message) + "\n";
+ // Many editors and IDEs recognize errors in the form of
+ // filename:linenumber:column: error: descriptive-test-here\n
+ auto formatted_message = location.position() + ": error: " + std::string(message) + "\n";
error_reporter_->ReportError(std::move(formatted_message));
return false;
}
diff --git a/system/host/fidl/lib/parser.cpp b/system/host/fidl/lib/parser.cpp
index 812ad4e..c274ab3 100644
--- a/system/host/fidl/lib/parser.cpp
+++ b/system/host/fidl/lib/parser.cpp
@@ -101,10 +101,10 @@
squiggle.resize(line_size);
}
- std::string error = "found unexpected token in file ";
- error += token_location.source_file().filename();
- error += " on line " + line_number;
- error += " column " + column_number + ":\n";
+ // Many editors and IDEs recognize errors in the form of
+ // filename:linenumber:column: error: descriptive-test-here\n
+ std::string error = token_location.position();
+ error += ": error: found unexpected token\n";
error += surrounding_line;
error += squiggle + "\n";