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

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

Issue 1244613004: Implement support for watching directories containing implicitly analyzed files (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months 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
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 newFolder(posix.dirname(path)); 101 newFolder(posix.dirname(path));
102 _MemoryDummyLink link = new _MemoryDummyLink(this, path); 102 _MemoryDummyLink link = new _MemoryDummyLink(this, path);
103 _pathToResource[path] = link; 103 _pathToResource[path] = link;
104 _pathToTimestamp[path] = nextStamp++; 104 _pathToTimestamp[path] = nextStamp++;
105 _notifyWatchers(path, ChangeType.ADD); 105 _notifyWatchers(path, ChangeType.ADD);
106 return link; 106 return link;
107 } 107 }
108 108
109 File newFile(String path, String content, [int stamp]) { 109 File newFile(String path, String content, [int stamp]) {
110 path = posix.normalize(path); 110 path = posix.normalize(path);
111 newFolder(posix.dirname(path)); 111 _MemoryResource resource = _pathToResource[path];
112 _MemoryResource folder = _pathToResource[posix.dirname(path)];
113 if (folder == null) {
114 newFolder(posix.dirname(path));
115 } else if (folder is! Folder) {
116 throw new ArgumentError('Cannot create file ($path) as child of file');
117 }
112 _MemoryFile file = new _MemoryFile(this, path); 118 _MemoryFile file = new _MemoryFile(this, path);
113 _pathToResource[path] = file; 119 _pathToResource[path] = file;
114 _pathToContent[path] = content; 120 _pathToContent[path] = content;
115 _pathToTimestamp[path] = stamp != null ? stamp : nextStamp++; 121 _pathToTimestamp[path] = stamp != null ? stamp : nextStamp++;
116 _notifyWatchers(path, ChangeType.ADD); 122 _notifyWatchers(path, ChangeType.ADD);
117 return file; 123 return file;
118 } 124 }
119 125
120 Folder newFolder(String path) { 126 Folder newFolder(String path) {
121 path = posix.normalize(path); 127 path = posix.normalize(path);
122 if (!path.startsWith('/')) { 128 if (!path.startsWith('/')) {
123 throw new ArgumentError("Path must start with '/'"); 129 throw new ArgumentError("Path must start with '/'");
124 } 130 }
125 _MemoryResource resource = _pathToResource[path]; 131 _MemoryResource resource = _pathToResource[path];
126 if (resource == null) { 132 if (resource == null) {
127 String parentPath = posix.dirname(path); 133 String parentPath = posix.dirname(path);
128 if (parentPath != path) { 134 if (parentPath != path) {
129 newFolder(parentPath); 135 newFolder(parentPath);
130 } 136 }
131 _MemoryFolder folder = new _MemoryFolder(this, path); 137 _MemoryFolder folder = new _MemoryFolder(this, path);
132 _pathToResource[path] = folder; 138 _pathToResource[path] = folder;
133 _pathToTimestamp[path] = nextStamp++; 139 _pathToTimestamp[path] = nextStamp++;
140 _notifyWatchers(path, ChangeType.ADD);
134 return folder; 141 return folder;
135 } else if (resource is _MemoryFolder) { 142 } else if (resource is _MemoryFolder) {
143 _notifyWatchers(path, ChangeType.ADD);
136 return resource; 144 return resource;
137 } else { 145 } else {
138 String message = 146 String message =
139 'Folder expected at ' "'$path'" 'but ${resource.runtimeType} found'; 147 'Folder expected at ' "'$path'" 'but ${resource.runtimeType} found';
140 throw new ArgumentError(message); 148 throw new ArgumentError(message);
141 } 149 }
142 } 150 }
143 151
144 File updateFile(String path, String content, [int stamp]) { 152 File updateFile(String path, String content, [int stamp]) {
145 path = posix.normalize(path); 153 path = posix.normalize(path);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 bool operator ==(other) { 480 bool operator ==(other) {
473 if (runtimeType != other.runtimeType) { 481 if (runtimeType != other.runtimeType) {
474 return false; 482 return false;
475 } 483 }
476 return path == other.path; 484 return path == other.path;
477 } 485 }
478 486
479 @override 487 @override
480 String toString() => path; 488 String toString() => path;
481 } 489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698