Chromium Code Reviews| Index: pkg/analyzer/lib/file_system/memory_file_system.dart |
| diff --git a/pkg/analyzer/lib/file_system/memory_file_system.dart b/pkg/analyzer/lib/file_system/memory_file_system.dart |
| index d3ec74f11019eab7cb5860dc94258c8de1661664..b15b256b2e239657c029a96fff0a2aaa28a19348 100644 |
| --- a/pkg/analyzer/lib/file_system/memory_file_system.dart |
| +++ b/pkg/analyzer/lib/file_system/memory_file_system.dart |
| @@ -159,6 +159,21 @@ class MemoryResourceProvider implements ResourceProvider { |
| } |
| } |
| + void renameFileSync(String path, String newPath) { |
| + if (newPath == path) { |
| + return; |
| + } |
| + if (_pathToResource[newPath] is _MemoryFolder) { |
| + throw new FileSystemException( |
| + path, 'Could not be renamed: $newPath is a folder.'); |
| + } |
| + _pathToResource.remove(path); |
| + _pathToContent[newPath] = _pathToContent.remove(path); |
| + _pathToBytes[newPath] = _pathToBytes.remove(path); |
| + _pathToTimestamp[newPath] = _pathToTimestamp.remove(path); |
| + _pathToWatchers[newPath] = _pathToWatchers.remove(path); |
|
Brian Wilkerson
2016/03/17 19:31:00
Does this need to call _notifyWatchers?
|
| + } |
| + |
| File updateFile(String path, String content, [int stamp]) { |
| path = pathContext.normalize(path); |
| newFolder(pathContext.dirname(path)); |
| @@ -214,7 +229,9 @@ class MemoryResourceProvider implements ResourceProvider { |
| }); |
| } |
| - void _setFileBytes(String path, List<int> bytes) { |
| + void _setFileBytes(_MemoryFile file, List<int> bytes) { |
| + String path = file.path; |
| + _pathToResource[path] = file; |
| _pathToBytes[path] = bytes; |
| _pathToTimestamp[path] = nextStamp++; |
| _notifyWatchers(path, ChangeType.MODIFY); |
| @@ -271,6 +288,11 @@ class _MemoryDummyLink extends _MemoryResource implements File { |
| } |
| @override |
| + Resource renameSync(String newPath) { |
| + throw new FileSystemException(path, 'File could not be renamed'); |
| + } |
| + |
| + @override |
| void writeAsBytesSync(List<int> bytes) { |
| throw new FileSystemException(path, 'File could not be written'); |
| } |
| @@ -335,8 +357,14 @@ class _MemoryFile extends _MemoryResource implements File { |
| } |
| @override |
| + File renameSync(String newPath) { |
| + _provider.renameFileSync(path, newPath); |
| + return _provider._newFile(newPath); |
| + } |
| + |
| + @override |
| void writeAsBytesSync(List<int> bytes) { |
| - _provider._setFileBytes(path, bytes); |
| + _provider._setFileBytes(this, bytes); |
| } |
| } |