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

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

Issue 428303004: Breaking changes in 'analyzer' package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename Source.resolveRelative to resolveRelativeUri, soften version constraints Created 6 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
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 4ca4e615d1a906923e6be35d7624f503cb1505e3..ee32ada5704a3ce21ea7ccae4e72d87cdb31ebb9 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -160,7 +160,7 @@ class _MemoryDummyLink extends _MemoryResource implements File {
int get _timestamp => _provider._pathToTimestamp[path];
@override
- Source createSource(UriKind uriKind) {
+ Source createSource([Uri uri]) {
throw new MemoryResourceException(path, "File '$path' could not be read");
}
}
@@ -184,8 +184,11 @@ class _MemoryFile extends _MemoryResource implements File {
int get _timestamp => _provider._pathToTimestamp[path];
@override
- Source createSource(UriKind uriKind) {
- return new _MemoryFileSource(this, uriKind);
+ Source createSource([Uri uri]) {
+ if (uri == null) {
+ uri = toUri(path);
+ }
+ return new _MemoryFileSource(this, uri);
}
}
@@ -196,9 +199,9 @@ class _MemoryFile extends _MemoryResource implements File {
class _MemoryFileSource implements Source {
final _MemoryFile _file;
- final UriKind uriKind;
+ final Uri uri;
- _MemoryFileSource(this._file, this.uriKind);
+ _MemoryFileSource(this._file, this.uri);
@override
TimestampedData<String> get contents {
@@ -207,7 +210,7 @@ class _MemoryFileSource implements Source {
@override
String get encoding {
- return '${new String.fromCharCode(uriKind.encoding)}${_file.path}';
+ return uri.toString();
}
@override
@@ -226,6 +229,19 @@ class _MemoryFileSource implements Source {
String get shortName => _file.shortName;
@override
+ UriKind get uriKind {
+ String scheme = uri.scheme;
+ if (scheme == PackageUriResolver.PACKAGE_SCHEME) {
+ return UriKind.PACKAGE_URI;
+ } else if (scheme == DartUriResolver.DART_SCHEME) {
+ return UriKind.DART_URI;
+ } else if (scheme == FileUriResolver.FILE_SCHEME) {
+ return UriKind.FILE_URI;
+ }
+ return UriKind.FILE_URI;
+ }
+
+ @override
bool operator ==(other) {
if (other is _MemoryFileSource) {
return other._file == _file;
@@ -237,13 +253,8 @@ class _MemoryFileSource implements Source {
bool exists() => _file.exists;
@override
- Source resolveRelative(Uri relativeUri) {
- String relativePath = posix.fromUri(relativeUri);
- String folderPath = posix.dirname(_file.path);
- String path = posix.join(folderPath, relativePath);
- path = posix.normalize(path);
- _MemoryFile file = new _MemoryFile(_file._provider, path);
- return new _MemoryFileSource(file, uriKind);
+ Uri resolveRelativeUri(Uri relativeUri) {
+ return uri.resolveUri(relativeUri);
}
}
« no previous file with comments | « pkg/analyzer/lib/file_system/file_system.dart ('k') | pkg/analyzer/lib/file_system/physical_file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698