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:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
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') { |
35 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); | 35 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); |
36 } | 36 } |
37 String source; | 37 String source; |
38 try { | 38 try { |
39 source = readAll(uriPathToNative(resourceUri.path)); | 39 source = readAll(uriPathToNative(resourceUri.path)); |
40 } on FileException catch (ex) { | 40 } on FileException catch (ex) { |
41 throw "Error reading '${relativize(cwd, resourceUri, isWindows)}' " | 41 return new Future.error( |
42 "(${ex.osError})"; | 42 "Error reading '${relativize(cwd, resourceUri, isWindows)}' " |
| 43 "(${ex.osError})"); |
43 } | 44 } |
44 dartCharactersRead += source.length; | 45 dartCharactersRead += source.length; |
45 sourceFiles[resourceUri.toString()] = new SourceFile( | 46 sourceFiles[resourceUri.toString()] = new SourceFile( |
46 relativize(cwd, resourceUri, isWindows), source); | 47 relativize(cwd, resourceUri, isWindows), source); |
47 return new Future.value(source); | 48 return new Future.value(source); |
48 } | 49 } |
49 | 50 |
50 Future<String> call(Uri resourceUri) => readStringFromUri(resourceUri); | 51 Future<String> call(Uri resourceUri) => readStringFromUri(resourceUri); |
51 } | 52 } |
52 | 53 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (fatal && throwOnError) { | 132 if (fatal && throwOnError) { |
132 isAborting = true; | 133 isAborting = true; |
133 throw new AbortLeg(message); | 134 throw new AbortLeg(message); |
134 } | 135 } |
135 } | 136 } |
136 | 137 |
137 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { | 138 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
138 return diagnosticHandler(uri, begin, end, message, kind); | 139 return diagnosticHandler(uri, begin, end, message, kind); |
139 } | 140 } |
140 } | 141 } |
OLD | NEW |