| 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:io'; | 8 import 'dart:io'; |
| 9 import 'dart:utf'; | 9 import 'dart:utf'; |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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') { |
| 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 FileIOException catch (ex) { | 40 } on FileException catch (ex) { |
| 41 throw 'Error: Cannot read "${relativize(cwd, resourceUri, isWindows)}" ' | 41 throw 'Error: Cannot read "${relativize(cwd, resourceUri, isWindows)}" ' |
| 42 '(${ex.osError}).'; | 42 '(${ex.osError}).'; |
| 43 } | 43 } |
| 44 dartCharactersRead += source.length; | 44 dartCharactersRead += source.length; |
| 45 sourceFiles[resourceUri.toString()] = new SourceFile( | 45 sourceFiles[resourceUri.toString()] = new SourceFile( |
| 46 relativize(cwd, resourceUri, isWindows), source); | 46 relativize(cwd, resourceUri, isWindows), source); |
| 47 return new Future.value(source); | 47 return new Future.value(source); |
| 48 } | 48 } |
| 49 | 49 |
| 50 Future<String> call(Uri resourceUri) => readStringFromUri(resourceUri); | 50 Future<String> call(Uri resourceUri) => readStringFromUri(resourceUri); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (fatal && throwOnError) { | 117 if (fatal && throwOnError) { |
| 118 isAborting = true; | 118 isAborting = true; |
| 119 throw new AbortLeg(message); | 119 throw new AbortLeg(message); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { | 123 void call(Uri uri, int begin, int end, String message, api.Diagnostic kind) { |
| 124 return diagnosticHandler(uri, begin, end, message, kind); | 124 return diagnosticHandler(uri, begin, end, message, kind); |
| 125 } | 125 } |
| 126 } | 126 } |
| OLD | NEW |