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
This commit is contained in:
paulberry@google.com
2014-06-23 21:33:18 +00:00
parent c718393be3
commit 940f84df33
3 changed files with 5 additions and 67 deletions
@@ -47,7 +47,7 @@ class AnalysisServerContextDirectoryManager extends ContextDirectoryManager {
: super(resourceProvider);
@override
void addContext(Folder folder, File pubspecFile) {
void addContext(Folder folder) {
Map<String, List<Folder>> packageMap =
analysisServer.packageMapProvider.computePackageMap(folder);
ContextDirectory contextDirectory = new ContextDirectory(
@@ -27,17 +27,6 @@ class _ContextDirectoryInfo {
* added to the context.
*/
Map<String, Source> sources = new HashMap<String, Source>();
/**
* 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
@@ -21,7 +21,6 @@ class TestContextDirectoryManager extends ContextDirectoryManager {
int now = 0;
final Set<String> currentContextPaths = new Set<String>();
final Map<String, String> currentContextPubspecPaths = <String, String>{};
/**
* Map from context to (map from file path to timestamp of last event)
@@ -29,10 +28,9 @@ class TestContextDirectoryManager extends ContextDirectoryManager {
final Map<String, Map<String, int>> currentContextFilePaths = <String, Map<String, int>>{};
@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] = <String, int>{};
}
@@ -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(<String>[projPath], <String>[]);
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(<String>[projPath], <String>[]);
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(<String>[projPath], <String>[]);
manager.setRoots(<String>[], <String>[]);
expect(manager.currentContextPaths, hasLength(0));
expect(manager.currentContextPubspecPaths, hasLength(0));
expect(manager.currentContextFilePaths, hasLength(0));
});
@@ -136,7 +130,6 @@ main() {
manager.setRoots(<String>[projPath], <String>[]);
manager.setRoots(<String>[], <String>[]);
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(<String>[projPath], <String>[]);
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(<String>[projPath], <String>[]);
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');