| Index: pkg/analyzer/test/src/dart/analysis/driver_test.dart
|
| diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
|
| index 30f87f08b7b8176606813e156a1c851f3454ed08..846ebbe721c6641b7709f0a6b5d72ed47413a309 100644
|
| --- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
|
| +++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
|
| @@ -896,31 +896,53 @@ var A2 = B1;
|
| driver.addFile(c);
|
| // Don't add d.dart, it is referenced implicitly.
|
|
|
| - void assertDeclarations(List<TopLevelDeclarationInSource> declarations,
|
| - List<String> expectedFiles, List<bool> expectedIsExported) {
|
| - expect(expectedFiles, hasLength(expectedIsExported.length));
|
| - for (int i = 0; i < expectedFiles.length; i++) {
|
| - expect(declarations,
|
| - contains(predicate((TopLevelDeclarationInSource declaration) {
|
| - return declaration.source.fullName == expectedFiles[i] &&
|
| - declaration.isExported == expectedIsExported[i];
|
| - })));
|
| - }
|
| - }
|
| -
|
| - assertDeclarations(
|
| + _assertTopLevelDeclarations(
|
| await driver.getTopLevelNameDeclarations('A'), [a, b], [false, true]);
|
|
|
| - assertDeclarations(
|
| + _assertTopLevelDeclarations(
|
| await driver.getTopLevelNameDeclarations('B'), [b], [false]);
|
|
|
| - assertDeclarations(
|
| + _assertTopLevelDeclarations(
|
| await driver.getTopLevelNameDeclarations('C'), [c], [false]);
|
|
|
| - assertDeclarations(
|
| + _assertTopLevelDeclarations(
|
| await driver.getTopLevelNameDeclarations('D'), [d], [false]);
|
|
|
| - assertDeclarations(await driver.getTopLevelNameDeclarations('X'), [], []);
|
| + _assertTopLevelDeclarations(
|
| + await driver.getTopLevelNameDeclarations('X'), [], []);
|
| + }
|
| +
|
| + test_getTopLevelNameDeclarations_parts() async {
|
| + var a = _p('/test/lib/a.dart');
|
| + var b = _p('/test/lib/b.dart');
|
| + var c = _p('/test/lib/c.dart');
|
| +
|
| + provider.newFile(
|
| + a,
|
| + r'''
|
| +library lib;
|
| +part 'b.dart';
|
| +part 'c.dart';
|
| +class A {}
|
| +''');
|
| + provider.newFile(b, 'part of lib; class B {}');
|
| + provider.newFile(c, 'part of lib; class C {}');
|
| +
|
| + driver.addFile(a);
|
| + driver.addFile(b);
|
| + driver.addFile(c);
|
| +
|
| + _assertTopLevelDeclarations(
|
| + await driver.getTopLevelNameDeclarations('A'), [a], [false]);
|
| +
|
| + _assertTopLevelDeclarations(
|
| + await driver.getTopLevelNameDeclarations('B'), [a], [false]);
|
| +
|
| + _assertTopLevelDeclarations(
|
| + await driver.getTopLevelNameDeclarations('C'), [a], [false]);
|
| +
|
| + _assertTopLevelDeclarations(
|
| + await driver.getTopLevelNameDeclarations('X'), [], []);
|
| }
|
|
|
| test_getUnitElement() async {
|
| @@ -1430,6 +1452,20 @@ var A = B;
|
| expect(allStatuses[1].isIdle, isTrue);
|
| }
|
|
|
| + void _assertTopLevelDeclarations(
|
| + List<TopLevelDeclarationInSource> declarations,
|
| + List<String> expectedFiles,
|
| + List<bool> expectedIsExported) {
|
| + expect(expectedFiles, hasLength(expectedIsExported.length));
|
| + for (int i = 0; i < expectedFiles.length; i++) {
|
| + expect(declarations,
|
| + contains(predicate((TopLevelDeclarationInSource declaration) {
|
| + return declaration.source.fullName == expectedFiles[i] &&
|
| + declaration.isExported == expectedIsExported[i];
|
| + })));
|
| + }
|
| + }
|
| +
|
| ClassDeclaration _getClass(CompilationUnit unit, String name) {
|
| for (CompilationUnitMember declaration in unit.declarations) {
|
| if (declaration is ClassDeclaration) {
|
|
|