Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Unified Diff: pkg/analysis_server/lib/src/resource.dart

Issue 367483002: Ignore bogus links, such as those created by emacs for files being edited. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/resource.dart
diff --git a/pkg/analysis_server/lib/src/resource.dart b/pkg/analysis_server/lib/src/resource.dart
index f5e5b7bd6b894efef893b747561717bbbb5aaa61..87b67fb54e2364eef9c19d61ae5b2e789331fa62 100644
--- a/pkg/analysis_server/lib/src/resource.dart
+++ b/pkg/analysis_server/lib/src/resource.dart
@@ -173,6 +173,30 @@ class MemoryResourceException {
/**
+ * An in-memory implementation of [File] which acts like a symbolic link to a
+ * non-existent file.
+ */
+class _MemoryDummyLink extends _MemoryResource implements File {
+ _MemoryDummyLink(MemoryResourceProvider provider, String path) :
+ super(provider, path);
+
+ @override
+ Source createSource(UriKind uriKind) {
+ throw new MemoryResourceException(path, "File '$path' could not be read");
+ }
+
+ String get _content {
+ throw new MemoryResourceException(path, "File '$path' could not be read");
+ }
+
+ int get _timestamp => _provider._pathToTimestamp[path];
+
+ @override
+ bool get exists => false;
+}
+
+
+/**
* An in-memory implementation of [Source].
*/
class _MemoryFileSource implements Source {
@@ -336,6 +360,20 @@ class MemoryResourceProvider implements ResourceProvider {
return file;
}
+ /**
+ * Create a resource representing a dummy link (that is, a File object which
+ * appears in its parent directory, but whose `exists` property is false)
+ */
+ File newDummyLink(String path) {
+ path = posix.normalize(path);
+ newFolder(posix.dirname(path));
+ _MemoryDummyLink link = new _MemoryDummyLink(this, path);
+ _pathToResource[path] = link;
+ _pathToTimestamp[path] = nextStamp++;
+ _notifyWatchers(path, ChangeType.ADD);
+ return link;
+ }
+
void _notifyWatchers(String path, ChangeType changeType) {
_pathToWatchers.forEach((String watcherPath, List<StreamController<WatchEvent>> streamControllers) {
if (posix.isWithin(watcherPath, path)) {

Powered by Google App Engine
This is Rietveld 408576698