OLD | NEW |
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.source_visitor; | 5 library dart_style.src.source_visitor; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
10 | 10 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 _visitCollectionLiteral( | 152 _visitCollectionLiteral( |
153 null, node.leftParenthesis, node.arguments, node.rightParenthesis); | 153 null, node.leftParenthesis, node.arguments, node.rightParenthesis); |
154 return; | 154 return; |
155 } | 155 } |
156 | 156 |
157 new ArgumentListVisitor(this, node).visit(); | 157 new ArgumentListVisitor(this, node).visit(); |
158 } | 158 } |
159 | 159 |
160 visitAsExpression(AsExpression node) { | 160 visitAsExpression(AsExpression node) { |
161 builder.startSpan(); | 161 builder.startSpan(); |
| 162 builder.nestExpression(); |
162 visit(node.expression); | 163 visit(node.expression); |
163 soloSplit(); | 164 soloSplit(); |
164 token(node.asOperator); | 165 token(node.asOperator); |
165 space(); | 166 space(); |
166 visit(node.type); | 167 visit(node.type); |
| 168 builder.unnest(); |
167 builder.endSpan(); | 169 builder.endSpan(); |
168 } | 170 } |
169 | 171 |
170 // TODO(rnystrom): Type annotate once analyzer publishes a version with the | 172 // TODO(rnystrom): Type annotate once analyzer publishes a version with the |
171 // new AST type. | 173 // new AST type. |
172 // TODO(rnystrom): Test. | 174 // TODO(rnystrom): Test. |
173 visitAssertInitializer(node) { | 175 visitAssertInitializer(node) { |
174 _simpleStatement(node, () { | 176 _simpleStatement(node, () { |
175 token(node.assertKeyword); | 177 token(node.assertKeyword); |
176 | 178 |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 visit(node.expression); | 1235 visit(node.expression); |
1234 token(node.rightBracket); | 1236 token(node.rightBracket); |
1235 } | 1237 } |
1236 | 1238 |
1237 visitInterpolationString(InterpolationString node) { | 1239 visitInterpolationString(InterpolationString node) { |
1238 token(node.contents); | 1240 token(node.contents); |
1239 } | 1241 } |
1240 | 1242 |
1241 visitIsExpression(IsExpression node) { | 1243 visitIsExpression(IsExpression node) { |
1242 builder.startSpan(); | 1244 builder.startSpan(); |
| 1245 builder.nestExpression(); |
1243 visit(node.expression); | 1246 visit(node.expression); |
1244 soloSplit(); | 1247 soloSplit(); |
1245 token(node.isOperator); | 1248 token(node.isOperator); |
1246 token(node.notOperator); | 1249 token(node.notOperator); |
1247 space(); | 1250 space(); |
1248 visit(node.type); | 1251 visit(node.type); |
| 1252 builder.unnest(); |
1249 builder.endSpan(); | 1253 builder.endSpan(); |
1250 } | 1254 } |
1251 | 1255 |
1252 visitLabel(Label node) { | 1256 visitLabel(Label node) { |
1253 visit(node.label); | 1257 visit(node.label); |
1254 token(node.colon); | 1258 token(node.colon); |
1255 } | 1259 } |
1256 | 1260 |
1257 visitLabeledStatement(LabeledStatement node) { | 1261 visitLabeledStatement(LabeledStatement node) { |
1258 _visitLabels(node.labels); | 1262 _visitLabels(node.labels); |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 /// Gets the 1-based line number that the beginning of [token] lies on. | 2594 /// Gets the 1-based line number that the beginning of [token] lies on. |
2591 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; | 2595 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; |
2592 | 2596 |
2593 /// Gets the 1-based line number that the end of [token] lies on. | 2597 /// Gets the 1-based line number that the end of [token] lies on. |
2594 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; | 2598 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; |
2595 | 2599 |
2596 /// Gets the 1-based column number that the beginning of [token] lies on. | 2600 /// Gets the 1-based column number that the beginning of [token] lies on. |
2597 int _startColumn(Token token) => | 2601 int _startColumn(Token token) => |
2598 _lineInfo.getLocation(token.offset).columnNumber; | 2602 _lineInfo.getLocation(token.offset).columnNumber; |
2599 } | 2603 } |
OLD | NEW |