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

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

Issue 1648923003: Fix an exception caused by malformed code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | 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 0c99e696bd93886f090a64e3ed3228c7ece056ee..b742db9326841e0d86bb4b3ad93d8d2eb4a17d49 100644
--- a/pkg/analyzer/lib/src/string_source.dart
+++ b/pkg/analyzer/lib/src/string_source.dart
@@ -7,25 +7,39 @@ library analyzer.src.string_source;
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 int modificationStamp;
StringSource(this._contents, this.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.");
+ throw new UnsupportedError("StringSource doesn't support encoding.");
+ @override
int get hashCode => _contents.hashCode ^ fullName.hashCode;
+ @override
bool get isInSystemLibrary => false;
+ @override
String get shortName => fullName;
@override
@@ -33,18 +47,25 @@ class StringSource extends Source {
throw new UnsupportedError("StringSource doesn't support uri.");
UriKind get uriKind =>
- throw new UnsupportedError("StringSource doesn't support " "uriKind.");
+ throw new UnsupportedError("StringSource doesn't support uriKind.");
+ /**
+ * Return `true` if the given [object] is a string source that is equal to
+ * this source.
+ */
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;
+ @override
Uri resolveRelativeUri(Uri relativeUri) => throw new UnsupportedError(
"StringSource doesn't support resolveRelative.");
+
+ @override
+ String toString() => 'StringSource ($fullName)';
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698