| 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 26 matching lines...) Expand all Loading... |
| 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(resourceUri.toFilePath()); | 45 source = readAll(resourceUri.toFilePath()); |
| 46 } on FileSystemException catch (ex) { | 46 } on FileSystemException catch (ex) { |
| 47 sourceFiles[resourceUri.toString()] = null; | |
| 48 return new Future.error( | 47 return new Future.error( |
| 49 "Error reading '${relativize(cwd, resourceUri, isWindows)}' " | 48 "Error reading '${relativize(cwd, resourceUri, isWindows)}' " |
| 50 "(${ex.osError})"); | 49 "(${ex.osError})"); |
| 51 } | 50 } |
| 52 dartCharactersRead += source.length; | 51 dartCharactersRead += source.length; |
| 53 sourceFiles[resourceUri.toString()] = new Utf8BytesSourceFile( | 52 sourceFiles[resourceUri.toString()] = new Utf8BytesSourceFile( |
| 54 relativize(cwd, resourceUri, isWindows), source); | 53 relativize(cwd, resourceUri, isWindows), source); |
| 55 return new Future.value(source); | 54 return new Future.value(source); |
| 56 } | 55 } |
| 57 | 56 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 if (fatal && throwOnError) { | 164 if (fatal && throwOnError) { |
| 166 isAborting = true; | 165 isAborting = true; |
| 167 throw new AbortLeg(message); | 166 throw new AbortLeg(message); |
| 168 } | 167 } |
| 169 } | 168 } |
| 170 | 169 |
| 171 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { | 170 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
| 172 return diagnosticHandler(uri, begin, end, message, kind); | 171 return diagnosticHandler(uri, begin, end, message, kind); |
| 173 } | 172 } |
| 174 } | 173 } |
| OLD | NEW |