OLD | NEW |
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 source_file_provider; | 5 library source_file_provider; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; |
8 import 'dart:io'; | 9 import 'dart:io'; |
9 import 'dart:utf'; | |
10 | 10 |
11 import '../compiler.dart' as api show Diagnostic; | 11 import '../compiler.dart' as api show Diagnostic; |
12 import 'dart2js.dart' show AbortLeg; | 12 import 'dart2js.dart' show AbortLeg; |
13 import 'colors.dart' as colors; | 13 import 'colors.dart' as colors; |
14 import 'source_file.dart'; | 14 import 'source_file.dart'; |
15 import 'filenames.dart'; | 15 import 'filenames.dart'; |
16 import 'util/uri_extras.dart'; | 16 import 'util/uri_extras.dart'; |
17 | 17 |
18 String readAll(String filename) { | 18 String readAll(String filename) { |
19 var file = (new File(filename)).openSync(); | 19 var file = (new File(filename)).openSync(); |
20 var length = file.lengthSync(); | 20 var length = file.lengthSync(); |
21 var buffer = new List<int>(length); | 21 var buffer = new List<int>(length); |
22 var bytes = file.readIntoSync(buffer, 0, length); | 22 var bytes = file.readIntoSync(buffer, 0, length); |
23 file.closeSync(); | 23 file.closeSync(); |
24 return new String.fromCharCodes(new Utf8Decoder(buffer).decodeRest()); | 24 return UTF8.decode(buffer); |
25 } | 25 } |
26 | 26 |
27 class SourceFileProvider { | 27 class SourceFileProvider { |
28 bool isWindows = (Platform.operatingSystem == 'windows'); | 28 bool isWindows = (Platform.operatingSystem == 'windows'); |
29 Uri cwd = currentDirectory; | 29 Uri cwd = currentDirectory; |
30 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; | 30 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; |
31 int dartCharactersRead = 0; | 31 int dartCharactersRead = 0; |
32 | 32 |
33 Future<String> readStringFromUri(Uri resourceUri) { | 33 Future<String> readStringFromUri(Uri resourceUri) { |
34 if (resourceUri.scheme != 'file') { | 34 if (resourceUri.scheme != 'file') { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (fatal && throwOnError) { | 131 if (fatal && throwOnError) { |
132 isAborting = true; | 132 isAborting = true; |
133 throw new AbortLeg(message); | 133 throw new AbortLeg(message); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { | 137 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
138 return diagnosticHandler(uri, begin, end, message, kind); | 138 return diagnosticHandler(uri, begin, end, message, kind); |
139 } | 139 } |
140 } | 140 } |
OLD | NEW |