Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: pkg/analyzer_experimental/lib/src/services/formatter_impl.dart

Issue 42863002: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_experimental/analyzer.dart'; 9 import 'package:analyzer_experimental/analyzer.dart';
10 import 'package:analyzer_experimental/src/generated/java_core.dart' show CharSeq uence;
10 import 'package:analyzer_experimental/src/generated/parser.dart'; 11 import 'package:analyzer_experimental/src/generated/parser.dart';
11 import 'package:analyzer_experimental/src/generated/scanner.dart'; 12 import 'package:analyzer_experimental/src/generated/scanner.dart';
12 import 'package:analyzer_experimental/src/generated/source.dart'; 13 import 'package:analyzer_experimental/src/generated/source.dart';
13 import 'package:analyzer_experimental/src/services/writer.dart'; 14 import 'package:analyzer_experimental/src/services/writer.dart';
14 15
15 /// Formatter options. 16 /// Formatter options.
16 class FormatterOptions { 17 class FormatterOptions {
17 18
18 /// Create formatter options with defaults derived (where defined) from 19 /// Create formatter options with defaults derived (where defined) from
19 /// the style guide: <http://www.dartlang.org/articles/style-guide/>. 20 /// the style guide: <http://www.dartlang.org/articles/style-guide/>.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (errors.length > 0) { 164 if (errors.length > 0) {
164 throw new FormatterException.forError(errors); 165 throw new FormatterException.forError(errors);
165 } 166 }
166 } 167 }
167 168
168 onError(AnalysisError error) { 169 onError(AnalysisError error) {
169 errors.add(error); 170 errors.add(error);
170 } 171 }
171 172
172 Token tokenize(String source) { 173 Token tokenize(String source) {
173 var scanner = new StringScanner(null, source, this); 174 var reader = new CharSequenceReader(new CharSequence(source));
175 var scanner = new Scanner(null, reader, this);
174 var token = scanner.tokenize(); 176 var token = scanner.tokenize();
175 lineInfo = new LineInfo(scanner.lineStarts); 177 lineInfo = new LineInfo(scanner.lineStarts);
176 return token; 178 return token;
177 } 179 }
178 180
179 } 181 }
180 182
181 183
182 // Compares two token streams. Used for sanity checking formatted results. 184 // Compares two token streams. Used for sanity checking formatted results.
183 class TokenStreamComparator { 185 class TokenStreamComparator {
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 var lastLine = 1526 var lastLine =
1525 lineInfo.getLocation(lastOffset).lineNumber; 1527 lineInfo.getLocation(lastOffset).lineNumber;
1526 var currentLine = 1528 var currentLine =
1527 lineInfo.getLocation(currentOffset).lineNumber; 1529 lineInfo.getLocation(currentOffset).lineNumber;
1528 return currentLine - lastLine; 1530 return currentLine - lastLine;
1529 } 1531 }
1530 1532
1531 String toString() => writer.toString(); 1533 String toString() => writer.toString();
1532 1534
1533 } 1535 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698