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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 | 516 |
517 visitEmptyFunctionBody(EmptyFunctionBody node) { | 517 visitEmptyFunctionBody(EmptyFunctionBody node) { |
518 token(node.semicolon); | 518 token(node.semicolon); |
519 } | 519 } |
520 | 520 |
521 visitEmptyStatement(EmptyStatement node) { | 521 visitEmptyStatement(EmptyStatement node) { |
522 token(node.semicolon); | 522 token(node.semicolon); |
523 } | 523 } |
524 | 524 |
525 visitEnumConstantDeclaration(EnumConstantDeclaration node) { | 525 visitEnumConstantDeclaration(EnumConstantDeclaration node) { |
526 throw new UnimplementedError("Enum formatting is not implemented yet."); | 526 visit(node.name); |
527 } | 527 } |
528 | 528 |
529 visitEnumDeclaration(EnumDeclaration node) { | 529 visitEnumDeclaration(EnumDeclaration node) { |
530 throw new UnimplementedError("Enum formatting is not implemented yet."); | 530 visitDeclarationMetadata(node.metadata); |
| 531 |
| 532 token(node.keyword); |
| 533 space(); |
| 534 visit(node.name); |
| 535 space(); |
| 536 token(node.leftBracket); |
| 537 |
| 538 _writer.indent(); |
| 539 _writer.startMultisplit(); |
| 540 _writer.multisplit(space: true); |
| 541 |
| 542 visitCommaSeparatedNodes(node.constants, between: () { |
| 543 _writer.multisplit(space: true); |
| 544 }); |
| 545 |
| 546 // Trailing comma. |
| 547 if (node.rightBracket.previous.lexeme == ",") { |
| 548 token(node.rightBracket.previous); |
| 549 } |
| 550 |
| 551 _writer.unindent(); |
| 552 _writer.multisplit(space: true); |
| 553 token(node.rightBracket); |
531 } | 554 } |
532 | 555 |
533 visitExportDirective(ExportDirective node) { | 556 visitExportDirective(ExportDirective node) { |
534 visitDeclarationMetadata(node.metadata); | 557 visitDeclarationMetadata(node.metadata); |
535 | 558 |
536 _simpleStatement(node, () { | 559 _simpleStatement(node, () { |
537 token(node.keyword); | 560 token(node.keyword); |
538 space(); | 561 space(); |
539 visit(node.uri); | 562 visit(node.uri); |
540 _visitCombinators(node.combinators); | 563 _visitCombinators(node.combinators); |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 /// Gets the 1-based line number that the beginning of [token] lies on. | 1798 /// Gets the 1-based line number that the beginning of [token] lies on. |
1776 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; | 1799 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; |
1777 | 1800 |
1778 /// Gets the 1-based line number that the end of [token] lies on. | 1801 /// Gets the 1-based line number that the end of [token] lies on. |
1779 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; | 1802 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; |
1780 | 1803 |
1781 /// Gets the 1-based column number that the beginning of [token] lies on. | 1804 /// Gets the 1-based column number that the beginning of [token] lies on. |
1782 int _startColumn(Token token) => | 1805 int _startColumn(Token token) => |
1783 _lineInfo.getLocation(token.offset).columnNumber; | 1806 _lineInfo.getLocation(token.offset).columnNumber; |
1784 } | 1807 } |
OLD | NEW |