| 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.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 import 'package:source_span/source_span.dart' as source_span; | |
| 10 | 9 |
| 11 /** | 10 /** |
| 12 * An implementation of [Source] that's based on an in-memory Dart string. | 11 * An implementation of [Source] that's based on an in-memory Dart string. |
| 13 */ | 12 */ |
| 14 class StringSource extends Source { | 13 class StringSource extends Source { |
| 15 /** | 14 /** |
| 16 * The content of the source. | 15 * The content of the source. |
| 17 */ | 16 */ |
| 18 final String _contents; | 17 final String _contents; |
| 19 | 18 |
| 20 source_span.SourceFile _sourceFile; | |
| 21 | |
| 22 @override | 19 @override |
| 23 final String fullName; | 20 final String fullName; |
| 24 | 21 |
| 25 @override | 22 @override |
| 26 final Uri uri; | 23 final Uri uri; |
| 27 | 24 |
| 28 @override | 25 @override |
| 29 final int modificationStamp; | 26 final int modificationStamp; |
| 30 | 27 |
| 31 StringSource(this._contents, String fullName) | 28 StringSource(this._contents, String fullName) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 @override | 40 @override |
| 44 int get hashCode => _contents.hashCode ^ fullName.hashCode; | 41 int get hashCode => _contents.hashCode ^ fullName.hashCode; |
| 45 | 42 |
| 46 @override | 43 @override |
| 47 bool get isInSystemLibrary => false; | 44 bool get isInSystemLibrary => false; |
| 48 | 45 |
| 49 @override | 46 @override |
| 50 String get shortName => fullName; | 47 String get shortName => fullName; |
| 51 | 48 |
| 52 @override | 49 @override |
| 53 source_span.SourceFile get sourceFile => | |
| 54 _sourceFile ??= new source_span.SourceFile(_contents, url: uri); | |
| 55 | |
| 56 @override | |
| 57 UriKind get uriKind => UriKind.FILE_URI; | 50 UriKind get uriKind => UriKind.FILE_URI; |
| 58 | 51 |
| 59 /** | 52 /** |
| 60 * Return `true` if the given [object] is a string source that is equal to | 53 * Return `true` if the given [object] is a string source that is equal to |
| 61 * this source. | 54 * this source. |
| 62 */ | 55 */ |
| 63 @override | 56 @override |
| 64 bool operator ==(Object object) { | 57 bool operator ==(Object object) { |
| 65 return object is StringSource && | 58 return object is StringSource && |
| 66 object._contents == _contents && | 59 object._contents == _contents && |
| 67 object.fullName == fullName; | 60 object.fullName == fullName; |
| 68 } | 61 } |
| 69 | 62 |
| 70 @override | 63 @override |
| 71 bool exists() => true; | 64 bool exists() => true; |
| 72 | 65 |
| 73 @override | 66 @override |
| 74 String toString() => 'StringSource ($fullName)'; | 67 String toString() => 'StringSource ($fullName)'; |
| 75 } | 68 } |
| OLD | NEW |