| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, 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 services.index.indexable_file; | |
| 6 | |
| 7 import 'package:analysis_server/src/provisional/index/index_core.dart'; | |
| 8 import 'package:analyzer/src/generated/engine.dart'; | |
| 9 | |
| 10 /** | |
| 11 * An [IndexableObject] which is used to index references to a file. | |
| 12 */ | |
| 13 class IndexableFile implements IndexableObject { | |
| 14 /** | |
| 15 * The path of the file to be indexed. | |
| 16 */ | |
| 17 @override | |
| 18 final String path; | |
| 19 | |
| 20 /** | |
| 21 * Initialize a newly created indexable file to represent the given [path]. | |
| 22 */ | |
| 23 IndexableFile(this.path); | |
| 24 | |
| 25 @override | |
| 26 String get filePath => path; | |
| 27 | |
| 28 @override | |
| 29 IndexableObjectKind get kind => IndexableFileKind.INSTANCE; | |
| 30 | |
| 31 @override | |
| 32 int get offset => -1; | |
| 33 | |
| 34 @override | |
| 35 bool operator ==(Object object) => | |
| 36 object is IndexableFile && object.path == path; | |
| 37 | |
| 38 @override | |
| 39 String toString() => path; | |
| 40 } | |
| 41 | |
| 42 /** | |
| 43 * The kind of an indexable file. | |
| 44 */ | |
| 45 class IndexableFileKind implements IndexableObjectKind<IndexableFile> { | |
| 46 /** | |
| 47 * The unique instance of this class. | |
| 48 */ | |
| 49 static final IndexableFileKind INSTANCE = | |
| 50 new IndexableFileKind._(IndexableObjectKind.nextIndex); | |
| 51 | |
| 52 /** | |
| 53 * The index uniquely identifying this kind. | |
| 54 */ | |
| 55 final int index; | |
| 56 | |
| 57 /** | |
| 58 * Initialize a newly created kind to have the given [index]. | |
| 59 */ | |
| 60 IndexableFileKind._(this.index) { | |
| 61 IndexableObjectKind.register(this); | |
| 62 } | |
| 63 | |
| 64 @override | |
| 65 IndexableFile decode(AnalysisContext context, String filePath, int offset) { | |
| 66 return new IndexableFile(filePath); | |
| 67 } | |
| 68 | |
| 69 @override | |
| 70 int encodeHash(StringToInt stringToInt, IndexableFile indexable) { | |
| 71 String path = indexable.path; | |
| 72 return stringToInt(path); | |
| 73 } | |
| 74 } | |
| OLD | NEW |