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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library resource; 5 library resource;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 MemoryResourceException(this.path, this.message); 166 MemoryResourceException(this.path, this.message);
167 167
168 @override 168 @override
169 String toString() { 169 String toString() {
170 return "MemoryResourceException(path=$path; message=$message)"; 170 return "MemoryResourceException(path=$path; message=$message)";
171 } 171 }
172 } 172 }
173 173
174 174
175 /** 175 /**
176 * An in-memory implementation of [File] which acts like a symbolic link to a
177 * non-existent file.
178 */
179 class _MemoryDummyLink extends _MemoryResource implements File {
180 _MemoryDummyLink(MemoryResourceProvider provider, String path) :
181 super(provider, path);
182
183 @override
184 Source createSource(UriKind uriKind) {
185 throw new MemoryResourceException(path, "File '$path' could not be read");
186 }
187
188 String get _content {
189 throw new MemoryResourceException(path, "File '$path' could not be read");
190 }
191
192 int get _timestamp => _provider._pathToTimestamp[path];
193
194 @override
195 bool get exists => false;
196 }
197
198
199 /**
176 * An in-memory implementation of [Source]. 200 * An in-memory implementation of [Source].
177 */ 201 */
178 class _MemoryFileSource implements Source { 202 class _MemoryFileSource implements Source {
179 final _MemoryFile _file; 203 final _MemoryFile _file;
180 204
181 final UriKind uriKind; 205 final UriKind uriKind;
182 206
183 _MemoryFileSource(this._file, this.uriKind); 207 _MemoryFileSource(this._file, this.uriKind);
184 208
185 @override 209 @override
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 path = posix.normalize(path); 353 path = posix.normalize(path);
330 newFolder(posix.dirname(path)); 354 newFolder(posix.dirname(path));
331 _MemoryFile file = new _MemoryFile(this, path); 355 _MemoryFile file = new _MemoryFile(this, path);
332 _pathToResource[path] = file; 356 _pathToResource[path] = file;
333 _pathToContent[path] = content; 357 _pathToContent[path] = content;
334 _pathToTimestamp[path] = nextStamp++; 358 _pathToTimestamp[path] = nextStamp++;
335 _notifyWatchers(path, ChangeType.ADD); 359 _notifyWatchers(path, ChangeType.ADD);
336 return file; 360 return file;
337 } 361 }
338 362
363 /**
364 * Create a resource representing a dummy link (that is, a File object which
365 * appears in its parent directory, but whose `exists` property is false)
366 */
367 File newDummyLink(String path) {
368 path = posix.normalize(path);
369 newFolder(posix.dirname(path));
370 _MemoryDummyLink link = new _MemoryDummyLink(this, path);
371 _pathToResource[path] = link;
372 _pathToTimestamp[path] = nextStamp++;
373 _notifyWatchers(path, ChangeType.ADD);
374 return link;
375 }
376
339 void _notifyWatchers(String path, ChangeType changeType) { 377 void _notifyWatchers(String path, ChangeType changeType) {
340 _pathToWatchers.forEach((String watcherPath, List<StreamController<WatchEven t>> streamControllers) { 378 _pathToWatchers.forEach((String watcherPath, List<StreamController<WatchEven t>> streamControllers) {
341 if (posix.isWithin(watcherPath, path)) { 379 if (posix.isWithin(watcherPath, path)) {
342 for (StreamController<WatchEvent> streamController in streamControllers) { 380 for (StreamController<WatchEvent> streamController in streamControllers) {
343 streamController.add(new WatchEvent(changeType, path)); 381 streamController.add(new WatchEvent(changeType, path));
344 } 382 }
345 } 383 }
346 }); 384 });
347 } 385 }
348 386
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 556 }
519 557
520 /** 558 /**
521 * Return `true` if the given URI is a `file` URI. 559 * Return `true` if the given URI is a `file` URI.
522 * 560 *
523 * @param uri the URI being tested 561 * @param uri the URI being tested
524 * @return `true` if the given URI is a `file` URI 562 * @return `true` if the given URI is a `file` URI
525 */ 563 */
526 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; 564 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
527 } 565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698