| OLD | NEW |
| 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.string_source; | 5 library analyzer.string_source; |
| 6 | 6 |
| 7 import 'generated/source.dart'; | 7 import 'generated/source.dart'; |
| 8 import 'generated/engine.dart' show TimestampedData; |
| 8 | 9 |
| 9 /// An implementation of [Source] that's based on an in-memory Dart string. | 10 /// An implementation of [Source] that's based on an in-memory Dart string. |
| 10 class StringSource implements Source { | 11 class StringSource implements Source { |
| 11 final String _contents; | 12 final String _contents; |
| 12 final String fullName; | 13 final String fullName; |
| 13 final int modificationStamp; | 14 final int modificationStamp; |
| 14 | 15 |
| 15 StringSource(this._contents, this.fullName) | 16 StringSource(this._contents, this.fullName) |
| 16 : modificationStamp = new DateTime.now().millisecondsSinceEpoch; | 17 : modificationStamp = new DateTime.now().millisecondsSinceEpoch; |
| 17 | 18 |
| 18 bool operator==(Object object) { | 19 bool operator==(Object object) { |
| 19 if (object is StringSource) { | 20 if (object is StringSource) { |
| 20 StringSource ssObject = object; | 21 StringSource ssObject = object; |
| 21 return ssObject._contents == _contents && ssObject.fullName == fullName; | 22 return ssObject._contents == _contents && ssObject.fullName == fullName; |
| 22 } | 23 } |
| 23 return false; | 24 return false; |
| 24 } | 25 } |
| 25 | 26 |
| 26 bool exists() => true; | 27 bool exists() => true; |
| 27 | 28 |
| 28 void getContents(Source_ContentReceiver receiver) => | 29 void getContentsToReceiver(Source_ContentReceiver receiver) => |
| 29 receiver.accept(_contents, modificationStamp); | 30 receiver.accept(_contents, modificationStamp); |
| 30 | 31 |
| 32 TimestampedData<String> get contents => new TimestampedData(modificationStamp,
_contents); |
| 33 |
| 31 String get encoding => throw new UnsupportedError("StringSource doesn't suppor
t " | 34 String get encoding => throw new UnsupportedError("StringSource doesn't suppor
t " |
| 32 "encoding."); | 35 "encoding."); |
| 33 | 36 |
| 34 String get shortName => fullName; | 37 String get shortName => fullName; |
| 35 | 38 |
| 36 UriKind get uriKind => throw new UnsupportedError("StringSource doesn't suppor
t " | 39 UriKind get uriKind => throw new UnsupportedError("StringSource doesn't suppor
t " |
| 37 "uriKind."); | 40 "uriKind."); |
| 38 | 41 |
| 39 int get hashCode => _contents.hashCode ^ fullName.hashCode; | 42 int get hashCode => _contents.hashCode ^ fullName.hashCode; |
| 40 | 43 |
| 41 bool get isInSystemLibrary => false; | 44 bool get isInSystemLibrary => false; |
| 42 | 45 |
| 43 Source resolveRelative(Uri relativeUri) => throw new UnsupportedError( | 46 Source resolveRelative(Uri relativeUri) => throw new UnsupportedError( |
| 44 "StringSource doesn't support resolveRelative."); | 47 "StringSource doesn't support resolveRelative."); |
| 45 } | 48 } |
| OLD | NEW |