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

Unified Diff: tools/gn/command_format.cc

Issue 1442023002: Sort "deps" and "public_deps" when running the "gn format" command. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | tools/gn/command_format_unittest.cc » ('j') | tools/gn/format_test_data/063.golden » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_format.cc
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc
index 5eff6017f3f9c2f4a4574e852e7e0ca0373d2d0c..ef3149ef219098ed4395c40ab7bff158b0baf391 100644
--- a/tools/gn/command_format.cc
+++ b/tools/gn/command_format.cc
@@ -128,8 +128,8 @@ class Printer {
// Flag assignments to sources, deps, etc. to make their RHSs multiline.
void AnnotatePreferredMultilineAssignment(const BinaryOpNode* binop);
- // Alphabetically a list on the RHS if the LHS is 'sources'.
- void SortIfSources(const BinaryOpNode* binop);
+ // Alphabetically a list on the RHS if the LHS is 'sources' or 'deps'.
+ void SortIfSourcesOrDeps(const BinaryOpNode* binop);
// Heuristics to decide if there should be a blank line added between two
// items. For various "small" items, it doesn't look nice if there's too much
@@ -307,15 +307,15 @@ void Printer::AnnotatePreferredMultilineAssignment(const BinaryOpNode* binop) {
}
}
-void Printer::SortIfSources(const BinaryOpNode* binop) {
+void Printer::SortIfSourcesOrDeps(const BinaryOpNode* binop) {
const IdentifierNode* ident = binop->left()->AsIdentifier();
const ListNode* list = binop->right()->AsList();
- // TODO(scottmg): Sort more than 'sources'?
+ // TODO(scottmg): Sort more than 'sources' and 'deps'?
if ((binop->op().value() == "=" || binop->op().value() == "+=" ||
binop->op().value() == "-=") &&
ident && list) {
const base::StringPiece lhs = ident->value().value();
- if (lhs == "sources")
+ if (lhs == "sources" || lhs == "deps")
const_cast<ListNode*>(list)->SortAsStringsList();
}
}
@@ -458,7 +458,7 @@ int Printer::Expr(const ParseNode* root,
CHECK(precedence_.find(binop->op().value()) != precedence_.end());
AnnotatePreferredMultilineAssignment(binop);
- SortIfSources(binop);
+ SortIfSourcesOrDeps(binop);
Precedence prec = precedence_[binop->op().value()];
« no previous file with comments | « no previous file | tools/gn/command_format_unittest.cc » ('j') | tools/gn/format_test_data/063.golden » ('J')

Powered by Google App Engine
This is Rietveld 408576698