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 testDirectory = |
14 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); | 14 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); |
15 | 15 |
| 16 /// The local path to the root directory of the dev_compiler repo. |
| 17 final String repoDirectory = path.dirname(testDirectory); |
| 18 |
16 class _TestUtils {} | 19 class _TestUtils {} |
17 | 20 |
18 class TestUriResolver extends ResourceUriResolver { | 21 class TestUriResolver extends ResourceUriResolver { |
19 final MemoryResourceProvider provider; | 22 final MemoryResourceProvider provider; |
20 TestUriResolver(provider) | 23 TestUriResolver(provider) |
21 : provider = provider, | 24 : provider = provider, |
22 super(provider); | 25 super(provider); |
23 | 26 |
24 @override | 27 @override |
25 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 28 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
26 if (uri.scheme == 'package') { | 29 if (uri.scheme == 'package') { |
27 return (provider.getResource('/packages/' + uri.path) as File) | 30 return (provider.getResource('/packages/' + uri.path) as File) |
28 .createSource(uri); | 31 .createSource(uri); |
29 } | 32 } |
30 return super.resolveAbsolute(uri, actualUri); | 33 return super.resolveAbsolute(uri, actualUri); |
31 } | 34 } |
32 } | 35 } |
OLD | NEW |