| Index: pkg/analysis_server/test/context_manager_test.dart
|
| diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
|
| index af43b51be53722ed1c34fe61fd99ca73b480e2db..0b0d7ce5a6c23b2892516e51746baed67cff6204 100644
|
| --- a/pkg/analysis_server/test/context_manager_test.dart
|
| +++ b/pkg/analysis_server/test/context_manager_test.dart
|
| @@ -7,8 +7,6 @@ library test.context.directory.manager;
|
| import 'dart:collection';
|
|
|
| import 'package:analysis_server/src/context_manager.dart';
|
| -import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.dart';
|
| -import 'package:analysis_server/uri/resolver_provider.dart';
|
| import 'package:analyzer/file_system/file_system.dart';
|
| import 'package:analyzer/file_system/memory_file_system.dart';
|
| import 'package:analyzer/instrumentation/instrumentation.dart';
|
| @@ -55,7 +53,9 @@ class AbstractContextManagerTest {
|
| */
|
| static const String TEST_NAME = 'test';
|
|
|
| - TestContextManager manager;
|
| + ContextManagerImpl manager;
|
| +
|
| + TestContextManagerCallbacks callbacks;
|
|
|
| MemoryResourceProvider resourceProvider;
|
|
|
| @@ -84,14 +84,16 @@ class AbstractContextManagerTest {
|
| void setUp() {
|
| resourceProvider = new MemoryResourceProvider();
|
| packageMapProvider = new MockPackageMapProvider();
|
| - manager = new TestContextManager(
|
| - resourceProvider, providePackageResolver, packageMapProvider);
|
| + manager = new ContextManagerImpl(resourceProvider, providePackageResolver,
|
| + packageMapProvider, InstrumentationService.NULL_SERVICE);
|
| + callbacks = new TestContextManagerCallbacks();
|
| + manager.callbacks = callbacks;
|
| resourceProvider.newFolder(projPath);
|
| - AbstractContextManager.ENABLE_PACKAGESPEC_SUPPORT = true;
|
| + ContextManagerImpl.ENABLE_PACKAGESPEC_SUPPORT = true;
|
| }
|
|
|
| void tearDown() {
|
| - AbstractContextManager.ENABLE_PACKAGESPEC_SUPPORT = false;
|
| + ContextManagerImpl.ENABLE_PACKAGESPEC_SUPPORT = false;
|
| }
|
|
|
| test_ignoreFilesInPackagesFolder() {
|
| @@ -103,12 +105,12 @@ class AbstractContextManagerTest {
|
| resourceProvider.newFile(filePath1, 'contents');
|
| // "packages" files are ignored initially
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - expect(manager.currentContextFilePaths[projPath], isEmpty);
|
| + expect(callbacks.currentContextFilePaths[projPath], isEmpty);
|
| // "packages" files are ignored during watch
|
| String filePath2 = posix.join(projPath, 'packages', 'file2.dart');
|
| resourceProvider.newFile(filePath2, 'contents');
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextFilePaths[projPath], isEmpty);
|
| + expect(callbacks.currentContextFilePaths[projPath], isEmpty);
|
| });
|
| }
|
|
|
| @@ -135,18 +137,73 @@ class AbstractContextManagerTest {
|
| expect(manager.isInAnalysisRoot('/test.dart'), isFalse);
|
| }
|
|
|
| + test_path_filter() async {
|
| + // Setup context.
|
| + Folder root = resourceProvider.newFolder(projPath);
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| + expect(callbacks.currentContextFilePaths[projPath], isEmpty);
|
| + // Set ignore patterns for context.
|
| + manager.setIgnorePatternsForContext(
|
| + root, ['sdk_ext/**', 'lib/ignoreme.dart']);
|
| + // Start creating files.
|
| + newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]);
|
| + String libPath = newFolder([projPath, LIB_NAME]);
|
| + newFile([libPath, 'main.dart']);
|
| + newFile([libPath, 'ignoreme.dart']);
|
| + String sdkExtPath = newFolder([projPath, 'sdk_ext']);
|
| + newFile([sdkExtPath, 'entry.dart']);
|
| + String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
|
| + newFile([sdkExtSrcPath, 'part.dart']);
|
| + // Pump event loop so new files are discovered and added to context.
|
| + await pumpEventQueue();
|
| + // Verify that ignored files were ignored.
|
| + Map<String, int> fileTimestamps =
|
| + callbacks.currentContextFilePaths[projPath];
|
| + expect(fileTimestamps, isNotEmpty);
|
| + List<String> files = fileTimestamps.keys.toList();
|
| + expect(files.length, equals(1));
|
| + expect(files[0], equals('/my/proj/lib/main.dart'));
|
| + }
|
| +
|
| + test_path_filter_analysis_option() async {
|
| + // Create files.
|
| + String libPath = newFolder([projPath, LIB_NAME]);
|
| + newFile([libPath, 'main.dart']);
|
| + newFile([libPath, 'nope.dart']);
|
| + String sdkExtPath = newFolder([projPath, 'sdk_ext']);
|
| + newFile([sdkExtPath, 'entry.dart']);
|
| + String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
|
| + newFile([sdkExtSrcPath, 'part.dart']);
|
| + // Setup analysis options file with ignore list.
|
| + newFile([projPath, '.analysis_options'], r'''
|
| +analyzer:
|
| + exclude:
|
| + - lib/nope.dart
|
| + - 'sdk_ext/**'
|
| +''');
|
| + // Setup context.
|
| + manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| + // Verify that analysis options was parsed and the ignore patterns applied.
|
| + Map<String, int> fileTimestamps =
|
| + callbacks.currentContextFilePaths[projPath];
|
| + expect(fileTimestamps, isNotEmpty);
|
| + List<String> files = fileTimestamps.keys.toList();
|
| + expect(files.length, equals(1));
|
| + expect(files[0], equals('/my/proj/lib/main.dart'));
|
| + }
|
| +
|
| test_refresh_folder_with_packagespec() {
|
| // create a context with a .packages file
|
| String packagespecFile = posix.join(projPath, '.packages');
|
| resourceProvider.newFile(packagespecFile, '');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toList(), [projPath]);
|
| - manager.now++;
|
| + expect(callbacks.currentContextPaths.toList(), [projPath]);
|
| + callbacks.now++;
|
| manager.refresh(null);
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toList(), [projPath]);
|
| - expect(manager.currentContextTimestamps[projPath], manager.now);
|
| + expect(callbacks.currentContextPaths.toList(), [projPath]);
|
| + expect(callbacks.currentContextTimestamps[projPath], callbacks.now);
|
| });
|
| });
|
| }
|
| @@ -162,16 +219,16 @@ class AbstractContextManagerTest {
|
| resourceProvider.newFile(packagespec2Path, '');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toSet(),
|
| + expect(callbacks.currentContextPaths.toSet(),
|
| [subdir1Path, subdir2Path, projPath].toSet());
|
| - manager.now++;
|
| + callbacks.now++;
|
| manager.refresh(null);
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toSet(),
|
| + expect(callbacks.currentContextPaths.toSet(),
|
| [subdir1Path, subdir2Path, projPath].toSet());
|
| - expect(manager.currentContextTimestamps[projPath], manager.now);
|
| - expect(manager.currentContextTimestamps[subdir1Path], manager.now);
|
| - expect(manager.currentContextTimestamps[subdir2Path], manager.now);
|
| + expect(callbacks.currentContextTimestamps[projPath], callbacks.now);
|
| + expect(callbacks.currentContextTimestamps[subdir1Path], callbacks.now);
|
| + expect(callbacks.currentContextTimestamps[subdir2Path], callbacks.now);
|
| });
|
| });
|
| }
|
| @@ -182,12 +239,12 @@ class AbstractContextManagerTest {
|
| resourceProvider.newFile(pubspecPath, 'pubspec');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toList(), [projPath]);
|
| - manager.now++;
|
| + expect(callbacks.currentContextPaths.toList(), [projPath]);
|
| + callbacks.now++;
|
| manager.refresh(null);
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toList(), [projPath]);
|
| - expect(manager.currentContextTimestamps[projPath], manager.now);
|
| + expect(callbacks.currentContextPaths.toList(), [projPath]);
|
| + expect(callbacks.currentContextTimestamps[projPath], callbacks.now);
|
| });
|
| });
|
| }
|
| @@ -203,73 +260,20 @@ class AbstractContextManagerTest {
|
| resourceProvider.newFile(pubspec2Path, 'pubspec');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toSet(),
|
| + expect(callbacks.currentContextPaths.toSet(),
|
| [subdir1Path, subdir2Path, projPath].toSet());
|
| - manager.now++;
|
| + callbacks.now++;
|
| manager.refresh(null);
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toSet(),
|
| + expect(callbacks.currentContextPaths.toSet(),
|
| [subdir1Path, subdir2Path, projPath].toSet());
|
| - expect(manager.currentContextTimestamps[projPath], manager.now);
|
| - expect(manager.currentContextTimestamps[subdir1Path], manager.now);
|
| - expect(manager.currentContextTimestamps[subdir2Path], manager.now);
|
| + expect(callbacks.currentContextTimestamps[projPath], callbacks.now);
|
| + expect(callbacks.currentContextTimestamps[subdir1Path], callbacks.now);
|
| + expect(callbacks.currentContextTimestamps[subdir2Path], callbacks.now);
|
| });
|
| });
|
| }
|
|
|
| - test_path_filter() async {
|
| - // Setup context.
|
| - Folder root = resourceProvider.newFolder(projPath);
|
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - expect(manager.currentContextFilePaths[projPath], isEmpty);
|
| - // Set ignore patterns for context.
|
| - manager.setIgnorePatternsForContext(
|
| - root, ['sdk_ext/**', 'lib/ignoreme.dart']);
|
| - // Start creating files.
|
| - newFile([projPath, AbstractContextManager.PUBSPEC_NAME]);
|
| - String libPath = newFolder([projPath, LIB_NAME]);
|
| - newFile([libPath, 'main.dart']);
|
| - newFile([libPath, 'ignoreme.dart']);
|
| - String sdkExtPath = newFolder([projPath, 'sdk_ext']);
|
| - newFile([sdkExtPath, 'entry.dart']);
|
| - String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
|
| - newFile([sdkExtSrcPath, 'part.dart']);
|
| - // Pump event loop so new files are discovered and added to context.
|
| - await pumpEventQueue();
|
| - // Verify that ignored files were ignored.
|
| - Map<String, int> fileTimestamps = manager.currentContextFilePaths[projPath];
|
| - expect(fileTimestamps, isNotEmpty);
|
| - List<String> files = fileTimestamps.keys.toList();
|
| - expect(files.length, equals(1));
|
| - expect(files[0], equals('/my/proj/lib/main.dart'));
|
| - }
|
| -
|
| - test_path_filter_analysis_option() async {
|
| - // Create files.
|
| - String libPath = newFolder([projPath, LIB_NAME]);
|
| - newFile([libPath, 'main.dart']);
|
| - newFile([libPath, 'nope.dart']);
|
| - String sdkExtPath = newFolder([projPath, 'sdk_ext']);
|
| - newFile([sdkExtPath, 'entry.dart']);
|
| - String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
|
| - newFile([sdkExtSrcPath, 'part.dart']);
|
| - // Setup analysis options file with ignore list.
|
| - newFile([projPath, '.analysis_options'], r'''
|
| -analyzer:
|
| - exclude:
|
| - - lib/nope.dart
|
| - - 'sdk_ext/**'
|
| -''');
|
| - // Setup context.
|
| - manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - // Verify that analysis options was parsed and the ignore patterns applied.
|
| - Map<String, int> fileTimestamps = manager.currentContextFilePaths[projPath];
|
| - expect(fileTimestamps, isNotEmpty);
|
| - List<String> files = fileTimestamps.keys.toList();
|
| - expect(files.length, equals(1));
|
| - expect(files[0], equals('/my/proj/lib/main.dart'));
|
| - }
|
| -
|
| test_refresh_oneContext() {
|
| // create two contexts with pubspec.yaml files
|
| String pubspecPath = posix.join(projPath, 'pubspec.yaml');
|
| @@ -283,14 +287,14 @@ analyzer:
|
| List<String> roots = <String>[projPath, proj2Path];
|
| manager.setRoots(roots, <String>[], <String, String>{});
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toList(), unorderedEquals(roots));
|
| - int then = manager.now;
|
| - manager.now++;
|
| + expect(callbacks.currentContextPaths.toList(), unorderedEquals(roots));
|
| + int then = callbacks.now;
|
| + callbacks.now++;
|
| manager.refresh([resourceProvider.getResource(proj2Path)]);
|
| return pumpEventQueue().then((_) {
|
| - expect(manager.currentContextPaths.toList(), unorderedEquals(roots));
|
| - expect(manager.currentContextTimestamps[projPath], then);
|
| - expect(manager.currentContextTimestamps[proj2Path], manager.now);
|
| + expect(callbacks.currentContextPaths.toList(), unorderedEquals(roots));
|
| + expect(callbacks.currentContextTimestamps[projPath], then);
|
| + expect(callbacks.currentContextTimestamps[proj2Path], callbacks.now);
|
| });
|
| });
|
| }
|
| @@ -300,7 +304,7 @@ analyzer:
|
| resourceProvider.newFile(filePath, 'contents');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // verify
|
| - var filePaths = manager.currentContextFilePaths[projPath];
|
| + var filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| List<AnalysisContext> contextsInAnalysisRoot =
|
| @@ -318,7 +322,7 @@ analyzer:
|
| resourceProvider.newFile(filePath, 'contents');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // verify
|
| - var filePaths = manager.currentContextFilePaths[projPath];
|
| + var filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| }
|
| @@ -328,7 +332,7 @@ analyzer:
|
| resourceProvider.newDummyLink(filePath);
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // verify
|
| - var filePaths = manager.currentContextFilePaths[projPath];
|
| + var filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, isEmpty);
|
| }
|
|
|
| @@ -336,9 +340,9 @@ analyzer:
|
| String examplePath = newFolder([projPath, EXAMPLE_NAME]);
|
| String libPath = newFolder([projPath, LIB_NAME]);
|
|
|
| - newFile([projPath, AbstractContextManager.PACKAGE_SPEC_NAME]);
|
| + newFile([projPath, ContextManagerImpl.PACKAGE_SPEC_NAME]);
|
| newFile([libPath, 'main.dart']);
|
| - newFile([examplePath, AbstractContextManager.PACKAGE_SPEC_NAME]);
|
| + newFile([examplePath, ContextManagerImpl.PACKAGE_SPEC_NAME]);
|
| newFile([examplePath, 'example.dart']);
|
|
|
| packageMapProvider.packageMap['proj'] =
|
| @@ -346,15 +350,15 @@ analyzer:
|
|
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
|
|
| - expect(manager.currentContextPaths, hasLength(2));
|
| + expect(callbacks.currentContextPaths, hasLength(2));
|
|
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| - Set<Source> projSources = manager.currentContextSources[projPath];
|
| + expect(callbacks.currentContextPaths, contains(projPath));
|
| + Set<Source> projSources = callbacks.currentContextSources[projPath];
|
| expect(projSources, hasLength(1));
|
| expect(projSources.first.uri.toString(), 'file:///my/proj/lib/main.dart');
|
|
|
| - expect(manager.currentContextPaths, contains(examplePath));
|
| - Set<Source> exampleSources = manager.currentContextSources[examplePath];
|
| + expect(callbacks.currentContextPaths, contains(examplePath));
|
| + Set<Source> exampleSources = callbacks.currentContextSources[examplePath];
|
| expect(exampleSources, hasLength(1));
|
| expect(exampleSources.first.uri.toString(),
|
| 'file:///my/proj/example/example.dart');
|
| @@ -364,9 +368,9 @@ analyzer:
|
| String examplePath = newFolder([projPath, EXAMPLE_NAME]);
|
| String libPath = newFolder([projPath, LIB_NAME]);
|
|
|
| - newFile([projPath, AbstractContextManager.PUBSPEC_NAME]);
|
| + newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]);
|
| newFile([libPath, 'main.dart']);
|
| - newFile([examplePath, AbstractContextManager.PUBSPEC_NAME]);
|
| + newFile([examplePath, ContextManagerImpl.PUBSPEC_NAME]);
|
| newFile([examplePath, 'example.dart']);
|
|
|
| packageMapProvider.packageMap['proj'] =
|
| @@ -374,15 +378,15 @@ analyzer:
|
|
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
|
|
| - expect(manager.currentContextPaths, hasLength(2));
|
| + expect(callbacks.currentContextPaths, hasLength(2));
|
|
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| - Set<Source> projSources = manager.currentContextSources[projPath];
|
| + expect(callbacks.currentContextPaths, contains(projPath));
|
| + Set<Source> projSources = callbacks.currentContextSources[projPath];
|
| expect(projSources, hasLength(1));
|
| expect(projSources.first.uri.toString(), 'package:proj/main.dart');
|
|
|
| - expect(manager.currentContextPaths, contains(examplePath));
|
| - Set<Source> exampleSources = manager.currentContextSources[examplePath];
|
| + expect(callbacks.currentContextPaths, contains(examplePath));
|
| + Set<Source> exampleSources = callbacks.currentContextSources[examplePath];
|
| expect(exampleSources, hasLength(1));
|
| expect(exampleSources.first.uri.toString(),
|
| 'file:///my/proj/example/example.dart');
|
| @@ -392,9 +396,9 @@ analyzer:
|
| packageMapProvider.packageMap = null;
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // verify
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| - expect(manager.currentContextFilePaths[projPath], hasLength(0));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, contains(projPath));
|
| + expect(callbacks.currentContextFilePaths[projPath], hasLength(0));
|
| }
|
|
|
| void test_setRoots_addFolderWithPackagespec() {
|
| @@ -409,12 +413,12 @@ analyzer:
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
|
|
| // verify
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| - expect(manager.currentContextFilePaths[projPath], hasLength(1));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, contains(projPath));
|
| + expect(callbacks.currentContextFilePaths[projPath], hasLength(1));
|
|
|
| // smoketest resolution
|
| - SourceFactory sourceFactory = manager.currentContext.sourceFactory;
|
| + SourceFactory sourceFactory = callbacks.currentContext.sourceFactory;
|
| Source resolvedSource =
|
| sourceFactory.resolveUri(source, 'package:unittest/unittest.dart');
|
| expect(resolvedSource, isNotNull);
|
| @@ -427,9 +431,9 @@ analyzer:
|
| resourceProvider.newFile(pubspecPath, 'pubspec');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // verify
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| - expect(manager.currentContextFilePaths[projPath], hasLength(0));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, contains(projPath));
|
| + expect(callbacks.currentContextFilePaths[projPath], hasLength(0));
|
| }
|
|
|
| void test_setRoots_addFolderWithPubspec_andPackagespec() {
|
| @@ -439,7 +443,7 @@ analyzer:
|
| resourceProvider.newFile(packagespecPath, '');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // verify
|
| - manager.assertContextPaths([projPath]);
|
| + callbacks.assertContextPaths([projPath]);
|
| }
|
|
|
| void test_setRoots_addFolderWithPubspecAndLib() {
|
| @@ -448,7 +452,7 @@ analyzer:
|
| String srcPath = newFolder([libPath, SRC_NAME]);
|
| String testPath = newFolder([projPath, TEST_NAME]);
|
|
|
| - newFile([projPath, AbstractContextManager.PUBSPEC_NAME]);
|
| + newFile([projPath, ContextManagerImpl.PUBSPEC_NAME]);
|
| String appPath = newFile([binPath, 'app.dart']);
|
| newFile([libPath, 'main.dart']);
|
| newFile([srcPath, 'internal.dart']);
|
| @@ -458,10 +462,10 @@ analyzer:
|
| [resourceProvider.getResource(libPath)];
|
|
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - Set<Source> sources = manager.currentContextSources[projPath];
|
| + Set<Source> sources = callbacks.currentContextSources[projPath];
|
|
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| - expect(manager.currentContextPaths, contains(projPath));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, contains(projPath));
|
| expect(sources, hasLength(4));
|
| List<String> uris =
|
| sources.map((Source source) => source.uri.toString()).toList();
|
| @@ -491,11 +495,11 @@ analyzer:
|
|
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProjectA, subProjectB]);
|
| + callbacks.assertContextPaths([root, subProjectA, subProjectB]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| - manager.assertContextFiles(subProjectB, [subProjectB_file]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| + callbacks.assertContextFiles(subProjectB, [subProjectB_file]);
|
| }
|
|
|
| void test_setRoots_addFolderWithPubspecFolders() {
|
| @@ -519,11 +523,11 @@ analyzer:
|
| };
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProjectA, subProjectB]);
|
| + callbacks.assertContextPaths([root, subProjectA, subProjectB]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| - manager.assertContextFiles(subProjectB, [subProjectB_file]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| + callbacks.assertContextFiles(subProjectB, [subProjectB_file]);
|
| // verify package maps
|
| _checkPackageMap(root, isNull);
|
| _checkPackageMap(
|
| @@ -572,8 +576,8 @@ analyzer:
|
| resourceProvider.newFile(file2, '// 2');
|
| // set roots
|
| manager.setRoots(<String>[project], <String>[file1], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file2]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file2]);
|
| }
|
|
|
| void test_setRoots_exclude_newRoot_withExcludedFolder() {
|
| @@ -588,8 +592,8 @@ analyzer:
|
| resourceProvider.newFile(fileB, 'library b;');
|
| // set roots
|
| manager.setRoots(<String>[project], <String>[folderB], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA]);
|
| }
|
|
|
| void test_setRoots_exclude_sameRoot_addExcludedFile() {
|
| @@ -602,12 +606,12 @@ analyzer:
|
| resourceProvider.newFile(file2, '// 2');
|
| // set roots
|
| manager.setRoots(<String>[project], <String>[], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file1, file2]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file1, file2]);
|
| // exclude "2"
|
| manager.setRoots(<String>[project], <String>[file2], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file1]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file1]);
|
| }
|
|
|
| void test_setRoots_exclude_sameRoot_addExcludedFolder() {
|
| @@ -622,12 +626,12 @@ analyzer:
|
| resourceProvider.newFile(fileB, 'library b;');
|
| // initially both "aaa/a" and "bbb/b" are included
|
| manager.setRoots(<String>[project], <String>[], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA, fileB]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA, fileB]);
|
| // exclude "bbb/"
|
| manager.setRoots(<String>[project], <String>[folderB], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA]);
|
| }
|
|
|
| void test_setRoots_exclude_sameRoot_removeExcludedFile() {
|
| @@ -640,12 +644,12 @@ analyzer:
|
| resourceProvider.newFile(file2, '// 2');
|
| // set roots
|
| manager.setRoots(<String>[project], <String>[file2], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file1]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file1]);
|
| // stop excluding "2"
|
| manager.setRoots(<String>[project], <String>[], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file1, file2]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file1, file2]);
|
| }
|
|
|
| void test_setRoots_exclude_sameRoot_removeExcludedFile_inFolder() {
|
| @@ -658,12 +662,12 @@ analyzer:
|
| resourceProvider.newFile(file2, '// 2');
|
| // set roots
|
| manager.setRoots(<String>[project], <String>[file2], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file1]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file1]);
|
| // stop excluding "2"
|
| manager.setRoots(<String>[project], <String>[], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [file1, file2]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [file1, file2]);
|
| }
|
|
|
| void test_setRoots_exclude_sameRoot_removeExcludedFolder() {
|
| @@ -678,12 +682,12 @@ analyzer:
|
| resourceProvider.newFile(fileB, 'library b;');
|
| // exclude "bbb/"
|
| manager.setRoots(<String>[project], <String>[folderB], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA]);
|
| // stop excluding "bbb/"
|
| manager.setRoots(<String>[project], <String>[], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA, fileB]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA, fileB]);
|
| }
|
|
|
| void test_setRoots_newFolderWithPackageRoot() {
|
| @@ -723,11 +727,11 @@ analyzer:
|
| packageMapProvider.packageMap = null;
|
| // add one root - there is a context
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| // set empty roots - no contexts
|
| manager.setRoots(<String>[], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(0));
|
| - expect(manager.currentContextFilePaths, hasLength(0));
|
| + expect(callbacks.currentContextPaths, hasLength(0));
|
| + expect(callbacks.currentContextFilePaths, hasLength(0));
|
| }
|
|
|
| void test_setRoots_removeFolderWithPackagespec() {
|
| @@ -736,11 +740,11 @@ analyzer:
|
| resourceProvider.newFile(pubspecPath, '');
|
| // add one root - there is a context
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| // set empty roots - no contexts
|
| manager.setRoots(<String>[], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(0));
|
| - expect(manager.currentContextFilePaths, hasLength(0));
|
| + expect(callbacks.currentContextPaths, hasLength(0));
|
| + expect(callbacks.currentContextFilePaths, hasLength(0));
|
| }
|
|
|
| void test_setRoots_removeFolderWithPackagespecFolder() {
|
| @@ -765,16 +769,17 @@ analyzer:
|
| // set roots
|
| manager.setRoots(
|
| <String>[projectA, projectB], <String>[], <String, String>{});
|
| - manager.assertContextPaths([projectA, subProjectA, projectB, subProjectB]);
|
| - manager.assertContextFiles(projectA, [projectA_file]);
|
| - manager.assertContextFiles(projectB, [projectB_file]);
|
| - manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| - manager.assertContextFiles(subProjectB, [subProjectB_file]);
|
| + callbacks
|
| + .assertContextPaths([projectA, subProjectA, projectB, subProjectB]);
|
| + callbacks.assertContextFiles(projectA, [projectA_file]);
|
| + callbacks.assertContextFiles(projectB, [projectB_file]);
|
| + callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| + callbacks.assertContextFiles(subProjectB, [subProjectB_file]);
|
| // remove "projectB"
|
| manager.setRoots(<String>[projectA], <String>[], <String, String>{});
|
| - manager.assertContextPaths([projectA, subProjectA]);
|
| - manager.assertContextFiles(projectA, [projectA_file]);
|
| - manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| + callbacks.assertContextPaths([projectA, subProjectA]);
|
| + callbacks.assertContextFiles(projectA, [projectA_file]);
|
| + callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| }
|
|
|
| void test_setRoots_removeFolderWithPubspec() {
|
| @@ -783,11 +788,11 @@ analyzer:
|
| resourceProvider.newFile(pubspecPath, 'pubspec');
|
| // add one root - there is a context
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(1));
|
| + expect(callbacks.currentContextPaths, hasLength(1));
|
| // set empty roots - no contexts
|
| manager.setRoots(<String>[], <String>[], <String, String>{});
|
| - expect(manager.currentContextPaths, hasLength(0));
|
| - expect(manager.currentContextFilePaths, hasLength(0));
|
| + expect(callbacks.currentContextPaths, hasLength(0));
|
| + expect(callbacks.currentContextFilePaths, hasLength(0));
|
| }
|
|
|
| void test_setRoots_removeFolderWithPubspecFolder() {
|
| @@ -812,16 +817,17 @@ analyzer:
|
| // set roots
|
| manager.setRoots(
|
| <String>[projectA, projectB], <String>[], <String, String>{});
|
| - manager.assertContextPaths([projectA, subProjectA, projectB, subProjectB]);
|
| - manager.assertContextFiles(projectA, [projectA_file]);
|
| - manager.assertContextFiles(projectB, [projectB_file]);
|
| - manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| - manager.assertContextFiles(subProjectB, [subProjectB_file]);
|
| + callbacks
|
| + .assertContextPaths([projectA, subProjectA, projectB, subProjectB]);
|
| + callbacks.assertContextFiles(projectA, [projectA_file]);
|
| + callbacks.assertContextFiles(projectB, [projectB_file]);
|
| + callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| + callbacks.assertContextFiles(subProjectB, [subProjectB_file]);
|
| // remove "projectB"
|
| manager.setRoots(<String>[projectA], <String>[], <String, String>{});
|
| - manager.assertContextPaths([projectA, subProjectA]);
|
| - manager.assertContextFiles(projectA, [projectA_file]);
|
| - manager.assertContextFiles(subProjectA, [subProjectA_file]);
|
| + callbacks.assertContextPaths([projectA, subProjectA]);
|
| + callbacks.assertContextFiles(projectA, [projectA_file]);
|
| + callbacks.assertContextFiles(subProjectA, [subProjectA_file]);
|
| }
|
|
|
| void test_setRoots_removePackageRoot() {
|
| @@ -842,7 +848,7 @@ analyzer:
|
| test_watch_addDummyLink() {
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // empty folder initially
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, isEmpty);
|
| // add link
|
| String filePath = posix.join(projPath, 'foo.dart');
|
| @@ -856,7 +862,7 @@ analyzer:
|
| test_watch_addFile() {
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // empty folder initially
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(0));
|
| // add file
|
| String filePath = posix.join(projPath, 'foo.dart');
|
| @@ -879,20 +885,20 @@ analyzer:
|
| resourceProvider.newFile(fileA, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[project], <String>[folderB], <String, String>{});
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA]);
|
| // add a file, ignored as excluded
|
| resourceProvider.newFile(fileB, 'library b;');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([project]);
|
| - manager.assertContextFiles(project, [fileA]);
|
| + callbacks.assertContextPaths([project]);
|
| + callbacks.assertContextFiles(project, [fileA]);
|
| });
|
| }
|
|
|
| test_watch_addFileInSubfolder() {
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // empty folder initially
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(0));
|
| // add file in subfolder
|
| String filePath = posix.join(projPath, 'foo', 'bar.dart');
|
| @@ -913,14 +919,14 @@ analyzer:
|
| resourceProvider.newFile(rootFile, 'library root;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root]);
|
| + callbacks.assertContextPaths([root]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| // add packagespec - still just one root
|
| resourceProvider.newFile(rootPackagespec, '');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| // TODO(pquitslund): verify that a new source factory is created --
|
| // likely this will need to happen in a corresponding ServerContextManagerTest.
|
| });
|
| @@ -938,15 +944,15 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root]);
|
| + callbacks.assertContextPaths([root]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile, subFile]);
|
| + callbacks.assertContextFiles(root, [rootFile, subFile]);
|
| // add .packages
|
| resourceProvider.newFile(subPubspec, '');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| });
|
| }
|
|
|
| @@ -964,15 +970,15 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library sub;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| // add pubspec - ignore, because is already in a packagespec-based context
|
| resourceProvider.newFile(subSubPubspec, '');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| });
|
| }
|
|
|
| @@ -990,18 +996,18 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
|
|
| // add .packages
|
| resourceProvider.newFile(subPackagespec, '');
|
| return pumpEventQueue().then((_) {
|
| // Should NOT create another context.
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| });
|
| }
|
|
|
| @@ -1014,14 +1020,14 @@ analyzer:
|
| resourceProvider.newFile(rootFile, 'library root;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root]);
|
| + callbacks.assertContextPaths([root]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| // add pubspec - still just one root
|
| resourceProvider.newFile(rootPubspec, 'pubspec');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| });
|
| }
|
|
|
| @@ -1037,15 +1043,15 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root]);
|
| + callbacks.assertContextPaths([root]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile, subFile]);
|
| + callbacks.assertContextFiles(root, [rootFile, subFile]);
|
| // add pubspec
|
| resourceProvider.newFile(subPubspec, 'pubspec');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| });
|
| }
|
|
|
| @@ -1063,15 +1069,15 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library sub;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| // add pubspec - ignore, because is already in a pubspec-based context
|
| resourceProvider.newFile(subSubPubspec, 'pubspec');
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| });
|
| }
|
|
|
| @@ -1082,7 +1088,7 @@ analyzer:
|
| Folder projFolder = file.parent;
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // the file was added
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| expect(file.exists, isTrue);
|
| @@ -1103,7 +1109,7 @@ analyzer:
|
| Folder projFolder = file.parent;
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // the file was added
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| expect(file.exists, isTrue);
|
| @@ -1127,13 +1133,13 @@ analyzer:
|
| resourceProvider.newFile(rootFile, 'library root;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| // delete the pubspec
|
| resourceProvider.deleteFile(rootPubspec);
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| });
|
| }
|
|
|
| @@ -1150,15 +1156,15 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| // delete the pubspec
|
| resourceProvider.deleteFile(subPubspec);
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile, subFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile, subFile]);
|
| });
|
| }
|
|
|
| @@ -1177,16 +1183,16 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| // delete the packagespec
|
| resourceProvider.deleteFile(subPackagespec);
|
| return pumpEventQueue().then((_) {
|
| // Should NOT merge
|
| - manager.assertContextPaths([root, subProject]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| });
|
| }
|
|
|
| @@ -1200,13 +1206,13 @@ analyzer:
|
| resourceProvider.newFile(rootFile, 'library root;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| // delete the pubspec
|
| resourceProvider.deleteFile(rootPubspec);
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| });
|
| }
|
|
|
| @@ -1223,15 +1229,15 @@ analyzer:
|
| resourceProvider.newFile(subFile, 'library a;');
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| - manager.assertContextPaths([root, subProject]);
|
| + callbacks.assertContextPaths([root, subProject]);
|
| // verify files
|
| - manager.assertContextFiles(root, [rootFile]);
|
| - manager.assertContextFiles(subProject, [subFile]);
|
| + callbacks.assertContextFiles(root, [rootFile]);
|
| + callbacks.assertContextFiles(subProject, [subFile]);
|
| // delete the pubspec
|
| resourceProvider.deleteFile(subPubspec);
|
| return pumpEventQueue().then((_) {
|
| - manager.assertContextPaths([root]);
|
| - manager.assertContextFiles(root, [rootFile, subFile]);
|
| + callbacks.assertContextPaths([root]);
|
| + callbacks.assertContextFiles(root, [rootFile, subFile]);
|
| });
|
| }
|
|
|
| @@ -1241,15 +1247,15 @@ analyzer:
|
| resourceProvider.newFile(filePath, 'contents');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| // the file was added
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| - expect(filePaths[filePath], equals(manager.now));
|
| + expect(filePaths[filePath], equals(callbacks.now));
|
| // update the file
|
| - manager.now++;
|
| + callbacks.now++;
|
| resourceProvider.modifyFile(filePath, 'new contents');
|
| return pumpEventQueue().then((_) {
|
| - return expect(filePaths[filePath], equals(manager.now));
|
| + return expect(filePaths[filePath], equals(callbacks.now));
|
| });
|
| }
|
|
|
| @@ -1375,18 +1381,18 @@ analyzer:
|
|
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
|
|
| - Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
|
| + Map<String, int> filePaths = callbacks.currentContextFilePaths[projPath];
|
| expect(filePaths, hasLength(1));
|
| expect(filePaths, contains(filePath));
|
| - Packages packages = manager.currentContextPackagespecs[projPath];
|
| + Packages packages = callbacks.currentContextPackagespecs[projPath];
|
| expect(packages.packages, isEmpty);
|
|
|
| // update .packages
|
| - manager.now++;
|
| + callbacks.now++;
|
| resourceProvider.modifyFile(packagesPath, 'main:./lib/');
|
| return pumpEventQueue().then((_) {
|
| // verify new package info
|
| - packages = manager.currentContextPackagespecs[projPath];
|
| + packages = callbacks.currentContextPackagespecs[projPath];
|
| expect(packages.packages, unorderedEquals(['main']));
|
| });
|
| }
|
| @@ -1396,7 +1402,7 @@ analyzer:
|
| * using a package map matching [expectation].
|
| */
|
| void _checkPackageMap(String path, expectation) {
|
| - UriResolver resolver = manager.currentContextPackageUriResolvers[path];
|
| + UriResolver resolver = callbacks.currentContextPackageUriResolvers[path];
|
| Map<String, List<Folder>> packageMap =
|
| resolver is PackageMapUriResolver ? resolver.packageMap : null;
|
| expect(packageMap, expectation);
|
| @@ -1407,14 +1413,14 @@ analyzer:
|
| * using a package root maching [expectation].
|
| */
|
| void _checkPackageRoot(String path, expectation) {
|
| - UriResolver resolver = manager.currentContextPackageUriResolvers[path];
|
| + UriResolver resolver = callbacks.currentContextPackageUriResolvers[path];
|
| expect(resolver, new isInstanceOf<PackageUriResolver>());
|
| PackageUriResolver packageUriResolver = resolver;
|
| expect(packageUriResolver.packagesDirectory_forTesting, expectation);
|
| }
|
| }
|
|
|
| -class TestContextManager extends AbstractContextManager {
|
| +class TestContextManagerCallbacks extends ContextManagerCallbacks {
|
| /**
|
| * Source of timestamps stored in [currentContextFilePaths].
|
| */
|
| @@ -1454,12 +1460,6 @@ class TestContextManager extends AbstractContextManager {
|
| */
|
| final Map<String, Packages> currentContextPackagespecs = <String, Packages>{};
|
|
|
| - TestContextManager(MemoryResourceProvider resourceProvider,
|
| - ResolverProvider packageResolverProvider,
|
| - OptimizingPubPackageMapProvider packageMapProvider)
|
| - : super(resourceProvider, packageResolverProvider, packageMapProvider,
|
| - InstrumentationService.NULL_SERVICE);
|
| -
|
| /**
|
| * Iterable of the paths to contexts that currently exist.
|
| */
|
| @@ -1517,7 +1517,7 @@ class TestContextManager extends AbstractContextManager {
|
| }
|
|
|
| @override
|
| - void removeContext(Folder folder) {
|
| + void removeContext(Folder folder, List<String> flushedFiles) {
|
| String path = folder.path;
|
| expect(currentContextPaths, contains(path));
|
| currentContextTimestamps.remove(path);
|
|
|