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

Unified Diff: lib/src/argument_list_visitor.dart

Issue 1591463002: Indent functions in named argument lists with non-functions. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 4 years, 11 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 | « CHANGELOG.md ('k') | test/regression/0400/0478.stmt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/argument_list_visitor.dart
diff --git a/lib/src/argument_list_visitor.dart b/lib/src/argument_list_visitor.dart
index 5c8bc0356104022d2d0e394d18c9e7e348e330b8..3ffa4c0479b88a28bfd6e36c31d8cfcf02a57a1c 100644
--- a/lib/src/argument_list_visitor.dart
+++ b/lib/src/argument_list_visitor.dart
@@ -68,6 +68,31 @@ class ArgumentListVisitor {
}
}
+ // Edge case: If all of the arguments are named, but they aren't all
+ // functions, then don't handle the functions specially. A function with a
+ // bunch of named arguments tends to look best when they are all lined up,
+ // even the function ones (unless they are all functions).
+ //
+ // Prefers:
+ //
+ // function(
+ // named: () {
+ // something();
+ // },
+ // another: argument);
+ //
+ // Over:
+ //
+ // function(named: () {
+ // something();
+ // }
+ // another: argument);
+ if (functionsStart != null &&
+ node.arguments[0] is NamedExpression &&
+ (functionsStart > 0 || functionsEnd < node.arguments.length)) {
+ functionsStart = null;
+ }
+
if (functionsStart == null) {
// No functions, so there is just a single argument list.
return new ArgumentListVisitor._(visitor, node,
« no previous file with comments | « CHANGELOG.md ('k') | test/regression/0400/0478.stmt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698