From 940f84df331dc979583122c35ec5552006d5ed37 Mon Sep 17 00:00:00 2001 From: "paulberry@google.com" Date: Mon, 23 Jun 2014 21:33:18 +0000 Subject: [PATCH] Remove dead code for tracking pubspec.yaml files. Now that we are using "pub list-package-dirs" to find the packages associated with a context, we no longer need to explicitly track the presence or absence of a "pubspec.yaml" file within the context. Note that we will have to watch the "pubspec.lock" file in order to decide when to re-run "pub list-package-dirs", but we'll do this using a different mechanism, since the decision of which file(s) to watch is the responsibility of pub, and communicated to us through the JSON output of "pub list-package-dirs". This will be addressed in a future CL. R=brianwilkerson@google.com Review URL: https://codereview.chromium.org//353453004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37620 260f80e4-7a28-3924-810f-c04153c831b5 --- .../lib/src/analysis_server.dart | 2 +- .../lib/src/context_directory_manager.dart | 40 ++----------------- .../test/context_directory_manager_test.dart | 30 +------------- 3 files changed, 5 insertions(+), 67 deletions(-) diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart index 7c4bf0a5a36..c29aa8a91f6 100644 --- a/pkg/analysis_server/lib/src/analysis_server.dart +++ b/pkg/analysis_server/lib/src/analysis_server.dart @@ -47,7 +47,7 @@ class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { : super(resourceProvider); @override - void addContext(Folder folder, File pubspecFile) { + void addContext(Folder folder) { Map> packageMap = analysisServer.packageMapProvider.computePackageMap(folder); ContextDirectory contextDirectory = new ContextDirectory( diff --git a/pkg/analysis_server/lib/src/context_directory_manager.dart b/pkg/analysis_server/lib/src/context_directory_manager.dart index 1371c0aa83e..9fc3c925838 100644 --- a/pkg/analysis_server/lib/src/context_directory_manager.dart +++ b/pkg/analysis_server/lib/src/context_directory_manager.dart @@ -27,17 +27,6 @@ class _ContextDirectoryInfo { * added to the context. */ Map sources = new HashMap(); - - /** - * Pubspec file for this context, if there is one. Otherwise null. - */ - File pubspecFile = null; - - /** - * Path to that the pubspec file for this context would have, if it has one. - * Otherwise path that the pubspec file would have. - */ - String pubspecPath; } /** @@ -115,11 +104,7 @@ abstract class ContextDirectoryManager { _handleWatchEvent(folder, info, event); }); File pubspecFile = folder.getChild(PUBSPEC_NAME); - info.pubspecPath = pubspecFile.path; - if (pubspecFile.exists) { - info.pubspecFile = pubspecFile; - } - addContext(folder, info.pubspecFile); + addContext(folder); ChangeSet changeSet = new ChangeSet(); _addSourceFiles(changeSet, folder, info); applyChangesToContext(folder, changeSet); @@ -142,14 +127,6 @@ abstract class ContextDirectoryManager { // there is a pubspec.yaml? break; } - if (info.pubspecFile == null && event.path == info.pubspecPath) { - // Pubspec file added. This is likely to be such a rare event that - // there's no need to try to be clever. Just destroy the old context - // and create a new one. - _destroyContext(folder); - _createContext(folder); - return; - } if (_shouldFileBeAnalyzed(event.path)) { ChangeSet changeSet = new ChangeSet(); Resource resource = resourceProvider.getResource(event.path); @@ -166,15 +143,6 @@ abstract class ContextDirectoryManager { } break; case ChangeType.REMOVE: - if (info.pubspecFile != null && event.path == info.pubspecPath) { - // Pubspec file removed. This is likely to be such a rare event that - // there's no need to try to be clever. Just destroy the old context - // and create a new one. - _destroyContext(folder); - _createContext(folder); - return; - } - // TODO(paulberry): handle removing pubspec.yaml Source source = info.sources[event.path]; if (source != null) { ChangeSet changeSet = new ChangeSet(); @@ -238,11 +206,9 @@ abstract class ContextDirectoryManager { } /** - * Called when a new context needs to be created. If the context is - * associated with a pubspec file, that file is passed in [pubspecFile]; - * otherwise it is null. + * Called when a new context needs to be created. */ - void addContext(Folder folder, File pubspecFile); + void addContext(Folder folder); /** * Called when the set of files associated with a context have changed (or diff --git a/pkg/analysis_server/test/context_directory_manager_test.dart b/pkg/analysis_server/test/context_directory_manager_test.dart index 3e11bc391db..ac149fc95cc 100644 --- a/pkg/analysis_server/test/context_directory_manager_test.dart +++ b/pkg/analysis_server/test/context_directory_manager_test.dart @@ -21,7 +21,6 @@ class TestContextDirectoryManager extends ContextDirectoryManager { int now = 0; final Set currentContextPaths = new Set(); - final Map currentContextPubspecPaths = {}; /** * Map from context to (map from file path to timestamp of last event) @@ -29,10 +28,9 @@ class TestContextDirectoryManager extends ContextDirectoryManager { final Map> currentContextFilePaths = >{}; @override - void addContext(Folder folder, File pubspecFile) { + void addContext(Folder folder) { String path = folder.path; currentContextPaths.add(path); - currentContextPubspecPaths[path] = pubspecFile != null ? pubspecFile.path : null; currentContextFilePaths[path] = {}; } @@ -57,7 +55,6 @@ class TestContextDirectoryManager extends ContextDirectoryManager { void removeContext(Folder folder) { String path = folder.path; currentContextPaths.remove(path); - currentContextPubspecPaths.remove(path); currentContextFilePaths.remove(path); } } @@ -82,7 +79,6 @@ main() { manager.setRoots([projPath], []); expect(manager.currentContextPaths, hasLength(1)); expect(manager.currentContextPaths, contains(projPath)); - expect(manager.currentContextPubspecPaths[projPath], equals(pubspecPath)); expect(manager.currentContextFilePaths[projPath], hasLength(0)); }); @@ -92,7 +88,6 @@ main() { manager.setRoots([projPath], []); expect(manager.currentContextPaths, hasLength(1)); expect(manager.currentContextPaths, contains(projPath)); - expect(manager.currentContextPubspecPaths[projPath], isNull); expect(manager.currentContextFilePaths[projPath], hasLength(0)); }); @@ -126,7 +121,6 @@ main() { manager.setRoots([projPath], []); manager.setRoots([], []); expect(manager.currentContextPaths, hasLength(0)); - expect(manager.currentContextPubspecPaths, hasLength(0)); expect(manager.currentContextFilePaths, hasLength(0)); }); @@ -136,7 +130,6 @@ main() { manager.setRoots([projPath], []); manager.setRoots([], []); expect(manager.currentContextPaths, hasLength(0)); - expect(manager.currentContextPubspecPaths, hasLength(0)); expect(manager.currentContextFilePaths, hasLength(0)); }); @@ -189,16 +182,6 @@ main() { }); }); - test('Add pubspec file', () { - manager.setRoots([projPath], []); - String pubspecPath = posix.join(projPath, 'pubspec.yaml'); - expect(manager.currentContextPubspecPaths[projPath], isNull); - provider.newFile(pubspecPath, 'pubspec'); - return pumpEventQueue().then((_) { - expect(manager.currentContextPubspecPaths[projPath], equals(pubspecPath)); - }); - }); - test('Delete file', () { String filePath = posix.join(projPath, 'foo.dart'); provider.newFile(filePath, 'contents'); @@ -210,17 +193,6 @@ main() { return pumpEventQueue().then((_) => expect(filePaths, hasLength(0))); }); - test('Delete pubspec file', () { - String pubspecPath = posix.join(projPath, 'pubspec.yaml'); - provider.newFile(pubspecPath, 'pubspec'); - manager.setRoots([projPath], []); - expect(manager.currentContextPubspecPaths[projPath], equals(pubspecPath)); - provider.deleteFile(pubspecPath); - return pumpEventQueue().then((_) { - expect(manager.currentContextPubspecPaths[projPath], isNull); - }); - }); - test('Modify file', () { String filePath = posix.join(projPath, 'foo.dart'); provider.newFile(filePath, 'contents');