Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Unified Diff: tools/gn/visibility.cc

Issue 306013007: Minor improvements to GN's "desc" output. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/visibility.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/visibility.cc
diff --git a/tools/gn/visibility.cc b/tools/gn/visibility.cc
index 41bfc63f412ef9a9734768be90bbd20071b41c79..6fc8fa125dc89eff85c630619acc263d332deb2f 100644
--- a/tools/gn/visibility.cc
+++ b/tools/gn/visibility.cc
@@ -97,28 +97,40 @@ bool Visibility::CanSeeMe(const Label& label) const {
return false;
}
-std::string Visibility::Describe() const {
+std::string Visibility::Describe(int indent, bool include_brackets) const {
+ std::string outer_indent_string(indent, ' ');
+
if (patterns_.empty())
- return std::string("[] (no visibility)");
- std::string result = "[\n";
+ return outer_indent_string + "[] (no visibility)\n";
+
+ std::string result;
+
+ std::string inner_indent_string = outer_indent_string;
+ if (include_brackets) {
+ result += outer_indent_string + "[\n";
+ // Indent the insides more if brackets are requested.
+ inner_indent_string += " ";
+ }
for (size_t i = 0; i < patterns_.size(); i++) {
switch (patterns_[i].type()) {
case VisPattern::MATCH:
- result += " " + patterns_[i].dir().value() + ":" +
+ result += inner_indent_string +
+ DirectoryWithNoLastSlash(patterns_[i].dir()) + ":" +
patterns_[i].name() + "\n";
break;
case VisPattern::DIRECTORY:
- result += " " + DirectoryWithNoLastSlash(patterns_[i].dir()) +
- ":*\n";
+ result += inner_indent_string +
+ DirectoryWithNoLastSlash(patterns_[i].dir()) + ":*\n";
break;
case VisPattern::RECURSIVE_DIRECTORY:
- result += " " + patterns_[i].dir().value() + "*\n";
+ result += inner_indent_string + patterns_[i].dir().value() + "*\n";
break;
}
}
- result += "]";
+ if (include_brackets)
+ result += outer_indent_string + "]\n";
return result;
}
@@ -244,7 +256,7 @@ bool Visibility::CheckItemVisibility(const Item* from,
"The item " + from->label().GetUserVisibleName(false) + "\n"
"can not depend on " + to_label + "\n"
"because it is not in " + to_label + "'s visibility list: " +
- to->visibility().Describe());
+ to->visibility().Describe(0, true));
return false;
}
return true;
« no previous file with comments | « tools/gn/visibility.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698