OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// Conventions for paths: | 5 /// Conventions for paths: |
6 /// | 6 /// |
7 /// - Use the [Uri] class for paths that may have the `file`, `dart` or | 7 /// - Use the [Uri] class for paths that may have the `file`, `dart` or |
8 /// `package` scheme. Never use [Uri] for relative paths. | 8 /// `package` scheme. Never use [Uri] for relative paths. |
9 /// - Use [String]s for all filenames and paths that have no scheme prefix. | 9 /// - Use [String]s for all filenames and paths that have no scheme prefix. |
10 /// - Never translate a `dart:` or `package:` URI into a `file:` URI, instead | 10 /// - Never translate a `dart:` or `package:` URI into a `file:` URI, instead |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void writeLibraryToText(Library library, {String path}) { | 43 void writeLibraryToText(Library library, {String path}) { |
44 StringBuffer buffer = new StringBuffer(); | 44 StringBuffer buffer = new StringBuffer(); |
45 new Printer(buffer).writeLibraryFile(library); | 45 new Printer(buffer).writeLibraryFile(library); |
46 if (path == null) { | 46 if (path == null) { |
47 print(buffer); | 47 print(buffer); |
48 } else { | 48 } else { |
49 new File(path).writeAsStringSync('$buffer'); | 49 new File(path).writeAsStringSync('$buffer'); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 void writeProgramToText(Program program, {String path, bool showExternal: false}
) { | 53 void writeProgramToText(Program program, |
| 54 {String path, bool showExternal: false}) { |
54 StringBuffer buffer = new StringBuffer(); | 55 StringBuffer buffer = new StringBuffer(); |
55 new Printer(buffer, showExternal: showExternal).writeProgramFile(program); | 56 new Printer(buffer, showExternal: showExternal).writeProgramFile(program); |
56 if (path == null) { | 57 if (path == null) { |
57 print(buffer); | 58 print(buffer); |
58 } else { | 59 } else { |
59 new File(path).writeAsStringSync('$buffer'); | 60 new File(path).writeAsStringSync('$buffer'); |
60 } | 61 } |
61 } | 62 } |
OLD | NEW |