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

Unified Diff: pkg/analyzer/lib/src/string_source.dart

Issue 1718803002: Make StringSource fully implement Source (issue 25822) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/string_source.dart
diff --git a/pkg/analyzer/lib/src/string_source.dart b/pkg/analyzer/lib/src/string_source.dart
index b742db9326841e0d86bb4b3ad93d8d2eb4a17d49..3cfbd2e313b01bb5fc8713ad0395eb9151d6d1da 100644
--- a/pkg/analyzer/lib/src/string_source.dart
+++ b/pkg/analyzer/lib/src/string_source.dart
@@ -20,18 +20,22 @@ class StringSource extends Source {
final String fullName;
@override
+ final Uri uri;
+
+ @override
final int modificationStamp;
- StringSource(this._contents, this.fullName)
- : modificationStamp = new DateTime.now().millisecondsSinceEpoch;
+ StringSource(this._contents, String fullName)
+ : this.fullName = fullName,
+ uri = fullName == null ? null : new Uri.file(fullName),
+ modificationStamp = new DateTime.now().millisecondsSinceEpoch;
@override
TimestampedData<String> get contents =>
new TimestampedData(modificationStamp, _contents);
@override
- String get encoding =>
- throw new UnsupportedError("StringSource doesn't support encoding.");
+ String get encoding => uri.toString();
@override
int get hashCode => _contents.hashCode ^ fullName.hashCode;
@@ -43,11 +47,7 @@ class StringSource extends Source {
String get shortName => fullName;
@override
- Uri get uri =>
- throw new UnsupportedError("StringSource doesn't support uri.");
-
- UriKind get uriKind =>
- throw new UnsupportedError("StringSource doesn't support uriKind.");
+ UriKind get uriKind => UriKind.FILE_URI;
/**
* Return `true` if the given [object] is a string source that is equal to
@@ -63,8 +63,7 @@ class StringSource extends Source {
bool exists() => true;
@override
- Uri resolveRelativeUri(Uri relativeUri) => throw new UnsupportedError(
- "StringSource doesn't support resolveRelative.");
+ Uri resolveRelativeUri(Uri relativeUri) => uri.resolveUri(relativeUri);
@override
String toString() => 'StringSource ($fullName)';
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698