OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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:uri'; | 8 import 'dart:uri'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:utf'; | 10 import 'dart:utf'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 class SourceFileProvider { | 28 class SourceFileProvider { |
29 bool isWindows = (Platform.operatingSystem == 'windows'); | 29 bool isWindows = (Platform.operatingSystem == 'windows'); |
30 Uri cwd = getCurrentDirectory(); | 30 Uri cwd = getCurrentDirectory(); |
31 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; | 31 Map<String, SourceFile> sourceFiles = <String, SourceFile>{}; |
32 int dartBytesRead = 0; | 32 int dartBytesRead = 0; |
33 | 33 |
34 Future<String> readStringFromUri(Uri resourceUri) { | 34 Future<String> readStringFromUri(Uri resourceUri) { |
35 if (resourceUri.scheme != 'file') { | 35 if (resourceUri.scheme != 'file') { |
36 throw new ArgumentError(resourceUri); | 36 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); |
37 } | 37 } |
38 String source; | 38 String source; |
39 try { | 39 try { |
40 source = readAll(uriPathToNative(resourceUri.path)); | 40 source = readAll(uriPathToNative(resourceUri.path)); |
41 } on FileIOException catch (ex) { | 41 } on FileIOException catch (ex) { |
42 throw 'Error: Cannot read "${relativize(cwd, resourceUri, isWindows)}" ' | 42 throw 'Error: Cannot read "${relativize(cwd, resourceUri, isWindows)}" ' |
43 '(${ex.osError}).'; | 43 '(${ex.osError}).'; |
44 } | 44 } |
45 dartBytesRead += source.length; | 45 dartBytesRead += source.length; |
46 sourceFiles[resourceUri.toString()] = | 46 sourceFiles[resourceUri.toString()] = |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 print(file.getLocationMessage(color(message), begin, end, true, color)); | 112 print(file.getLocationMessage(color(message), begin, end, true, color)); |
113 } | 113 } |
114 if (fatal && throwOnError) { | 114 if (fatal && throwOnError) { |
115 isAborting = true; | 115 isAborting = true; |
116 throw new AbortLeg(message); | 116 throw new AbortLeg(message); |
117 } | 117 } |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 | 121 |
OLD | NEW |