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

Side by Side Diff: pkg/analyzer/lib/file_system/memory_file_system.dart

Issue 1444943003: Use AbsolutePathContext in Folder.contains(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
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 memory_file_system; 5 library memory_file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:core' hide Resource; 9 import 'dart:core' hide Resource;
10 10
11 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 11 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
12 import 'package:analyzer/src/generated/source_io.dart'; 12 import 'package:analyzer/src/generated/source_io.dart';
13 import 'package:analyzer/src/util/absolute_path.dart';
13 import 'package:path/path.dart'; 14 import 'package:path/path.dart';
14 import 'package:watcher/watcher.dart'; 15 import 'package:watcher/watcher.dart';
15 16
16 import 'file_system.dart'; 17 import 'file_system.dart';
17 18
18 /** 19 /**
19 * An in-memory implementation of [ResourceProvider]. 20 * An in-memory implementation of [ResourceProvider].
20 * Use `/` as a path separator. 21 * Use `/` as a path separator.
21 */ 22 */
22 class MemoryResourceProvider implements ResourceProvider { 23 class MemoryResourceProvider implements ResourceProvider {
23 final Map<String, _MemoryResource> _pathToResource = 24 final Map<String, _MemoryResource> _pathToResource =
24 new HashMap<String, _MemoryResource>(); 25 new HashMap<String, _MemoryResource>();
25 final Map<String, String> _pathToContent = new HashMap<String, String>(); 26 final Map<String, String> _pathToContent = new HashMap<String, String>();
26 final Map<String, int> _pathToTimestamp = new HashMap<String, int>(); 27 final Map<String, int> _pathToTimestamp = new HashMap<String, int>();
27 final Map<String, List<StreamController<WatchEvent>>> _pathToWatchers = 28 final Map<String, List<StreamController<WatchEvent>>> _pathToWatchers =
28 new HashMap<String, List<StreamController<WatchEvent>>>(); 29 new HashMap<String, List<StreamController<WatchEvent>>>();
29 int nextStamp = 0; 30 int nextStamp = 0;
30 31
32 final AbsolutePathContext absolutePathContext =
33 new AbsolutePathContext(posix.separator);
34
31 @override 35 @override
32 Context get pathContext => posix; 36 Context get pathContext => posix;
33 37
34 /** 38 /**
35 * Delete the file with the given path. 39 * Delete the file with the given path.
36 */ 40 */
37 void deleteFile(String path) { 41 void deleteFile(String path) {
38 _checkFileAtPath(path); 42 _checkFileAtPath(path);
39 _pathToResource.remove(path); 43 _pathToResource.remove(path);
40 _pathToContent.remove(path); 44 _pathToContent.remove(path);
41 _pathToTimestamp.remove(path); 45 _pathToTimestamp.remove(path);
42 _notifyWatchers(path, ChangeType.REMOVE); 46 _notifyWatchers(path, ChangeType.REMOVE);
43 } 47 }
44 48
45 /** 49 /**
46 * Delete the folder with the given path 50 * Delete the folder with the given path
47 * and recurively delete nested files and folders. 51 * and recursively delete nested files and folders.
48 */ 52 */
49 void deleteFolder(String path) { 53 void deleteFolder(String path) {
50 _checkFolderAtPath(path); 54 _checkFolderAtPath(path);
51 _MemoryFolder folder = _pathToResource[path]; 55 _MemoryFolder folder = _pathToResource[path];
52 for (Resource child in folder.getChildren()) { 56 for (Resource child in folder.getChildren()) {
53 if (child is File) { 57 if (child is File) {
54 deleteFile(child.path); 58 deleteFile(child.path);
55 } else if (child is Folder) { 59 } else if (child is Folder) {
56 deleteFolder(child.path); 60 deleteFolder(child.path);
57 } else { 61 } else {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 bool operator ==(other) { 490 bool operator ==(other) {
487 if (runtimeType != other.runtimeType) { 491 if (runtimeType != other.runtimeType) {
488 return false; 492 return false;
489 } 493 }
490 return path == other.path; 494 return path == other.path;
491 } 495 }
492 496
493 @override 497 @override
494 String toString() => path; 498 String toString() => path;
495 } 499 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/file_system/file_system.dart ('k') | pkg/analyzer/lib/file_system/physical_file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698