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/src/generated/scanner.dart'; | 8 import 'package:analyzer/src/generated/scanner.dart'; |
9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
10 | 10 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 directives = directives.skip(1); | 363 directives = directives.skip(1); |
364 } | 364 } |
365 | 365 |
366 visitNodes(directives, between: oneOrTwoNewlines); | 366 visitNodes(directives, between: oneOrTwoNewlines); |
367 visitNodes(node.declarations, | 367 visitNodes(node.declarations, |
368 before: twoNewlines, between: oneOrTwoNewlines); | 368 before: twoNewlines, between: oneOrTwoNewlines); |
369 } | 369 } |
370 | 370 |
371 visitConditionalExpression(ConditionalExpression node) { | 371 visitConditionalExpression(ConditionalExpression node) { |
| 372 _writer.nestExpression(); |
372 visit(node.condition); | 373 visit(node.condition); |
373 space(); | 374 space(); |
374 | 375 |
375 _writer.startSpan(); | 376 _writer.startSpan(); |
376 token(node.question); | 377 token(node.question); |
377 | 378 |
378 // If we split after one clause in a conditional, always split after both. | 379 // If we split after one clause in a conditional, always split after both. |
379 _writer.startMultisplit(); | 380 _writer.startMultisplit(); |
380 _writer.multisplit(nest: true, space: true); | 381 _writer.multisplit(nest: true, space: true); |
381 visit(node.thenExpression); | 382 visit(node.thenExpression); |
382 | 383 |
383 space(); | 384 space(); |
384 token(node.colon); | 385 token(node.colon); |
385 _writer.multisplit(nest: true, space: true); | 386 _writer.multisplit(nest: true, space: true); |
386 visit(node.elseExpression); | 387 visit(node.elseExpression); |
387 | 388 |
388 _writer.endMultisplit(); | 389 _writer.endMultisplit(); |
389 _writer.endSpan(); | 390 _writer.endSpan(); |
| 391 _writer.unnest(); |
390 } | 392 } |
391 | 393 |
392 visitConstructorDeclaration(ConstructorDeclaration node) { | 394 visitConstructorDeclaration(ConstructorDeclaration node) { |
393 visitMemberMetadata(node.metadata); | 395 visitMemberMetadata(node.metadata); |
394 | 396 |
395 _writer.nestExpression(); | 397 _writer.nestExpression(); |
396 modifier(node.externalKeyword); | 398 modifier(node.externalKeyword); |
397 modifier(node.constKeyword); | 399 modifier(node.constKeyword); |
398 modifier(node.factoryKeyword); | 400 modifier(node.factoryKeyword); |
399 visit(node.returnType); | 401 visit(node.returnType); |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 /// Gets the 1-based line number that the beginning of [token] lies on. | 1803 /// Gets the 1-based line number that the beginning of [token] lies on. |
1802 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; | 1804 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; |
1803 | 1805 |
1804 /// Gets the 1-based line number that the end of [token] lies on. | 1806 /// Gets the 1-based line number that the end of [token] lies on. |
1805 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; | 1807 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; |
1806 | 1808 |
1807 /// Gets the 1-based column number that the beginning of [token] lies on. | 1809 /// Gets the 1-based column number that the beginning of [token] lies on. |
1808 int _startColumn(Token token) => | 1810 int _startColumn(Token token) => |
1809 _lineInfo.getLocation(token.offset).columnNumber; | 1811 _lineInfo.getLocation(token.offset).columnNumber; |
1810 } | 1812 } |
OLD | NEW |