Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
|
Brian Wilkerson
2015/10/18 15:41:07
"2014" --> "2015"
| |
| 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/plugin/index/index_core.dart'; | |
| 8 import 'package:analyzer/src/generated/engine.dart'; | |
| 9 | |
| 10 /** | |
| 11 * An [Element] which is used to index references to a file. | |
|
Brian Wilkerson
2015/10/18 15:41:07
"Element" --> "IndexableObject"
| |
| 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 { | |
|
Brian Wilkerson
2015/10/18 15:41:07
"=> -1"?
| |
| 33 return -1; | |
| 34 } | |
| 35 | |
| 36 @override | |
| 37 bool operator ==(Object object) => | |
| 38 object is IndexableFile && object.path == path; | |
| 39 | |
| 40 @override | |
| 41 String toString() => path; | |
| 42 } | |
| 43 | |
| 44 /** | |
| 45 * The kind of an indexable file. | |
| 46 */ | |
| 47 class IndexableFileKind implements IndexableObjectKind { | |
| 48 /** | |
| 49 * The unique instance of this class. | |
| 50 */ | |
| 51 static final IndexableFileKind INSTANCE = | |
| 52 new IndexableFileKind._(IndexableObjectKind.nextIndex); | |
| 53 | |
| 54 /** | |
| 55 * The index uniquely identifying this kind. | |
| 56 */ | |
| 57 final int index; | |
| 58 | |
| 59 /** | |
| 60 * Initialize a newly created kind to have the given [index]. | |
| 61 */ | |
| 62 IndexableFileKind._(this.index) { | |
| 63 IndexableObjectKind.register(this); | |
| 64 } | |
| 65 | |
| 66 @override | |
| 67 IndexableObject decode(AnalysisContext context, String filePath, int offset) { | |
| 68 return new IndexableFile(filePath); | |
| 69 } | |
| 70 | |
| 71 @override | |
| 72 int encodeHash(StringToInt stringToInt, IndexableObject indexable) { | |
| 73 String path = (indexable as IndexableFile).path; | |
| 74 return stringToInt(path); | |
| 75 } | |
| 76 } | |
| OLD | NEW |