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

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

Issue 2174753003: Avoid passing an invalid file URI to analyzer on Windows. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « CHANGELOG.md ('k') | no next file » | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 DartFormatter({this.lineEnding, int pageWidth, this.indent: 0}) 45 DartFormatter({this.lineEnding, int pageWidth, this.indent: 0})
46 : this.pageWidth = (pageWidth == null) ? 80 : pageWidth; 46 : this.pageWidth = (pageWidth == null) ? 80 : pageWidth;
47 47
48 /// Formats the given [source] string containing an entire Dart compilation 48 /// Formats the given [source] string containing an entire Dart compilation
49 /// unit. 49 /// unit.
50 /// 50 ///
51 /// If [uri] is given, it is a [String] or [Uri] used to identify the file 51 /// If [uri] is given, it is a [String] or [Uri] used to identify the file
52 /// being formatted in error messages. 52 /// being formatted in error messages.
53 String format(String source, {uri}) { 53 String format(String source, {uri}) {
54 if (uri == null) { 54 if (uri == null) {
55 uri = "<unknown>"; 55 // Do nothing.
56 } else if (uri is Uri) { 56 } else if (uri is Uri) {
57 uri = uri.toString(); 57 uri = uri.toString();
58 } else if (uri is String) { 58 } else if (uri is String) {
59 // Do nothing. 59 // Do nothing.
60 } else { 60 } else {
61 throw new ArgumentError("uri must be `null`, a Uri, or a String."); 61 throw new ArgumentError("uri must be `null`, a Uri, or a String.");
62 } 62 }
63 63
64 return formatSource( 64 return formatSource(
65 new SourceCode(source, uri: uri, isCompilationUnit: true)) 65 new SourceCode(source, uri: uri, isCompilationUnit: true))
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 } 126 }
127 127
128 errorListener.throwIfErrors(); 128 errorListener.throwIfErrors();
129 129
130 // Format it. 130 // Format it.
131 var visitor = new SourceVisitor(this, lineInfo, source); 131 var visitor = new SourceVisitor(this, lineInfo, source);
132 return visitor.run(node); 132 return visitor.run(node);
133 } 133 }
134 } 134 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698