Chromium Code Reviews| Index: tools/gn/command_format.cc |
| diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc |
| index 5eff6017f3f9c2f4a4574e852e7e0ca0373d2d0c..664d109cf44740e5ef0514224bfc96c75639b86d 100644 |
| --- a/tools/gn/command_format.cc |
| +++ b/tools/gn/command_format.cc |
| @@ -128,8 +128,10 @@ 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); |
| + // Sort a list on the RHS if the LHS is 'sources' or 'deps'. The 'sources' |
| + // are sorted alphabetically while the 'deps' are sorted puttint first the |
|
Dirk Pranke
2015/11/16 00:34:34
nit: s/puttint first/putting first/
|
| + // relative targets and then the global ones (both sorted alphabetically). |
| + 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,20 +309,21 @@ 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") |
| const_cast<ListNode*>(list)->SortAsStringsList(); |
| + else if (lhs == "deps") |
| + const_cast<ListNode*>(list)->SortAsDepsList(); |
| } |
| } |
| - |
| bool Printer::ShouldAddBlankLineInBetween(const ParseNode* a, |
| const ParseNode* b) { |
| LocationRange a_range = a->GetRange(); |
| @@ -458,7 +461,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()]; |