aboutsummaryrefslogtreecommitdiff
path: root/src/google
diff options
context:
space:
mode:
authorkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-04-05 21:45:45 +0000
committerkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2010-04-05 21:45:45 +0000
commit6793c1af264cf3a85bfa74006baf291f2f9be16e (patch)
tree27434786b811949c82a473e87cbac34e5520c956 /src/google
parenteeb8fd7dc845693fdb4e61a6031c658f8592e05e (diff)
downloadprotobuf-6793c1af264cf3a85bfa74006baf291f2f9be16e.tar.gz
protobuf-6793c1af264cf3a85bfa74006baf291f2f9be16e.tar.bz2
protobuf-6793c1af264cf3a85bfa74006baf291f2f9be16e.zip
Use full paths when writing MSVS-style errors. Patch from Oleg Smolsky.
Diffstat (limited to 'src/google')
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc16
-rw-r--r--src/google/protobuf/compiler/command_line_interface_unittest.cc2
2 files changed, 14 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index d3495ca6..02c3e0f9 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -182,14 +182,23 @@ bool TryCreateParentDirectory(const string& prefix, const string& filename) {
class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
public io::ErrorCollector {
public:
- ErrorPrinter(ErrorFormat format) : format_(format) {}
+ ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL)
+ : format_(format), tree_(tree) {}
~ErrorPrinter() {}
// implements MultiFileErrorCollector ------------------------------
void AddError(const string& filename, int line, int column,
const string& message) {
- cerr << filename;
+ // Print full path when running under MSVS
+ std::string dfile;
+ if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&
+ tree_ != NULL &&
+ tree_->VirtualFileToDiskFile(filename, &dfile)) {
+ cerr << dfile;
+ } else {
+ cerr << filename;
+ }
// Users typically expect 1-based line/column numbers, so we add 1
// to each here.
@@ -215,6 +224,7 @@ class CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,
private:
const ErrorFormat format_;
+ DiskSourceTree *tree_;
};
// -------------------------------------------------------------------
@@ -583,7 +593,7 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
}
// Allocate the Importer.
- ErrorPrinter error_collector(error_format_);
+ ErrorPrinter error_collector(error_format_, &source_tree);
Importer importer(&source_tree, &error_collector);
vector<const FileDescriptor*> parsed_files;
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc
index 9129ebf0..bdf37ad1 100644
--- a/src/google/protobuf/compiler/command_line_interface_unittest.cc
+++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -1153,7 +1153,7 @@ TEST_F(CommandLineInterfaceTest, MsvsFormatErrors) {
"--proto_path=$tmpdir --error_format=msvs foo.proto");
ExpectErrorText(
- "foo.proto(2) : error in column=1: Expected top-level statement "
+ "$tmpdir/foo.proto(2) : error in column=1: Expected top-level statement "
"(e.g. \"message\").\n");
}