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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.string_source; 5 library analyzer.src.string_source;
6 6
7 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 7 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
8 import 'package:analyzer/src/generated/source.dart'; 8 import 'package:analyzer/src/generated/source.dart';
9 9
10 /// An implementation of [Source] that's based on an in-memory Dart string. 10 /**
11 * An implementation of [Source] that's based on an in-memory Dart string.
12 */
11 class StringSource extends Source { 13 class StringSource extends Source {
14 /**
15 * The content of the source.
16 */
12 final String _contents; 17 final String _contents;
18
19 @override
13 final String fullName; 20 final String fullName;
21
22 @override
14 final int modificationStamp; 23 final int modificationStamp;
15 24
16 StringSource(this._contents, this.fullName) 25 StringSource(this._contents, this.fullName)
17 : modificationStamp = new DateTime.now().millisecondsSinceEpoch; 26 : modificationStamp = new DateTime.now().millisecondsSinceEpoch;
18 27
28 @override
19 TimestampedData<String> get contents => 29 TimestampedData<String> get contents =>
20 new TimestampedData(modificationStamp, _contents); 30 new TimestampedData(modificationStamp, _contents);
21 31
32 @override
22 String get encoding => 33 String get encoding =>
23 throw new UnsupportedError("StringSource doesn't support " "encoding."); 34 throw new UnsupportedError("StringSource doesn't support encoding.");
24 35
36 @override
25 int get hashCode => _contents.hashCode ^ fullName.hashCode; 37 int get hashCode => _contents.hashCode ^ fullName.hashCode;
26 38
39 @override
27 bool get isInSystemLibrary => false; 40 bool get isInSystemLibrary => false;
28 41
42 @override
29 String get shortName => fullName; 43 String get shortName => fullName;
30 44
31 @override 45 @override
32 Uri get uri => 46 Uri get uri =>
33 throw new UnsupportedError("StringSource doesn't support uri."); 47 throw new UnsupportedError("StringSource doesn't support uri.");
34 48
35 UriKind get uriKind => 49 UriKind get uriKind =>
36 throw new UnsupportedError("StringSource doesn't support " "uriKind."); 50 throw new UnsupportedError("StringSource doesn't support uriKind.");
37 51
52 /**
53 * Return `true` if the given [object] is a string source that is equal to
54 * this source.
55 */
38 bool operator ==(Object object) { 56 bool operator ==(Object object) {
39 if (object is StringSource) { 57 return object is StringSource &&
40 StringSource ssObject = object; 58 object._contents == _contents &&
41 return ssObject._contents == _contents && ssObject.fullName == fullName; 59 object.fullName == fullName;
42 }
43 return false;
44 } 60 }
45 61
62 @override
46 bool exists() => true; 63 bool exists() => true;
47 64
65 @override
48 Uri resolveRelativeUri(Uri relativeUri) => throw new UnsupportedError( 66 Uri resolveRelativeUri(Uri relativeUri) => throw new UnsupportedError(
49 "StringSource doesn't support resolveRelative."); 67 "StringSource doesn't support resolveRelative.");
68
69 @override
70 String toString() => 'StringSource ($fullName)';
50 } 71 }
OLDNEW
« 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