| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dev_compiler.src.testing; | 5 library dev_compiler.src.testing; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
| 9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| 11 import 'package:path/path.dart' as path; | 11 import 'package:path/path.dart' as path; |
| 12 | 12 |
| 13 final String testDirectory = | 13 final String testingPath = |
| 14 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); | 14 path.fromUri((reflectClass(_TestUtils).owner as LibraryMirror).uri); |
| 15 final String testDirectory = path.dirname(testingPath); |
| 15 | 16 |
| 16 /// The local path to the root directory of the dev_compiler repo. | 17 /// The local path to the root directory of the dev_compiler repo. |
| 17 final String repoDirectory = path.dirname(testDirectory); | 18 final String repoDirectory = path.dirname(testDirectory); |
| 18 | 19 |
| 19 class _TestUtils {} | 20 class _TestUtils {} |
| 20 | 21 |
| 21 class TestUriResolver extends ResourceUriResolver { | 22 class TestUriResolver extends ResourceUriResolver { |
| 22 final MemoryResourceProvider provider; | 23 final MemoryResourceProvider provider; |
| 23 TestUriResolver(provider) | 24 TestUriResolver(provider) |
| 24 : provider = provider, | 25 : provider = provider, |
| 25 super(provider); | 26 super(provider); |
| 26 | 27 |
| 27 @override | 28 @override |
| 28 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 29 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 29 if (uri.scheme == 'package') { | 30 if (uri.scheme == 'package') { |
| 30 return (provider.getResource('/packages/' + uri.path) as File) | 31 return (provider.getResource('/packages/' + uri.path) as File) |
| 31 .createSource(uri); | 32 .createSource(uri); |
| 32 } | 33 } |
| 33 return super.resolveAbsolute(uri, actualUri); | 34 return super.resolveAbsolute(uri, actualUri); |
| 34 } | 35 } |
| 35 } | 36 } |
| OLD | NEW |