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 8ce24724a18ce4ac0476632f311c79e7d7d943eb..cfc3aa2d5d884f88cb29cf586438b66ae3602ab0 100644 |
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart |
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart |
@@ -108,7 +108,12 @@ class MemoryResourceProvider implements ResourceProvider { |
File newFile(String path, String content, [int stamp]) { |
path = posix.normalize(path); |
- newFolder(posix.dirname(path)); |
+ _MemoryResource folder = _pathToResource[posix.dirname(path)]; |
+ if (folder == null) { |
+ newFolder(posix.dirname(path)); |
+ } else if (folder is! Folder) { |
+ throw new ArgumentError('Cannot create file ($path) as child of file'); |
+ } |
_MemoryFile file = new _MemoryFile(this, path); |
_pathToResource[path] = file; |
_pathToContent[path] = content; |
@@ -131,8 +136,10 @@ class MemoryResourceProvider implements ResourceProvider { |
_MemoryFolder folder = new _MemoryFolder(this, path); |
_pathToResource[path] = folder; |
_pathToTimestamp[path] = nextStamp++; |
+ _notifyWatchers(path, ChangeType.ADD); |
return folder; |
} else if (resource is _MemoryFolder) { |
+ _notifyWatchers(path, ChangeType.ADD); |
return resource; |
} else { |
String message = |