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.code_formatter; | 5 library dart_style.src.code_formatter; |
6 | 6 |
7 import 'package:analyzer/src/string_source.dart'; | 7 import 'package:analyzer/src/string_source.dart'; |
8 import 'package:analyzer/src/generated/parser.dart'; | 8 import 'package:analyzer/src/generated/parser.dart'; |
9 import 'package:analyzer/src/generated/scanner.dart'; | 9 import 'package:analyzer/src/generated/scanner.dart'; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 } else { | 140 } else { |
141 lineEnding = "\n"; | 141 lineEnding = "\n"; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 errorListener.throwIfErrors(); | 145 errorListener.throwIfErrors(); |
146 | 146 |
147 // Parse it. | 147 // Parse it. |
148 var parser = new Parser(stringSource, errorListener); | 148 var parser = new Parser(stringSource, errorListener); |
149 parser.parseAsync = true; | 149 parser.parseAsync = true; |
150 parser.parseEnum = true; | |
pquitslund
2015/01/08 04:49:25
Depending on what version of the analyzer we're pu
Bob Nystrom
2015/01/08 17:35:35
Right now dart_style is constrained to an older ve
| |
150 | 151 |
151 var node; | 152 var node; |
152 if (source.isCompilationUnit) { | 153 if (source.isCompilationUnit) { |
153 node = parser.parseCompilationUnit(startToken); | 154 node = parser.parseCompilationUnit(startToken); |
154 } else { | 155 } else { |
155 node = parser.parseStatement(startToken); | 156 node = parser.parseStatement(startToken); |
156 } | 157 } |
157 | 158 |
158 errorListener.throwIfErrors(); | 159 errorListener.throwIfErrors(); |
159 | 160 |
160 // Format it. | 161 // Format it. |
161 var visitor = new SourceVisitor(this, lineInfo, source); | 162 var visitor = new SourceVisitor(this, lineInfo, source); |
162 return visitor.run(node); | 163 return visitor.run(node); |
163 } | 164 } |
164 } | 165 } |
OLD | NEW |