| 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.dart_formatter; | 5 library dart_style.src.dart_formatter; |
| 6 | 6 |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 var node; | 104 var node; |
| 105 if (source.isCompilationUnit) { | 105 if (source.isCompilationUnit) { |
| 106 node = parser.parseCompilationUnit(startToken); | 106 node = parser.parseCompilationUnit(startToken); |
| 107 } else { | 107 } else { |
| 108 node = parser.parseStatement(startToken); | 108 node = parser.parseStatement(startToken); |
| 109 | 109 |
| 110 // Make sure we consumed all of the source. | 110 // Make sure we consumed all of the source. |
| 111 var token = node.endToken.next; | 111 var token = node.endToken.next; |
| 112 if (token.type != TokenType.EOF) { | 112 if (token.type != TokenType.EOF) { |
| 113 var error = new AnalysisError.con2( | 113 var error = new AnalysisError( |
| 114 stringSource, | 114 stringSource, |
| 115 token.offset, | 115 token.offset, |
| 116 math.max(token.length, 1), | 116 math.max(token.length, 1), |
| 117 ParserErrorCode.UNEXPECTED_TOKEN, | 117 ParserErrorCode.UNEXPECTED_TOKEN, |
| 118 [token.lexeme]); | 118 [token.lexeme]); |
| 119 | 119 |
| 120 throw new FormatterException([error]); | 120 throw new FormatterException([error]); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 errorListener.throwIfErrors(); | 124 errorListener.throwIfErrors(); |
| 125 | 125 |
| 126 // Format it. | 126 // Format it. |
| 127 var visitor = new SourceVisitor(this, lineInfo, source); | 127 var visitor = new SourceVisitor(this, lineInfo, source); |
| 128 return visitor.run(node); | 128 return visitor.run(node); |
| 129 } | 129 } |
| 130 } | 130 } |
| OLD | NEW |