| 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 6ef54593e3363df200164202acd79b2a58ab173c..eab479f0796b621285eb35225d2c3d2c82b1eb88 100644
|
| --- a/pkg/analysis_server/test/context_manager_test.dart
|
| +++ b/pkg/analysis_server/test/context_manager_test.dart
|
| @@ -21,13 +21,11 @@ import 'package:unittest/unittest.dart';
|
| import 'mocks.dart';
|
| import 'reflective_tests.dart';
|
|
|
| -
|
| main() {
|
| groupSep = ' | ';
|
| runReflectiveTests(ContextManagerTest);
|
| }
|
|
|
| -
|
| @reflectiveTest
|
| class ContextManagerTest {
|
| /**
|
| @@ -101,9 +99,7 @@ class ContextManagerTest {
|
| resourceProvider.newFolder(project);
|
| resourceProvider.newFolder(excludedFolder);
|
| manager.setRoots(
|
| - <String>[project],
|
| - <String>[excludedFolder],
|
| - <String, String>{});
|
| + <String>[project], <String>[excludedFolder], <String, String>{});
|
| // verify
|
| expect(manager.isInAnalysisRoot('$excludedFolder/test.dart'), isFalse);
|
| }
|
| @@ -145,14 +141,12 @@ class ContextManagerTest {
|
| resourceProvider.newFile(pubspec2Path, 'pubspec');
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| return pumpEventQueue().then((_) {
|
| - expect(
|
| - manager.currentContextPaths.toSet(),
|
| + expect(manager.currentContextPaths.toSet(),
|
| [subdir1Path, subdir2Path, projPath].toSet());
|
| manager.now++;
|
| manager.refresh();
|
| return pumpEventQueue().then((_) {
|
| - expect(
|
| - manager.currentContextPaths.toSet(),
|
| + expect(manager.currentContextPaths.toSet(),
|
| [subdir1Path, subdir2Path, projPath].toSet());
|
| expect(manager.currentContextTimestamps[projPath], manager.now);
|
| expect(manager.currentContextTimestamps[subdir1Path], manager.now);
|
| @@ -221,8 +215,9 @@ class ContextManagerTest {
|
| newFile([srcPath, 'internal.dart']);
|
| String testFilePath = newFile([testPath, 'main_test.dart']);
|
|
|
| - packageMapProvider.packageMap['proj'] =
|
| - [resourceProvider.getResource(libPath)];
|
| + packageMapProvider.packageMap['proj'] = [
|
| + resourceProvider.getResource(libPath)
|
| + ];
|
|
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| Set<Source> sources = manager.currentContextSources[projPath];
|
| @@ -254,12 +249,8 @@ class ContextManagerTest {
|
| resourceProvider.newFile(subProjectB_file, 'library b;');
|
| // configure package maps
|
| packageMapProvider.packageMaps = {
|
| - subProjectA: {
|
| - 'foo': [resourceProvider.newFolder('/package/foo')]
|
| - },
|
| - subProjectB: {
|
| - 'bar': [resourceProvider.newFolder('/package/bar')]
|
| - },
|
| + subProjectA: {'foo': [resourceProvider.newFolder('/package/foo')]},
|
| + subProjectB: {'bar': [resourceProvider.newFolder('/package/bar')]},
|
| };
|
| // set roots
|
| manager.setRoots(<String>[root], <String>[], <String, String>{});
|
| @@ -271,27 +262,22 @@ class ContextManagerTest {
|
| // verify package maps
|
| _checkPackageMap(root, isNull);
|
| _checkPackageMap(
|
| - subProjectA,
|
| - equals(packageMapProvider.packageMaps[subProjectA]));
|
| + subProjectA, equals(packageMapProvider.packageMaps[subProjectA]));
|
| _checkPackageMap(
|
| - subProjectB,
|
| - equals(packageMapProvider.packageMaps[subProjectB]));
|
| + subProjectB, equals(packageMapProvider.packageMaps[subProjectB]));
|
| }
|
|
|
| void test_setRoots_addPackageRoot() {
|
| String packagePathFoo = '/package1/foo';
|
| String packageRootPath = '/package2/foo';
|
| Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
| - packageMapProvider.packageMap = {
|
| - 'foo': [packageFolder]
|
| - };
|
| + packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| List<String> includedPaths = <String>[projPath];
|
| List<String> excludedPaths = <String>[];
|
| manager.setRoots(includedPaths, excludedPaths, <String, String>{});
|
| _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| - projPath: packageRootPath
|
| - });
|
| + manager.setRoots(includedPaths,
|
| + excludedPaths, <String, String>{projPath: packageRootPath});
|
| _checkPackageRoot(projPath, equals(packageRootPath));
|
| }
|
|
|
| @@ -304,9 +290,8 @@ class ContextManagerTest {
|
| projPath: packageRootPath1
|
| });
|
| _checkPackageRoot(projPath, equals(packageRootPath1));
|
| - manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| - projPath: packageRootPath2
|
| - });
|
| + manager.setRoots(includedPaths,
|
| + excludedPaths, <String, String>{projPath: packageRootPath2});
|
| _checkPackageRoot(projPath, equals(packageRootPath2));
|
| }
|
|
|
| @@ -465,9 +450,7 @@ class ContextManagerTest {
|
| void test_setRoots_newlyAddedFoldersGetProperPackageMap() {
|
| String packagePath = '/package/foo';
|
| Folder packageFolder = resourceProvider.newFolder(packagePath);
|
| - packageMapProvider.packageMap = {
|
| - 'foo': [packageFolder]
|
| - };
|
| + packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| manager.setRoots(<String>[projPath], <String>[], <String, String>{});
|
| _checkPackageMap(projPath, equals(packageMapProvider.packageMap));
|
| }
|
| @@ -517,9 +500,7 @@ class ContextManagerTest {
|
| resourceProvider.newFile(subProjectB_file, '// sub-b');
|
| // set roots
|
| manager.setRoots(
|
| - <String>[projectA, projectB],
|
| - <String>[],
|
| - <String, String>{});
|
| + <String>[projectA, projectB], <String>[], <String, String>{});
|
| manager.assertContextPaths([projectA, subProjectA, projectB, subProjectB]);
|
| manager.assertContextFiles(projectA, [projectA_file]);
|
| manager.assertContextFiles(projectB, [projectB_file]);
|
| @@ -536,9 +517,7 @@ class ContextManagerTest {
|
| String packagePathFoo = '/package1/foo';
|
| String packageRootPath = '/package2/foo';
|
| Folder packageFolder = resourceProvider.newFolder(packagePathFoo);
|
| - packageMapProvider.packageMap = {
|
| - 'foo': [packageFolder]
|
| - };
|
| + packageMapProvider.packageMap = {'foo': [packageFolder]};
|
| List<String> includedPaths = <String>[projPath];
|
| List<String> excludedPaths = <String>[];
|
| manager.setRoots(includedPaths, excludedPaths, <String, String>{
|
| @@ -803,9 +782,7 @@ class ContextManagerTest {
|
| // configure package map
|
| String packagePath = '/package/foo';
|
| resourceProvider.newFolder(packagePath);
|
| - packageMapProvider.packageMap = {
|
| - 'foo': projPath
|
| - };
|
| + packageMapProvider.packageMap = {'foo': projPath};
|
| // Changing a .dart file in the project shouldn't cause a new
|
| // package map to be picked up.
|
| resourceProvider.modifyFile(dartFilePath, 'new contents');
|
| @@ -863,7 +840,6 @@ class ContextManagerTest {
|
| }
|
| }
|
|
|
| -
|
| class TestContextManager extends ContextManager {
|
| /**
|
| * Source of timestamps stored in [currentContextFilePaths].
|
| @@ -878,27 +854,25 @@ class TestContextManager extends ContextManager {
|
| /**
|
| * Map from context to (map from file path to timestamp of last event).
|
| */
|
| - final Map<String, Map<String, int>> currentContextFilePaths = <String,
|
| - Map<String, int>>{};
|
| + final Map<String, Map<String, int>> currentContextFilePaths =
|
| + <String, Map<String, int>>{};
|
|
|
| /**
|
| * A map from the paths of contexts to a set of the sources that should be
|
| * explicitly analyzed in those contexts.
|
| */
|
| - final Map<String, Set<Source>> currentContextSources = <String,
|
| - Set<Source>>{};
|
| + final Map<String, Set<Source>> currentContextSources = <String, Set<Source>>{
|
| + };
|
|
|
| /**
|
| * Map from context to package URI resolver.
|
| */
|
| - final Map<String, UriResolver> currentContextPackageUriResolvers = <String,
|
| - UriResolver>{};
|
| + final Map<String, UriResolver> currentContextPackageUriResolvers =
|
| + <String, UriResolver>{};
|
|
|
| TestContextManager(MemoryResourceProvider resourceProvider,
|
| PackageMapProvider packageMapProvider)
|
| - : super(
|
| - resourceProvider,
|
| - packageMapProvider,
|
| + : super(resourceProvider, packageMapProvider,
|
| InstrumentationService.NULL_SERVICE);
|
|
|
| /**
|
| @@ -915,8 +889,8 @@ class TestContextManager extends ContextManager {
|
| currentContextSources[path] = new HashSet<Source>();
|
| currentContextPackageUriResolvers[path] = packageUriResolver;
|
| AnalysisContextImpl context = new AnalysisContextImpl();
|
| - context.sourceFactory =
|
| - new SourceFactory(packageUriResolver == null ? [] : [packageUriResolver]);
|
| + context.sourceFactory = new SourceFactory(
|
| + packageUriResolver == null ? [] : [packageUriResolver]);
|
| return context;
|
| }
|
|
|
| @@ -961,8 +935,8 @@ class TestContextManager extends ContextManager {
|
| }
|
|
|
| @override
|
| - void updateContextPackageUriResolver(Folder contextFolder,
|
| - UriResolver packageUriResolver) {
|
| + void updateContextPackageUriResolver(
|
| + Folder contextFolder, UriResolver packageUriResolver) {
|
| currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver;
|
| }
|
| }
|
|
|