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

Unified Diff: pkg/analyzer/lib/file_system/memory_file_system.dart

Issue 1318813007: modify MemoryResourceProvider to support windows pathContext for testing #24000 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « .gitignore ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cfc3aa2d5d884f88cb29cf586438b66ae3602ab0..1684fe969911a74677be2198c9bd97543419d585 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -72,7 +72,7 @@ class MemoryResourceProvider implements ResourceProvider {
@override
Resource getResource(String path) {
- path = posix.normalize(path);
+ path = pathContext.normalize(path);
Resource resource = _pathToResource[path];
if (resource == null) {
resource = new _MemoryFile(this, path);
@@ -97,8 +97,8 @@ class MemoryResourceProvider implements ResourceProvider {
* appears in its parent directory, but whose `exists` property is false)
*/
File newDummyLink(String path) {
- path = posix.normalize(path);
- newFolder(posix.dirname(path));
+ path = pathContext.normalize(path);
+ newFolder(pathContext.dirname(path));
_MemoryDummyLink link = new _MemoryDummyLink(this, path);
_pathToResource[path] = link;
_pathToTimestamp[path] = nextStamp++;
@@ -107,10 +107,10 @@ class MemoryResourceProvider implements ResourceProvider {
}
File newFile(String path, String content, [int stamp]) {
- path = posix.normalize(path);
- _MemoryResource folder = _pathToResource[posix.dirname(path)];
+ path = pathContext.normalize(path);
+ _MemoryResource folder = _pathToResource[pathContext.dirname(path)];
if (folder == null) {
- newFolder(posix.dirname(path));
+ newFolder(pathContext.dirname(path));
} else if (folder is! Folder) {
throw new ArgumentError('Cannot create file ($path) as child of file');
}
@@ -123,13 +123,14 @@ class MemoryResourceProvider implements ResourceProvider {
}
Folder newFolder(String path) {
- path = posix.normalize(path);
- if (!path.startsWith('/')) {
- throw new ArgumentError("Path must start with '/'");
+ path = pathContext.normalize(path);
+ if (!path.startsWith(pathContext.separator)) {
+ throw new ArgumentError(
+ "Path must start with '${pathContext.separator}' : $path");
}
_MemoryResource resource = _pathToResource[path];
if (resource == null) {
- String parentPath = posix.dirname(path);
+ String parentPath = pathContext.dirname(path);
if (parentPath != path) {
newFolder(parentPath);
}
@@ -149,8 +150,8 @@ class MemoryResourceProvider implements ResourceProvider {
}
File updateFile(String path, String content, [int stamp]) {
- path = posix.normalize(path);
- newFolder(posix.dirname(path));
+ path = pathContext.normalize(path);
+ newFolder(pathContext.dirname(path));
_MemoryFile file = new _MemoryFile(this, path);
_pathToResource[path] = file;
_pathToContent[path] = content;
@@ -178,7 +179,7 @@ class MemoryResourceProvider implements ResourceProvider {
void _notifyWatchers(String path, ChangeType changeType) {
_pathToWatchers.forEach((String watcherPath,
List<StreamController<WatchEvent>> streamControllers) {
- if (watcherPath == path || posix.isWithin(watcherPath, path)) {
+ if (watcherPath == path || pathContext.isWithin(watcherPath, path)) {
for (StreamController<WatchEvent> streamController
in streamControllers) {
streamController.add(new WatchEvent(changeType, path));
@@ -261,7 +262,7 @@ class _MemoryFile extends _MemoryResource implements File {
@override
Source createSource([Uri uri]) {
if (uri == null) {
- uri = posix.toUri(path);
+ uri = _provider.pathContext.toUri(path);
}
return new _MemoryFileSource(this, uri);
}
@@ -381,15 +382,15 @@ class _MemoryFolder extends _MemoryResource implements Folder {
@override
String canonicalizePath(String relPath) {
- relPath = posix.normalize(relPath);
- String childPath = posix.join(path, relPath);
- childPath = posix.normalize(childPath);
+ relPath = _provider.pathContext.normalize(relPath);
+ String childPath = _provider.pathContext.join(path, relPath);
+ childPath = _provider.pathContext.normalize(childPath);
return childPath;
}
@override
bool contains(String path) {
- return posix.isWithin(this.path, path);
+ return _provider.pathContext.isWithin(this.path, path);
}
@override
@@ -419,7 +420,7 @@ class _MemoryFolder extends _MemoryResource implements Folder {
}
List<Resource> children = <Resource>[];
_provider._pathToResource.forEach((resourcePath, resource) {
- if (posix.dirname(resourcePath) == path) {
+ if (_provider.pathContext.dirname(resourcePath) == path) {
children.add(resource);
}
});
@@ -465,7 +466,7 @@ abstract class _MemoryResource implements Resource {
@override
Folder get parent {
- String parentPath = posix.dirname(path);
+ String parentPath = _provider.pathContext.dirname(path);
if (parentPath == path) {
return null;
}
@@ -473,7 +474,7 @@ abstract class _MemoryResource implements Resource {
}
@override
- String get shortName => posix.basename(path);
+ String get shortName => _provider.pathContext.basename(path);
@override
bool operator ==(other) {
« no previous file with comments | « .gitignore ('k') | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698