mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 16:47:20 +00:00
modify MemoryResourceProvider to support windows pathContext for testing #24000
R=paulberry@google.com Review URL: https://codereview.chromium.org//1318813007 .
This commit is contained in:
parent
1463fb3ff2
commit
c1992fa5d7
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -34,9 +34,10 @@
|
|||
*.xcodeproj
|
||||
*.intermediate
|
||||
|
||||
# Dart Editor config files - also in all subdirectories.
|
||||
# Eclipse config files - also in all subdirectories.
|
||||
.children
|
||||
.project
|
||||
.settings
|
||||
|
||||
# IntelliJ project files
|
||||
*.iml
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: analyzer
|
||||
version: 0.26.1+2
|
||||
version: 0.26.1+3
|
||||
author: Dart Team <misc@dartlang.org>
|
||||
description: Static analyzer for Dart.
|
||||
homepage: http://www.dartlang.org
|
||||
|
|
Loading…
Reference in a new issue