| 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 dart2js.test.memory_source_file_helper; | 5 library dart2js.test.memory_source_file_helper; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 import 'dart:uri' show Uri; | 8 import 'dart:uri' show Uri; |
| 9 export 'dart:uri' show Uri; | 9 export 'dart:uri' show Uri; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 export '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart' | 25 export '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart' |
| 26 show FormattingDiagnosticHandler; | 26 show FormattingDiagnosticHandler; |
| 27 | 27 |
| 28 class MemorySourceFileProvider extends SourceFileProvider { | 28 class MemorySourceFileProvider extends SourceFileProvider { |
| 29 static Map MEMORY_SOURCE_FILES; | 29 static Map MEMORY_SOURCE_FILES; |
| 30 Future<String> readStringFromUri(Uri resourceUri) { | 30 Future<String> readStringFromUri(Uri resourceUri) { |
| 31 if (resourceUri.scheme != 'memory') { | 31 if (resourceUri.scheme != 'memory') { |
| 32 return super.readStringFromUri(resourceUri); | 32 return super.readStringFromUri(resourceUri); |
| 33 } | 33 } |
| 34 String source = MEMORY_SOURCE_FILES[resourceUri.path]; | 34 String source = MEMORY_SOURCE_FILES[resourceUri.path]; |
| 35 // TODO(ahe): Return new Future.immediateError(...) ? | 35 // TODO(ahe): Return new Future.error(...) ? |
| 36 if (source == null) throw 'No such file $resourceUri'; | 36 if (source == null) throw 'No such file $resourceUri'; |
| 37 String resourceName = '$resourceUri'; | 37 String resourceName = '$resourceUri'; |
| 38 this.sourceFiles[resourceName] = new SourceFile(resourceName, source); | 38 this.sourceFiles[resourceName] = new SourceFile(resourceName, source); |
| 39 return new Future.immediate(source); | 39 return new Future.value(source); |
| 40 } | 40 } |
| 41 } | 41 } |
| OLD | NEW |