| Index: pkg/analyzer/test/src/dart/analysis/file_state_test.dart
|
| diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
|
| index f9433fec822b5858ee72e56538bbbb6a717fa21e..c4c8d4a6fc754a91acc787b14da0c3170c504cf1 100644
|
| --- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
|
| +++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
|
| @@ -58,6 +58,169 @@ class FileSystemStateTest {
|
| provider, sourceFactory, analysisOptions, new Uint32List(0), '');
|
| }
|
|
|
| + test_exportTopLevelDeclarations_export() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class A {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +export 'a.dart';
|
| +class B {}
|
| +''');
|
| + FileState file = fileSystemState.getFileForPath(b);
|
| + List<TopLevelDeclaration> declarations = file.exportTopLevelDeclarations;
|
| + expect(declarations.map((t) => t.name), unorderedEquals(['A', 'B']));
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_export2_show() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + String c = _p('/aaa/lib/c.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class A1 {}
|
| +class A2 {}
|
| +class A3 {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +export 'a.dart' show A1, A2;
|
| +class B1 {}
|
| +class B2 {}
|
| +''');
|
| + provider.newFile(
|
| + c,
|
| + r'''
|
| +export 'b.dart' show A2, A3, B1;
|
| +class C {}
|
| +''');
|
| + _assertExportedTopLevelDeclarations(c, ['A2', 'B1', 'C']);
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_export_flushOnChange() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class A {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +export 'a.dart';
|
| +class B {}
|
| +''');
|
| +
|
| + // Initial exported declarations.
|
| + _assertExportedTopLevelDeclarations(b, ['A', 'B']);
|
| +
|
| + // Update a.dart, so a.dart and b.dart exported declarations are flushed.
|
| + provider.newFile(a, 'class A {} class A2 {}');
|
| + fileSystemState.getFileForPath(a).refresh();
|
| + _assertExportedTopLevelDeclarations(b, ['A', 'A2', 'B']);
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_export_hide() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class A1 {}
|
| +class A2 {}
|
| +class A3 {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +export 'a.dart' hide A2;
|
| +class B {}
|
| +''');
|
| + _assertExportedTopLevelDeclarations(b, ['A1', 'A3', 'B']);
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_export_preferLocal() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class V {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +export 'a.dart';
|
| +int V;
|
| +''');
|
| + FileState file = fileSystemState.getFileForPath(b);
|
| + List<TopLevelDeclaration> declarations = file.exportTopLevelDeclarations;
|
| + expect(declarations.map((t) => t.name), unorderedEquals(['V']));
|
| + expect(declarations.single.kind, TopLevelDeclarationKind.variable);
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_export_show() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class A1 {}
|
| +class A2 {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +export 'a.dart' show A2;
|
| +class B {}
|
| +''');
|
| + _assertExportedTopLevelDeclarations(b, ['A2', 'B']);
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_import() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String b = _p('/aaa/lib/b.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +class A {}
|
| +''');
|
| + provider.newFile(
|
| + b,
|
| + r'''
|
| +import 'a.dart';
|
| +class B {}
|
| +''');
|
| + _assertExportedTopLevelDeclarations(b, ['B']);
|
| + }
|
| +
|
| + test_exportTopLevelDeclarations_parts() {
|
| + String a = _p('/aaa/lib/a.dart');
|
| + String a2 = _p('/aaa/lib/a2.dart');
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +library lib;
|
| +part 'a2.dart';
|
| +class A1 {}
|
| +''');
|
| + provider.newFile(
|
| + a2,
|
| + r'''
|
| +part of lib;
|
| +class A2 {}
|
| +''');
|
| + _assertExportedTopLevelDeclarations(a, ['A1', 'A2']);
|
| + }
|
| +
|
| test_getFileForPath_doesNotExist() {
|
| String path = _p('/aaa/lib/a.dart');
|
| FileState file = fileSystemState.getFileForPath(path);
|
| @@ -433,6 +596,12 @@ set V4(_) {}
|
| _assertFilesWithoutTransitiveSignatures([fa, fb, fc]);
|
| }
|
|
|
| + void _assertExportedTopLevelDeclarations(String path, List<String> expected) {
|
| + FileState file = fileSystemState.getFileForPath(path);
|
| + List<TopLevelDeclaration> declarations = file.exportTopLevelDeclarations;
|
| + expect(declarations.map((t) => t.name), unorderedEquals(expected));
|
| + }
|
| +
|
| void _assertFilesWithoutTransitiveFiles(List<FileState> expected) {
|
| var actual = fileSystemState.test.filesWithoutTransitiveFiles;
|
| expect(actual, unorderedEquals(expected));
|
|
|