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

Side by Side Diff: lib/src/call_chain_visitor.dart

Issue 1182953003: Eat some dogfood! (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart_style.src.call_chain_visitor; 5 library dart_style.src.call_chain_visitor;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 8
9 import 'argument_list_visitor.dart'; 9 import 'argument_list_visitor.dart';
10 import 'rule/argument.dart'; 10 import 'rule/argument.dart';
(...skipping 12 matching lines...) Expand all
23 final Expression _target; 23 final Expression _target;
24 24
25 /// The list of dotted names ([PropertyAccess] and [PrefixedIdentifier] at 25 /// The list of dotted names ([PropertyAccess] and [PrefixedIdentifier] at
26 /// the start of the call chain. 26 /// the start of the call chain.
27 /// 27 ///
28 /// This will be empty if the [_target] is not a [SimpleIdentifier]. 28 /// This will be empty if the [_target] is not a [SimpleIdentifier].
29 final List<Expression> _properties; 29 final List<Expression> _properties;
30 30
31 /// The mixed method calls and property accesses in the call chain in the 31 /// The mixed method calls and property accesses in the call chain in the
32 /// order that they appear in the source. 32 /// order that they appear in the source.
33 final List <Expression> _calls; 33 final List<Expression> _calls;
34 34
35 /// Whether or not a [Rule] is currently active for the call chain. 35 /// Whether or not a [Rule] is currently active for the call chain.
36 bool _ruleEnabled = false; 36 bool _ruleEnabled = false;
37 37
38 /// Whether or not the span wrapping the call chain is currently active. 38 /// Whether or not the span wrapping the call chain is currently active.
39 bool _spanEnded = false; 39 bool _spanEnded = false;
40 40
41 /// Creates a new call chain visitor for [visitor] starting with [node]. 41 /// Creates a new call chain visitor for [visitor] starting with [node].
42 /// 42 ///
43 /// The [node] is the outermost expression containing the chained "." 43 /// The [node] is the outermost expression containing the chained "."
(...skipping 23 matching lines...) Expand all
67 67
68 // An expression that starts with a series of dotted names gets treated a 68 // An expression that starts with a series of dotted names gets treated a
69 // little specially. We don't force leading properties to split with the 69 // little specially. We don't force leading properties to split with the
70 // rest of the chain. Allows code like: 70 // rest of the chain. Allows code like:
71 // 71 //
72 // address.street.number 72 // address.street.number
73 // .toString() 73 // .toString()
74 // .length; 74 // .length;
75 var properties = []; 75 var properties = [];
76 if (target is SimpleIdentifier) { 76 if (target is SimpleIdentifier) {
77 properties = calls 77 properties =
78 .takeWhile((call) => call is! MethodInvocation) 78 calls.takeWhile((call) => call is! MethodInvocation).toList();
79 .toList();
80 } 79 }
81 80
82 calls.removeRange(0, properties.length); 81 calls.removeRange(0, properties.length);
83 82
84 return new CallChainVisitor._(visitor, target, properties, calls); 83 return new CallChainVisitor._(visitor, target, properties, calls);
85 } 84 }
86 85
87 CallChainVisitor._( 86 CallChainVisitor._(
88 this._visitor, this._target, this._properties, this._calls); 87 this._visitor, this._target, this._properties, this._calls);
89 88
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 220 }
222 221
223 /// Ends the span wrapping the call chain if it hasn't ended already. 222 /// Ends the span wrapping the call chain if it hasn't ended already.
224 void _endSpan() { 223 void _endSpan() {
225 if (_spanEnded) return; 224 if (_spanEnded) return;
226 225
227 _visitor.builder.endSpan(); 226 _visitor.builder.endSpan();
228 _spanEnded = true; 227 _spanEnded = true;
229 } 228 }
230 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698