| OLD | NEW |
| 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 analyzer.file_system.memory_file_system; | 5 library analyzer.file_system.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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 class MemoryResourceProvider implements ResourceProvider { | 22 class MemoryResourceProvider implements ResourceProvider { |
| 23 final Map<String, _MemoryResource> _pathToResource = | 23 final Map<String, _MemoryResource> _pathToResource = |
| 24 new HashMap<String, _MemoryResource>(); | 24 new HashMap<String, _MemoryResource>(); |
| 25 final Map<String, String> _pathToContent = new HashMap<String, String>(); | 25 final Map<String, String> _pathToContent = new HashMap<String, String>(); |
| 26 final Map<String, int> _pathToTimestamp = new HashMap<String, int>(); | 26 final Map<String, int> _pathToTimestamp = new HashMap<String, int>(); |
| 27 final Map<String, List<StreamController<WatchEvent>>> _pathToWatchers = | 27 final Map<String, List<StreamController<WatchEvent>>> _pathToWatchers = |
| 28 new HashMap<String, List<StreamController<WatchEvent>>>(); | 28 new HashMap<String, List<StreamController<WatchEvent>>>(); |
| 29 int nextStamp = 0; | 29 int nextStamp = 0; |
| 30 | 30 |
| 31 final AbsolutePathContext absolutePathContext = | 31 final Context _pathContext; |
| 32 new AbsolutePathContext(false); | 32 final AbsolutePathContext absolutePathContext; |
| 33 |
| 34 MemoryResourceProvider({bool isWindows: false}) |
| 35 : _pathContext = isWindows ? windows : posix, |
| 36 absolutePathContext = new AbsolutePathContext(isWindows); |
| 33 | 37 |
| 34 @override | 38 @override |
| 35 Context get pathContext => posix; | 39 Context get pathContext => _pathContext; |
| 36 | 40 |
| 37 /** | 41 /** |
| 38 * Delete the file with the given path. | 42 * Delete the file with the given path. |
| 39 */ | 43 */ |
| 40 void deleteFile(String path) { | 44 void deleteFile(String path) { |
| 41 _checkFileAtPath(path); | 45 _checkFileAtPath(path); |
| 42 _pathToResource.remove(path); | 46 _pathToResource.remove(path); |
| 43 _pathToContent.remove(path); | 47 _pathToContent.remove(path); |
| 44 _pathToTimestamp.remove(path); | 48 _pathToTimestamp.remove(path); |
| 45 _notifyWatchers(path, ChangeType.REMOVE); | 49 _notifyWatchers(path, ChangeType.REMOVE); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 bool operator ==(other) { | 493 bool operator ==(other) { |
| 490 if (runtimeType != other.runtimeType) { | 494 if (runtimeType != other.runtimeType) { |
| 491 return false; | 495 return false; |
| 492 } | 496 } |
| 493 return path == other.path; | 497 return path == other.path; |
| 494 } | 498 } |
| 495 | 499 |
| 496 @override | 500 @override |
| 497 String toString() => path; | 501 String toString() => path; |
| 498 } | 502 } |
| OLD | NEW |