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 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 void _visitCollectionLiteral(TypedLiteral node, Token leftBracket, | 1669 void _visitCollectionLiteral(TypedLiteral node, Token leftBracket, |
1670 Iterable<AstNode> elements, Token rightBracket, | 1670 Iterable<AstNode> elements, Token rightBracket, |
1671 [int cost]) { | 1671 [int cost]) { |
1672 modifier(node.constKeyword); | 1672 modifier(node.constKeyword); |
1673 visit(node.typeArguments); | 1673 visit(node.typeArguments); |
1674 | 1674 |
1675 // Don't allow splitting in an empty collection. | 1675 // Don't allow splitting in an empty collection. |
1676 if (elements.isEmpty && rightBracket.precedingComments == null) { | 1676 if (elements.isEmpty && rightBracket.precedingComments == null) { |
1677 token(leftBracket); | 1677 token(leftBracket); |
1678 token(rightBracket); | 1678 token(rightBracket); |
| 1679 |
| 1680 // Clear this out in case this empty collection is in an argument list. |
| 1681 // We don't want this rule to bleed over to some other collection. |
| 1682 _nextLiteralBodyRule = null; |
1679 return; | 1683 return; |
1680 } | 1684 } |
1681 | 1685 |
1682 // Force all of the surrounding collections to split. | 1686 // Force all of the surrounding collections to split. |
1683 for (var i = 0; i < _collectionSplits.length; i++) { | 1687 for (var i = 0; i < _collectionSplits.length; i++) { |
1684 _collectionSplits[i] = true; | 1688 _collectionSplits[i] = true; |
1685 } | 1689 } |
1686 | 1690 |
1687 // Add this collection to the stack. | 1691 // Add this collection to the stack. |
1688 _collectionSplits.add(false); | 1692 _collectionSplits.add(false); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 /// Gets the 1-based line number that the beginning of [token] lies on. | 2161 /// Gets the 1-based line number that the beginning of [token] lies on. |
2158 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; | 2162 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; |
2159 | 2163 |
2160 /// Gets the 1-based line number that the end of [token] lies on. | 2164 /// Gets the 1-based line number that the end of [token] lies on. |
2161 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; | 2165 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; |
2162 | 2166 |
2163 /// Gets the 1-based column number that the beginning of [token] lies on. | 2167 /// Gets the 1-based column number that the beginning of [token] lies on. |
2164 int _startColumn(Token token) => | 2168 int _startColumn(Token token) => |
2165 _lineInfo.getLocation(token.offset).columnNumber; | 2169 _lineInfo.getLocation(token.offset).columnNumber; |
2166 } | 2170 } |
OLD | NEW |