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