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

Unified Diff: lib/src/source_visitor.dart

Issue 1355203002: Handle index expressions in the middle of call chains. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Handle chained indexes. Created 5 years, 3 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 | « lib/src/call_chain_visitor.dart ('k') | test/regression/other/analysis_server.unit » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/source_visitor.dart
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 42e2fc61c3a6daccad8601f6401c1e11a58ba2aa..ba3ba5e08e688ffa463738598c740ec65a897c5f 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -1012,8 +1012,18 @@ class SourceVisitor implements AstVisitor {
visit(node.target);
}
+ finishIndexExpression(node);
+
+ builder.unnest();
+ }
+
+ /// Visit the index part of [node], excluding the target.
+ ///
+ /// Called by [CallChainVisitor] to handle index expressions in the middle of
+ /// call chains.
+ void finishIndexExpression(IndexExpression node) {
if (node.target is IndexExpression) {
- // Corner case: On a chain of [] accesses, allow splitting between them.
+ // Edge case: On a chain of [] accesses, allow splitting between them.
// Produces nicer output in cases like:
//
// someJson['property']['property']['property']['property']...
@@ -1026,7 +1036,6 @@ class SourceVisitor implements AstVisitor {
visit(node.index);
token(node.rightBracket);
builder.endSpan();
- builder.unnest();
}
visitInstanceCreationExpression(InstanceCreationExpression node) {
« no previous file with comments | « lib/src/call_chain_visitor.dart ('k') | test/regression/other/analysis_server.unit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698