[command_args] Properly set file and line in dict
The if statement was preventing *any* files from being output in the
json. It's better to simply output the blank file string with the line
number (in the dotfile).
Change-Id: I57df561a095588a187c9b2757d417c3da4b2eab5
Reviewed-on: https://gn-review.googlesource.com/2100
Reviewed-by: Brett Wilson <brettw@chromium.org>
Commit-Queue: Brett Wilson <brettw@chromium.org>
diff --git a/tools/gn/command_args.cc b/tools/gn/command_args.cc
index 4e3a43f..9980333 100644
--- a/tools/gn/command_args.cc
+++ b/tools/gn/command_args.cc
@@ -181,11 +181,8 @@
std::string location, comment;
GetContextForValue(arg.override_value, &location, &line_no, &comment,
/*pad_comment=*/false);
- // Omit file and line if set with --args (i.e. no file)
- if (!location.empty()) {
- override_dict.SetKey("file", base::Value(location));
- override_dict.SetKey("line", base::Value(line_no));
- }
+ override_dict.SetKey("file", base::Value(location));
+ override_dict.SetKey("line", base::Value(line_no));
}
dict.SetKey("current", std::move(override_dict));
}
@@ -199,11 +196,8 @@
std::string location;
GetContextForValue(arg.default_value, &location, &line_no, &comment,
/*pad_comment=*/false);
- // Only emit file and line if the value is overridden.
- if (arg.has_override) {
- default_dict.SetKey("file", base::Value(location));
- default_dict.SetKey("line", base::Value(line_no));
- }
+ default_dict.SetKey("file", base::Value(location));
+ default_dict.SetKey("line", base::Value(line_no));
}
dict.SetKey("default", std::move(default_dict));
if (!comment.empty() && !short_only)