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:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 path = pathContext.normalize(path); | 194 path = pathContext.normalize(path); |
195 newFolder(pathContext.dirname(path)); | 195 newFolder(pathContext.dirname(path)); |
196 _MemoryFile file = new _MemoryFile(this, path); | 196 _MemoryFile file = new _MemoryFile(this, path); |
197 _pathToResource[path] = file; | 197 _pathToResource[path] = file; |
198 _pathToBytes[path] = UTF8.encode(content); | 198 _pathToBytes[path] = UTF8.encode(content); |
199 _pathToTimestamp[path] = stamp ?? nextStamp++; | 199 _pathToTimestamp[path] = stamp ?? nextStamp++; |
200 _notifyWatchers(path, ChangeType.MODIFY); | 200 _notifyWatchers(path, ChangeType.MODIFY); |
201 return file; | 201 return file; |
202 } | 202 } |
203 | 203 |
| 204 /** |
| 205 * Write a representation of the file system on the given [sink]. |
| 206 */ |
| 207 void writeOn(StringSink sink) { |
| 208 List<String> paths = _pathToResource.keys.toList(); |
| 209 paths.sort(); |
| 210 paths.forEach(sink.writeln); |
| 211 } |
| 212 |
204 void _checkFileAtPath(String path) { | 213 void _checkFileAtPath(String path) { |
205 _MemoryResource resource = _pathToResource[path]; | 214 _MemoryResource resource = _pathToResource[path]; |
206 if (resource is! _MemoryFile) { | 215 if (resource is! _MemoryFile) { |
207 throw new ArgumentError( | 216 throw new ArgumentError( |
208 'File expected at "$path" but ${resource.runtimeType} found'); | 217 'File expected at "$path" but ${resource.runtimeType} found'); |
209 } | 218 } |
210 } | 219 } |
211 | 220 |
212 void _checkFolderAtPath(String path) { | 221 void _checkFolderAtPath(String path) { |
213 _MemoryResource resource = _pathToResource[path]; | 222 _MemoryResource resource = _pathToResource[path]; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 486 |
478 @override | 487 @override |
479 bool isOrContains(String path) { | 488 bool isOrContains(String path) { |
480 if (path == this.path) { | 489 if (path == this.path) { |
481 return true; | 490 return true; |
482 } | 491 } |
483 return contains(path); | 492 return contains(path); |
484 } | 493 } |
485 | 494 |
486 @override | 495 @override |
| 496 Folder resolveSymbolicLinksSync() => this; |
| 497 |
| 498 @override |
487 Uri toUri() => | 499 Uri toUri() => |
488 new Uri.directory(path, windows: _provider.pathContext == windows); | 500 new Uri.directory(path, windows: _provider.pathContext == windows); |
489 } | 501 } |
490 | 502 |
491 /** | 503 /** |
492 * An in-memory implementation of [Resource]. | 504 * An in-memory implementation of [Resource]. |
493 */ | 505 */ |
494 abstract class _MemoryResource implements Resource { | 506 abstract class _MemoryResource implements Resource { |
495 final MemoryResourceProvider _provider; | 507 final MemoryResourceProvider _provider; |
496 @override | 508 @override |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 bool operator ==(other) { | 545 bool operator ==(other) { |
534 if (runtimeType != other.runtimeType) { | 546 if (runtimeType != other.runtimeType) { |
535 return false; | 547 return false; |
536 } | 548 } |
537 return path == other.path; | 549 return path == other.path; |
538 } | 550 } |
539 | 551 |
540 @override | 552 @override |
541 String toString() => path; | 553 String toString() => path; |
542 } | 554 } |
OLD | NEW |