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 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 // Split before the closing bracket character. | 2064 // Split before the closing bracket character. |
2065 builder.unindent(); | 2065 builder.unindent(); |
2066 builder.split(nest: false, space: space); | 2066 builder.split(nest: false, space: space); |
2067 }); | 2067 }); |
2068 | 2068 |
2069 builder.endRule(); | 2069 builder.endRule(); |
2070 } | 2070 } |
2071 | 2071 |
2072 /// Returns `true` if [node] is immediately contained within an anonymous | 2072 /// Returns `true` if [node] is immediately contained within an anonymous |
2073 /// [FunctionExpression]. | 2073 /// [FunctionExpression]. |
2074 bool _isInLambda(AstNode node) => node.parent is FunctionExpression && | 2074 bool _isInLambda(AstNode node) => |
| 2075 node.parent is FunctionExpression && |
2075 node.parent.parent is! FunctionDeclaration; | 2076 node.parent.parent is! FunctionDeclaration; |
2076 | 2077 |
2077 /// Writes the string literal [string] to the output. | 2078 /// Writes the string literal [string] to the output. |
2078 /// | 2079 /// |
2079 /// Splits multiline strings into separate chunks so that the line splitter | 2080 /// Splits multiline strings into separate chunks so that the line splitter |
2080 /// can handle them correctly. | 2081 /// can handle them correctly. |
2081 void _writeStringLiteral(String string, int offset) { | 2082 void _writeStringLiteral(String string, int offset) { |
2082 // Split each line of a multiline string into separate chunks. | 2083 // Split each line of a multiline string into separate chunks. |
2083 var lines = string.split(_formatter.lineEnding); | 2084 var lines = string.split(_formatter.lineEnding); |
2084 | 2085 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2361 /// Gets the 1-based line number that the beginning of [token] lies on. | 2362 /// Gets the 1-based line number that the beginning of [token] lies on. |
2362 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; | 2363 int _startLine(Token token) => _lineInfo.getLocation(token.offset).lineNumber; |
2363 | 2364 |
2364 /// Gets the 1-based line number that the end of [token] lies on. | 2365 /// Gets the 1-based line number that the end of [token] lies on. |
2365 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; | 2366 int _endLine(Token token) => _lineInfo.getLocation(token.end).lineNumber; |
2366 | 2367 |
2367 /// Gets the 1-based column number that the beginning of [token] lies on. | 2368 /// Gets the 1-based column number that the beginning of [token] lies on. |
2368 int _startColumn(Token token) => | 2369 int _startColumn(Token token) => |
2369 _lineInfo.getLocation(token.offset).columnNumber; | 2370 _lineInfo.getLocation(token.offset).columnNumber; |
2370 } | 2371 } |
OLD | NEW |