Chromium Code Reviews| Index: pkg/analysis_server/lib/src/services/index/indexable_file.dart |
| diff --git a/pkg/analysis_server/lib/src/services/index/indexable_file.dart b/pkg/analysis_server/lib/src/services/index/indexable_file.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5108d383f49dc57a11af27422bd0bfa3c5d7c417 |
| --- /dev/null |
| +++ b/pkg/analysis_server/lib/src/services/index/indexable_file.dart |
| @@ -0,0 +1,76 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
|
Brian Wilkerson
2015/10/18 15:41:07
"2014" --> "2015"
|
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library services.index.indexable_file; |
| + |
| +import 'package:analysis_server/plugin/index/index_core.dart'; |
| +import 'package:analyzer/src/generated/engine.dart'; |
| + |
| +/** |
| + * An [Element] which is used to index references to a file. |
|
Brian Wilkerson
2015/10/18 15:41:07
"Element" --> "IndexableObject"
|
| + */ |
| +class IndexableFile implements IndexableObject { |
| + /** |
| + * The path of the file to be indexed. |
| + */ |
| + @override |
| + final String path; |
| + |
| + /** |
| + * Initialize a newly created indexable file to represent the given [path]. |
| + */ |
| + IndexableFile(this.path); |
| + |
| + @override |
| + String get filePath => path; |
| + |
| + @override |
| + IndexableObjectKind get kind => IndexableFileKind.INSTANCE; |
| + |
| + @override |
| + int get offset { |
|
Brian Wilkerson
2015/10/18 15:41:07
"=> -1"?
|
| + return -1; |
| + } |
| + |
| + @override |
| + bool operator ==(Object object) => |
| + object is IndexableFile && object.path == path; |
| + |
| + @override |
| + String toString() => path; |
| +} |
| + |
| +/** |
| + * The kind of an indexable file. |
| + */ |
| +class IndexableFileKind implements IndexableObjectKind { |
| + /** |
| + * The unique instance of this class. |
| + */ |
| + static final IndexableFileKind INSTANCE = |
| + new IndexableFileKind._(IndexableObjectKind.nextIndex); |
| + |
| + /** |
| + * The index uniquely identifying this kind. |
| + */ |
| + final int index; |
| + |
| + /** |
| + * Initialize a newly created kind to have the given [index]. |
| + */ |
| + IndexableFileKind._(this.index) { |
| + IndexableObjectKind.register(this); |
| + } |
| + |
| + @override |
| + IndexableObject decode(AnalysisContext context, String filePath, int offset) { |
| + return new IndexableFile(filePath); |
| + } |
| + |
| + @override |
| + int encodeHash(StringToInt stringToInt, IndexableObject indexable) { |
| + String path = (indexable as IndexableFile).path; |
| + return stringToInt(path); |
| + } |
| +} |