Chromium Code Reviews| 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:io'; | 8 import 'dart:io'; |
| 9 export 'dart:io' show Platform; | 9 export 'dart:io' show Platform; |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 class MemorySourceFileProvider extends SourceFileProvider { | 26 class MemorySourceFileProvider extends SourceFileProvider { |
| 27 final Map<String, String> memorySourceFiles; | 27 final Map<String, String> memorySourceFiles; |
| 28 | 28 |
| 29 MemorySourceFileProvider(Map<String, String> this.memorySourceFiles); | 29 MemorySourceFileProvider(Map<String, String> this.memorySourceFiles); |
| 30 | 30 |
| 31 Future<String> readStringFromUri(Uri resourceUri) { | 31 Future<String> readStringFromUri(Uri resourceUri) { |
| 32 if (resourceUri.scheme != 'memory') { | 32 if (resourceUri.scheme != 'memory') { |
| 33 return super.readStringFromUri(resourceUri); | 33 return super.readStringFromUri(resourceUri); |
| 34 } | 34 } |
| 35 String source = memorySourceFiles[resourceUri.path]; | 35 String source = memorySourceFiles[resourceUri.path]; |
| 36 // TODO(ahe): Return new Future.error(...) ? | 36 if (source == null) { |
| 37 if (source == null) return new Future.error('No such file $resourceUri'); | 37 return new Future.error(new Exception('No such file $resourceUri')); |
|
ahe
2013/09/10 10:50:28
Why do you need to wrap this in an exception?
Johnni Winther
2013/09/10 11:41:53
I don't need to, but I found the type error in rep
| |
| 38 } | |
| 38 String resourceName = '$resourceUri'; | 39 String resourceName = '$resourceUri'; |
| 39 this.sourceFiles[resourceName] = new SourceFile(resourceName, source); | 40 this.sourceFiles[resourceName] = new SourceFile(resourceName, source); |
| 40 return new Future.value(source); | 41 return new Future.value(source); |
| 41 } | 42 } |
| 42 } | 43 } |
| OLD | NEW |