| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library analyzer.string_source; |
| 6 |
| 7 import 'generated/source.dart'; |
| 8 |
| 9 /// An implementation of [Source] that's based on an in-memory Dart string. |
| 10 class StringSource implements Source { |
| 11 final String _contents; |
| 12 final String fullName; |
| 13 final int modificationStamp; |
| 14 |
| 15 StringSource(this._contents, this.fullName) |
| 16 : modificationStamp = new DateTime.now().millisecondsSinceEpoch; |
| 17 |
| 18 bool operator==(Object object) => object is StringSource && |
| 19 object._contents == _contents && object._name == _name; |
| 20 |
| 21 bool exists() => true; |
| 22 |
| 23 void getContents(Source_ContentReceiver receiver) => |
| 24 receiver.accept2(_contents, modificationStamp); |
| 25 |
| 26 String get encoding => throw UnsupportedError("StringSource doesn't support " |
| 27 "encoding."); |
| 28 |
| 29 String get shortName => fullName; |
| 30 |
| 31 String get uriKind => throw UnsupportedError("StringSource doesn't support " |
| 32 "uriKind."); |
| 33 |
| 34 int get hashCode => _contents.hashCode ^ _name.hashCode; |
| 35 |
| 36 bool get isInSystemLibrary => false; |
| 37 |
| 38 Source resolveRelative(Uri relativeUri) => throw UnsupportedError( |
| 39 "StringSource doesn't support resolveRelative."); |
| 40 } |
| OLD | NEW |