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