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

Side by Side Diff: pkg/analysis_server/lib/src/resource.dart

Issue 308713002: Handle file additions/removals in ContextDirectoryManager. (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 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:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 /** 75 /**
76 * Instances of the class [ResourceProvider] convert [String] paths into 76 * Instances of the class [ResourceProvider] convert [String] paths into
77 * [Resource]s. 77 * [Resource]s.
78 */ 78 */
79 abstract class ResourceProvider { 79 abstract class ResourceProvider {
80 /** 80 /**
81 * Return the [Resource] that corresponds to the given [path]. 81 * Return the [Resource] that corresponds to the given [path].
82 */ 82 */
83 Resource getResource(String path); 83 Resource getResource(String path);
84
85 /**
86 * Get the path context used by this resource provider.
87 */
88 Context get pathContext;
84 } 89 }
85 90
86 91
87 /** 92 /**
88 * An in-memory implementation of [Resource]. 93 * An in-memory implementation of [Resource].
89 */ 94 */
90 abstract class _MemoryResource implements Resource { 95 abstract class _MemoryResource implements Resource {
91 final MemoryResourceProvider _provider; 96 final MemoryResourceProvider _provider;
92 final String _path; 97 final String _path;
93 98
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 349 }
345 } 350 }
346 351
347 void deleteFile(String path) { 352 void deleteFile(String path) {
348 _checkFileAtPath(path); 353 _checkFileAtPath(path);
349 _pathToResource.remove(path); 354 _pathToResource.remove(path);
350 _pathToContent.remove(path); 355 _pathToContent.remove(path);
351 _pathToTimestamp.remove(path); 356 _pathToTimestamp.remove(path);
352 _notifyWatchers(path, ChangeType.REMOVE); 357 _notifyWatchers(path, ChangeType.REMOVE);
353 } 358 }
359
360 @override
361 Context get pathContext => posix;
354 } 362 }
355 363
356 364
357 /** 365 /**
358 * A `dart:io` based implementation of [File]. 366 * A `dart:io` based implementation of [File].
359 */ 367 */
360 class _PhysicalFile extends _PhysicalResource implements File { 368 class _PhysicalFile extends _PhysicalResource implements File {
361 _PhysicalFile(io.File file) : super(file); 369 _PhysicalFile(io.File file) : super(file);
362 370
363 @override 371 @override
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 @override 447 @override
440 Resource getResource(String path) { 448 Resource getResource(String path) {
441 if (io.FileSystemEntity.isDirectorySync(path)) { 449 if (io.FileSystemEntity.isDirectorySync(path)) {
442 io.Directory directory = new io.Directory(path); 450 io.Directory directory = new io.Directory(path);
443 return new _PhysicalFolder(directory); 451 return new _PhysicalFolder(directory);
444 } else { 452 } else {
445 io.File file = new io.File(path); 453 io.File file = new io.File(path);
446 return new _PhysicalFile(file); 454 return new _PhysicalFile(file);
447 } 455 }
448 } 456 }
457
458 @override
459 Context get pathContext => io.Platform.isWindows ? windows : posix;
449 } 460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698