| Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
|
| diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
|
| index 90e3f38e4b5effd844020df317ba40eeab22eb0a..018ffafaf5113be653a13722e96d2e622ca65275 100644
|
| --- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
|
| +++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
|
| @@ -12,6 +12,8 @@ import 'package:analyzer/dart/ast/visitor.dart';
|
| import 'package:analyzer/dart/element/element.dart';
|
| import 'package:analyzer/dart/element/type.dart';
|
| import 'package:analyzer/src/dart/analysis/driver.dart';
|
| +import 'package:analyzer/src/generated/parser.dart';
|
| +import 'package:analyzer/src/generated/scanner.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/generated/utilities_dart.dart';
|
| import 'package:front_end/src/base/instrumentation.dart' as fasta;
|
| @@ -141,7 +143,7 @@ class _FrontEndInferenceTest extends BaseAnalysisDriverTest {
|
| var validation = new fasta.ValidatingInstrumentation();
|
| await validation.loadExpectations(uri);
|
|
|
| - provider.newFile(path, code);
|
| + _addFileAndImports(path, code);
|
|
|
| AnalysisResult result = await driver.getResult(path);
|
| result.unit.accept(new _InstrumentationVisitor(validation, uri));
|
| @@ -159,6 +161,37 @@ class _FrontEndInferenceTest extends BaseAnalysisDriverTest {
|
| return null;
|
| }
|
| }
|
| +
|
| + void _addFileAndImports(String path, String code) {
|
| + provider.newFile(path, code);
|
| + var source = null;
|
| + var analysisErrorListener = null;
|
| + var scanner = new Scanner(
|
| + source, new CharSequenceReader(code), analysisErrorListener);
|
| + var token = scanner.tokenize();
|
| + var compilationUnit =
|
| + new Parser(source, analysisErrorListener).parseDirectives(token);
|
| + for (var directive in compilationUnit.directives) {
|
| + if (directive is UriBasedDirective) {
|
| + Uri uri = Uri.parse(directive.uri.stringValue);
|
| + if (uri.scheme == 'dart') {
|
| + // Ignore these--they should be in the mock SDK.
|
| + } else if (uri.scheme == '') {
|
| + var pathSegments = uri.pathSegments;
|
| + // For these tests we don't support any directory traversal; we just
|
| + // assume the URI is the name of a file in the same directory as all
|
| + // the other tests.
|
| + if (pathSegments.length != 1) fail('URI too complex: $uri');
|
| + var referencedPath =
|
| + pathos.join(pathos.dirname(path), pathSegments[0]);
|
| + if (!provider.getFile(referencedPath).exists) {
|
| + var referencedCode = new File(referencedPath).readAsStringSync();
|
| + _addFileAndImports(referencedPath, referencedCode);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + }
|
| }
|
|
|
| /// Instance of [InstrumentationValue] describing an [ExecutableElement].
|
|
|