| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 formatter_impl; | 5 library formatter_impl; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/parser.dart'; | 10 import 'package:analyzer/src/generated/parser.dart'; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 return checkTokens(); | 295 return checkTokens(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 } | 298 } |
| 299 | 299 |
| 300 return false; | 300 return false; |
| 301 } | 301 } |
| 302 | 302 |
| 303 } | 303 } |
| 304 | 304 |
| 305 // Cached parser for testing token types. | 305 /// Test for token type. |
| 306 final tokenTester = new Parser(null,null); | 306 bool tokenIs(Token token, TokenType type) => |
| 307 token != null && token.type == type; |
| 307 | 308 |
| 308 /// Test if this token is an EOF token. | 309 /// Test if this token is an EOF token. |
| 309 bool isEOF(Token token) => tokenIs(token, TokenType.EOF); | 310 bool isEOF(Token token) => tokenIs(token, TokenType.EOF); |
| 310 | 311 |
| 311 /// Test for token type. | |
| 312 bool tokenIs(Token token, TokenType type) => | |
| 313 token != null && tokenTester.matchesAny(token, [type]); | |
| 314 | |
| 315 /// Test if this token is a GT token. | 312 /// Test if this token is a GT token. |
| 316 bool isGT(Token token) => tokenIs(token, TokenType.GT); | 313 bool isGT(Token token) => tokenIs(token, TokenType.GT); |
| 317 | 314 |
| 318 /// Test if this token is a GT_GT token. | 315 /// Test if this token is a GT_GT token. |
| 319 bool isGT_GT(Token token) => tokenIs(token, TokenType.GT_GT); | 316 bool isGT_GT(Token token) => tokenIs(token, TokenType.GT_GT); |
| 320 | 317 |
| 321 /// Test if this token is an INDEX token. | 318 /// Test if this token is an INDEX token. |
| 322 bool isINDEX(Token token) => tokenIs(token, TokenType.INDEX); | 319 bool isINDEX(Token token) => tokenIs(token, TokenType.INDEX); |
| 323 | 320 |
| 324 /// Test if this token is a OPEN_CURLY_BRACKET token. | 321 /// Test if this token is a OPEN_CURLY_BRACKET token. |
| (...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 var lastLine = | 1749 var lastLine = |
| 1753 lineInfo.getLocation(lastOffset).lineNumber; | 1750 lineInfo.getLocation(lastOffset).lineNumber; |
| 1754 var currentLine = | 1751 var currentLine = |
| 1755 lineInfo.getLocation(currentOffset).lineNumber; | 1752 lineInfo.getLocation(currentOffset).lineNumber; |
| 1756 return currentLine - lastLine; | 1753 return currentLine - lastLine; |
| 1757 } | 1754 } |
| 1758 | 1755 |
| 1759 String toString() => writer.toString(); | 1756 String toString() => writer.toString(); |
| 1760 | 1757 |
| 1761 } | 1758 } |
| OLD | NEW |