| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:front_end/src/base/analysis_target.dart'; | 5 import 'package:front_end/src/base/analysis_target.dart'; |
| 6 import 'package:front_end/src/base/timestamped_data.dart'; | 6 import 'package:front_end/src/base/timestamped_data.dart'; |
| 7 import 'package:front_end/src/base/uri_kind.dart'; | 7 import 'package:front_end/src/base/uri_kind.dart'; |
| 8 import 'package:path/path.dart' as pathos; |
| 9 |
| 10 /// Base class providing implementations for the methods in [Source] that don't |
| 11 /// require filesystem access. |
| 12 abstract class BasicSource extends Source { |
| 13 final Uri uri; |
| 14 |
| 15 BasicSource(this.uri); |
| 16 |
| 17 @override |
| 18 String get encoding => uri.toString(); |
| 19 |
| 20 @override |
| 21 String get fullName => encoding; |
| 22 |
| 23 @override |
| 24 int get hashCode => uri.hashCode; |
| 25 |
| 26 @override |
| 27 bool get isInSystemLibrary => uri.scheme == 'dart'; |
| 28 |
| 29 @override |
| 30 String get shortName => pathos.basename(fullName); |
| 31 |
| 32 @override |
| 33 bool operator ==(Object object) => object is Source && object.uri == uri; |
| 34 } |
| 8 | 35 |
| 9 /** | 36 /** |
| 10 * The interface `Source` defines the behavior of objects representing source co
de that can be | 37 * The interface `Source` defines the behavior of objects representing source co
de that can be |
| 11 * analyzed by the analysis engine. | 38 * analyzed by the analysis engine. |
| 12 * | 39 * |
| 13 * Implementations of this interface need to be aware of some assumptions made b
y the analysis | 40 * Implementations of this interface need to be aware of some assumptions made b
y the analysis |
| 14 * engine concerning sources: | 41 * engine concerning sources: |
| 15 * * Sources are not required to be unique. That is, there can be multiple insta
nces representing | 42 * * Sources are not required to be unique. That is, there can be multiple insta
nces representing |
| 16 * the same source. | 43 * the same source. |
| 17 * * Sources are long lived. That is, the engine is allowed to hold on to a sour
ce for an extended | 44 * * Sources are long lived. That is, the engine is allowed to hold on to a sour
ce for an extended |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 * Return `true` if this source exists. | 166 * Return `true` if this source exists. |
| 140 * | 167 * |
| 141 * Clients should consider using the method [AnalysisContext.exists] because | 168 * Clients should consider using the method [AnalysisContext.exists] because |
| 142 * contexts can have local overrides of the content of a source that the sourc
e is not aware of | 169 * contexts can have local overrides of the content of a source that the sourc
e is not aware of |
| 143 * and a source with local content is considered to exist even if there is no
file on disk. | 170 * and a source with local content is considered to exist even if there is no
file on disk. |
| 144 * | 171 * |
| 145 * @return `true` if this source exists | 172 * @return `true` if this source exists |
| 146 */ | 173 */ |
| 147 bool exists(); | 174 bool exists(); |
| 148 } | 175 } |
| OLD | NEW |