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

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

Issue 1505983005: Upgrade to analyzer 0.27.0. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Bump. Created 5 years 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.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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 space(); 526 space();
527 527
528 visit(node.elseExpression); 528 visit(node.elseExpression);
529 529
530 builder.endRule(); 530 builder.endRule();
531 builder.endSpan(); 531 builder.endSpan();
532 builder.endBlockArgumentNesting(); 532 builder.endBlockArgumentNesting();
533 builder.unnest(); 533 builder.unnest();
534 } 534 }
535 535
536 visitConfiguration(Configuration node) {
537 token(node.ifKeyword);
538 space();
539 token(node.leftParenthesis);
540 visit(node.name);
541
542 if (node.equalToken != null) {
543 builder.nestExpression();
544 space();
545 token(node.equalToken);
546 soloSplit();
547 visit(node.value);
548 builder.unnest();
549 }
550
551 token(node.rightParenthesis);
552 space();
553 visit(node.libraryUri);
554 }
555
536 visitConstructorDeclaration(ConstructorDeclaration node) { 556 visitConstructorDeclaration(ConstructorDeclaration node) {
537 visitMemberMetadata(node.metadata); 557 visitMemberMetadata(node.metadata);
538 558
539 modifier(node.externalKeyword); 559 modifier(node.externalKeyword);
540 modifier(node.constKeyword); 560 modifier(node.constKeyword);
541 modifier(node.factoryKeyword); 561 modifier(node.factoryKeyword);
542 visit(node.returnType); 562 visit(node.returnType);
543 token(node.period); 563 token(node.period);
544 visit(node.name); 564 visit(node.name);
545 565
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 token(node.whileKeyword); 679 token(node.whileKeyword);
660 space(); 680 space();
661 token(node.leftParenthesis); 681 token(node.leftParenthesis);
662 soloZeroSplit(); 682 soloZeroSplit();
663 visit(node.condition); 683 visit(node.condition);
664 token(node.rightParenthesis); 684 token(node.rightParenthesis);
665 token(node.semicolon); 685 token(node.semicolon);
666 builder.unnest(); 686 builder.unnest();
667 } 687 }
668 688
689 visitDottedName(DottedName node) {
690 for (var component in node.components) {
691 // Write the preceding ".".
692 if (component != node.components.first) {
693 token(component.beginToken.previous);
694 }
695
696 visit(component);
697 }
698 }
699
669 visitDoubleLiteral(DoubleLiteral node) { 700 visitDoubleLiteral(DoubleLiteral node) {
670 token(node.literal); 701 token(node.literal);
671 } 702 }
672 703
673 visitEmptyFunctionBody(EmptyFunctionBody node) { 704 visitEmptyFunctionBody(EmptyFunctionBody node) {
674 token(node.semicolon); 705 token(node.semicolon);
675 } 706 }
676 707
677 visitEmptyStatement(EmptyStatement node) { 708 visitEmptyStatement(EmptyStatement node) {
678 token(node.semicolon); 709 token(node.semicolon);
(...skipping 17 matching lines...) Expand all
696 } 727 }
697 728
698 visitExportDirective(ExportDirective node) { 729 visitExportDirective(ExportDirective node) {
699 visitDeclarationMetadata(node.metadata); 730 visitDeclarationMetadata(node.metadata);
700 731
701 _simpleStatement(node, () { 732 _simpleStatement(node, () {
702 token(node.keyword); 733 token(node.keyword);
703 space(); 734 space();
704 visit(node.uri); 735 visit(node.uri);
705 736
737 _visitConfigurations(node.configurations);
738
706 builder.startRule(new CombinatorRule()); 739 builder.startRule(new CombinatorRule());
707 visitNodes(node.combinators); 740 visitNodes(node.combinators);
708 builder.endRule(); 741 builder.endRule();
709 }); 742 });
710 } 743 }
711 744
712 visitExpressionFunctionBody(ExpressionFunctionBody node) { 745 visitExpressionFunctionBody(ExpressionFunctionBody node) {
713 // Space after the parameter list. 746 // Space after the parameter list.
714 space(); 747 space();
715 748
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 } 1088 }
1056 1089
1057 visitImportDirective(ImportDirective node) { 1090 visitImportDirective(ImportDirective node) {
1058 visitDeclarationMetadata(node.metadata); 1091 visitDeclarationMetadata(node.metadata);
1059 1092
1060 _simpleStatement(node, () { 1093 _simpleStatement(node, () {
1061 token(node.keyword); 1094 token(node.keyword);
1062 space(); 1095 space();
1063 visit(node.uri); 1096 visit(node.uri);
1064 1097
1098 _visitConfigurations(node.configurations);
1099
1065 if (node.asKeyword != null) { 1100 if (node.asKeyword != null) {
1066 soloSplit(); 1101 soloSplit();
1067 token(node.deferredKeyword, after: space); 1102 token(node.deferredKeyword, after: space);
1068 token(node.asKeyword); 1103 token(node.asKeyword);
1069 space(); 1104 space();
1070 visit(node.prefix); 1105 visit(node.prefix);
1071 } 1106 }
1072 1107
1073 builder.startRule(new CombinatorRule()); 1108 builder.startRule(new CombinatorRule());
1074 visitNodes(node.combinators); 1109 visitNodes(node.combinators);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 2025
1991 builder = builder.endBlock(ignoredRule, 2026 builder = builder.endBlock(ignoredRule,
1992 forceSplit: hasLeadingNewline || forceSplit); 2027 forceSplit: hasLeadingNewline || forceSplit);
1993 2028
1994 builder.endRule(); 2029 builder.endRule();
1995 2030
1996 // Now write the delimiter itself. 2031 // Now write the delimiter itself.
1997 _writeText(rightBracket.lexeme, rightBracket.offset); 2032 _writeText(rightBracket.lexeme, rightBracket.offset);
1998 } 2033 }
1999 2034
2035 /// Visits a list of configurations in an import or export directive.
2036 void _visitConfigurations(NodeList<Configuration> configurations) {
2037 if (configurations.isEmpty) return;
2038
2039 builder.startRule();
2040
2041 for (var configuration in configurations) {
2042 split();
2043 visit(configuration);
2044 }
2045
2046 builder.endRule();
2047 }
2048
2000 /// Visits a "combinator". 2049 /// Visits a "combinator".
2001 /// 2050 ///
2002 /// This is a [keyword] followed by a list of [nodes], with specific line 2051 /// This is a [keyword] followed by a list of [nodes], with specific line
2003 /// splitting rules. As the name implies, this is used for [HideCombinator] 2052 /// splitting rules. As the name implies, this is used for [HideCombinator]
2004 /// and [ShowCombinator], but it also used for "with" and "implements" 2053 /// and [ShowCombinator], but it also used for "with" and "implements"
2005 /// clauses in class declarations, which are formatted the same way. 2054 /// clauses in class declarations, which are formatted the same way.
2006 /// 2055 ///
2007 /// This assumes the current rule is a [CombinatorRule]. 2056 /// This assumes the current rule is a [CombinatorRule].
2008 void _visitCombinator(Token keyword, Iterable<AstNode> nodes) { 2057 void _visitCombinator(Token keyword, Iterable<AstNode> nodes) {
2009 // Allow splitting before the keyword. 2058 // Allow splitting before the keyword.
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 /// Gets the 1-based line number that the beginning of [token] lies on. 2411 /// Gets the 1-based line number that the beginning of [token] lies on.
2363 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; 2412 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber;
2364 2413
2365 /// Gets the 1-based line number that the end of [token] lies on. 2414 /// Gets the 1-based line number that the end of [token] lies on.
2366 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; 2415 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber;
2367 2416
2368 /// Gets the 1-based column number that the beginning of [token] lies on. 2417 /// Gets the 1-based column number that the beginning of [token] lies on.
2369 int _startColumn(Token token) => 2418 int _startColumn(Token token) =>
2370 _lineInfo.getLocation(token.offset).columnNumber; 2419 _lineInfo.getLocation(token.offset).columnNumber;
2371 } 2420 }
OLDNEW
« no previous file with comments | « lib/src/dart_formatter.dart ('k') | pubspec.lock » ('j') | pubspec.lock » ('J')

Powered by Google App Engine
This is Rietveld 408576698