| 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 25 matching lines...) Expand all Loading... |
| 36 return readUtf8BytesFromUri(resourceUri).then(UTF8.decode); | 36 return readUtf8BytesFromUri(resourceUri).then(UTF8.decode); |
| 37 } | 37 } |
| 38 | 38 |
| 39 Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) { | 39 Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) { |
| 40 if (resourceUri.scheme != 'file') { | 40 if (resourceUri.scheme != 'file') { |
| 41 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); | 41 throw new ArgumentError("Unknown scheme in uri '$resourceUri'"); |
| 42 } | 42 } |
| 43 List<int> source; | 43 List<int> source; |
| 44 try { | 44 try { |
| 45 source = readAll(uriPathToNative(resourceUri.path)); | 45 source = readAll(uriPathToNative(resourceUri.path)); |
| 46 } on FileException catch (ex) { | 46 } on FileSystemException catch (ex) { |
| 47 return new Future.error( | 47 return new Future.error( |
| 48 "Error reading '${relativize(cwd, resourceUri, isWindows)}' " | 48 "Error reading '${relativize(cwd, resourceUri, isWindows)}' " |
| 49 "(${ex.osError})"); | 49 "(${ex.osError})"); |
| 50 } | 50 } |
| 51 dartCharactersRead += source.length; | 51 dartCharactersRead += source.length; |
| 52 sourceFiles[resourceUri.toString()] = new Utf8BytesSourceFile( | 52 sourceFiles[resourceUri.toString()] = new Utf8BytesSourceFile( |
| 53 relativize(cwd, resourceUri, isWindows), source); | 53 relativize(cwd, resourceUri, isWindows), source); |
| 54 return new Future.value(source); | 54 return new Future.value(source); |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (fatal && throwOnError) { | 142 if (fatal && throwOnError) { |
| 143 isAborting = true; | 143 isAborting = true; |
| 144 throw new AbortLeg(message); | 144 throw new AbortLeg(message); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { | 148 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
| 149 return diagnosticHandler(uri, begin, end, message, kind); | 149 return diagnosticHandler(uri, begin, end, message, kind); |
| 150 } | 150 } |
| 151 } | 151 } |
| OLD | NEW |