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

Unified Diff: lib/src/call_chain_visitor.dart

Issue 1493553002: Smarter splitting around named collection arguments. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years 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 | « lib/src/argument_list_visitor.dart ('k') | lib/src/dart_formatter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/call_chain_visitor.dart
diff --git a/lib/src/call_chain_visitor.dart b/lib/src/call_chain_visitor.dart
index a7ab75e2267adb75689355325d658a138b34f743..7b7fb2690c2ddf9e4e02eac493026882cfe66249 100644
--- a/lib/src/call_chain_visitor.dart
+++ b/lib/src/call_chain_visitor.dart
@@ -8,6 +8,7 @@ import 'package:analyzer/analyzer.dart';
import 'argument_list_visitor.dart';
import 'rule/argument.dart';
+import 'rule/rule.dart';
import 'source_visitor.dart';
/// Helper class for [SourceVisitor] that handles visiting and writing a
@@ -307,22 +308,20 @@ class CallChainVisitor {
// Don't split right after a non-empty curly-bodied function.
if (expression is FunctionExpression) {
- var function = expression as FunctionExpression;
+ if (expression.body is! BlockFunctionBody) return false;
- if (function.body is! BlockFunctionBody) return false;
-
- return (function.body as BlockFunctionBody).block.statements.isEmpty;
+ return (expression.body as BlockFunctionBody).block.statements.isEmpty;
}
// If the expression ends in an argument list, base the splitting on the
// last argument.
var argumentList;
if (expression is MethodInvocation) {
- argumentList = (expression as MethodInvocation).argumentList;
+ argumentList = expression.argumentList;
} else if (expression is InstanceCreationExpression) {
- argumentList = (expression as InstanceCreationExpression).argumentList;
+ argumentList = expression.argumentList;
} else if (expression is FunctionExpressionInvocation) {
- argumentList = (expression as FunctionExpressionInvocation).argumentList;
+ argumentList = expression.argumentList;
}
// Any other kind of expression always splits.
@@ -420,7 +419,7 @@ class CallChainVisitor {
if (_ruleEnabled) return;
// If the properties split, force the calls to split too.
- var rule = new NamedRule();
+ var rule = new Rule();
if (_propertyRule != null) _propertyRule.setNamedArgsRule(rule);
if (lazy) {
« no previous file with comments | « lib/src/argument_list_visitor.dart ('k') | lib/src/dart_formatter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698