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

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

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: packages/analyzer/lib/src/string_source.dart
diff --git a/packages/analyzer/lib/src/string_source.dart b/packages/analyzer/lib/src/string_source.dart
index 5ffb332dd3e17e70ab9b267b1def0160b319c458..ce0c08777749b715cc38db44610380199cdc896a 100644
--- a/packages/analyzer/lib/src/string_source.dart
+++ b/packages/analyzer/lib/src/string_source.dart
@@ -2,49 +2,67 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library analyzer.string_source;
+library analyzer.src.string_source;
-import 'generated/engine.dart' show TimestampedData;
-import 'generated/source.dart';
+import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
+import 'package:analyzer/src/generated/source.dart';
-/// An implementation of [Source] that's based on an in-memory Dart string.
+/**
+ * An implementation of [Source] that's based on an in-memory Dart string.
+ */
class StringSource extends Source {
+ /**
+ * The content of the source.
+ */
final String _contents;
+
+ @override
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);
- String get encoding =>
- throw new UnsupportedError("StringSource doesn't support " "encoding.");
+ @override
+ String get encoding => uri.toString();
+ @override
int get hashCode => _contents.hashCode ^ fullName.hashCode;
+ @override
bool get isInSystemLibrary => false;
+ @override
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
+ * this source.
+ */
+ @override
bool operator ==(Object object) {
- if (object is StringSource) {
- StringSource ssObject = object;
- return ssObject._contents == _contents && ssObject.fullName == fullName;
- }
- return false;
+ return object is StringSource &&
+ object._contents == _contents &&
+ object.fullName == fullName;
}
+ @override
bool exists() => true;
- Uri resolveRelativeUri(Uri relativeUri) => throw new UnsupportedError(
- "StringSource doesn't support resolveRelative.");
+ @override
+ String toString() => 'StringSource ($fullName)';
}
« no previous file with comments | « packages/analyzer/lib/src/source/source_resource.dart ('k') | packages/analyzer/lib/src/summary/api_signature.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698