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

Side by Side Diff: lib/src/dart_formatter.dart

Issue 2194373002: Bump analyzer to 0.27.4. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 4 years, 4 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
« CHANGELOG.md ('K') | « CHANGELOG.md ('k') | pubspec.lock » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } else { 96 } else {
97 lineEnding = "\n"; 97 lineEnding = "\n";
98 } 98 }
99 } 99 }
100 100
101 errorListener.throwIfErrors(); 101 errorListener.throwIfErrors();
102 102
103 // Parse it. 103 // Parse it.
104 var parser = new Parser(stringSource, errorListener); 104 var parser = new Parser(stringSource, errorListener);
105 105
106 parser.parseTrailingCommas = true;
107
108 var node; 106 var node;
109 if (source.isCompilationUnit) { 107 if (source.isCompilationUnit) {
110 node = parser.parseCompilationUnit(startToken); 108 node = parser.parseCompilationUnit(startToken);
111 } else { 109 } else {
112 node = parser.parseStatement(startToken); 110 node = parser.parseStatement(startToken);
113 111
114 // Make sure we consumed all of the source. 112 // Make sure we consumed all of the source.
115 var token = node.endToken.next; 113 var token = node.endToken.next;
116 if (token.type != TokenType.EOF) { 114 if (token.type != TokenType.EOF) {
117 var error = new AnalysisError( 115 var error = new AnalysisError(
118 stringSource, 116 stringSource,
119 token.offset, 117 token.offset,
120 math.max(token.length, 1), 118 math.max(token.length, 1),
121 ParserErrorCode.UNEXPECTED_TOKEN, 119 ParserErrorCode.UNEXPECTED_TOKEN,
122 [token.lexeme]); 120 [token.lexeme]);
123 121
124 throw new FormatterException([error]); 122 throw new FormatterException([error]);
125 } 123 }
126 } 124 }
127 125
128 errorListener.throwIfErrors(); 126 errorListener.throwIfErrors();
129 127
130 // Format it. 128 // Format it.
131 var visitor = new SourceVisitor(this, lineInfo, source); 129 var visitor = new SourceVisitor(this, lineInfo, source);
132 return visitor.run(node); 130 return visitor.run(node);
133 } 131 }
134 } 132 }
OLDNEW
« CHANGELOG.md ('K') | « CHANGELOG.md ('k') | pubspec.lock » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698