| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 services.index; | 5 library services.index; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/index/index_core.dart'; | 9 import 'package:analysis_server/plugin/index/index_core.dart'; |
| 10 import 'package:analysis_server/src/services/index/indexable_element.dart'; | 10 import 'package:analysis_server/src/services/index/indexable_element.dart'; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * Initialize a newly created indexable name to represent the given [name]. | 76 * Initialize a newly created indexable name to represent the given [name]. |
| 77 */ | 77 */ |
| 78 IndexableName(this.name); | 78 IndexableName(this.name); |
| 79 | 79 |
| 80 @override | 80 @override |
| 81 String get filePath => null; | 81 String get filePath => null; |
| 82 | 82 |
| 83 @override | 83 @override |
| 84 IndexableObjectKind get kind => IndexableNameKind.INSTANCE; | 84 IndexableNameKind get kind => IndexableNameKind.INSTANCE; |
| 85 | 85 |
| 86 @override | 86 @override |
| 87 int get offset { | 87 int get offset { |
| 88 return -1; | 88 return -1; |
| 89 } | 89 } |
| 90 | 90 |
| 91 @override | 91 @override |
| 92 bool operator ==(Object object) => | 92 bool operator ==(Object object) => |
| 93 object is IndexableName && object.name == name; | 93 object is IndexableName && object.name == name; |
| 94 | 94 |
| 95 @override | 95 @override |
| 96 String toString() => name; | 96 String toString() => name; |
| 97 } | 97 } |
| 98 | 98 |
| 99 /** | 99 /** |
| 100 * The kind of an indexable name. | 100 * The kind of an indexable name. |
| 101 */ | 101 */ |
| 102 class IndexableNameKind implements IndexableObjectKind { | 102 class IndexableNameKind implements IndexableObjectKind<IndexableName> { |
| 103 /** | 103 /** |
| 104 * The unique instance of this class. | 104 * The unique instance of this class. |
| 105 */ | 105 */ |
| 106 static final IndexableNameKind INSTANCE = | 106 static final IndexableNameKind INSTANCE = |
| 107 new IndexableNameKind._(IndexableObjectKind.nextIndex); | 107 new IndexableNameKind._(IndexableObjectKind.nextIndex); |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * The index uniquely identifying this kind. | 110 * The index uniquely identifying this kind. |
| 111 */ | 111 */ |
| 112 final int index; | 112 final int index; |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * Initialize a newly created kind to have the given [index]. | 115 * Initialize a newly created kind to have the given [index]. |
| 116 */ | 116 */ |
| 117 IndexableNameKind._(this.index) { | 117 IndexableNameKind._(this.index) { |
| 118 IndexableObjectKind.register(this); | 118 IndexableObjectKind.register(this); |
| 119 } | 119 } |
| 120 | 120 |
| 121 @override | 121 @override |
| 122 IndexableObject decode(AnalysisContext context, String filePath, int offset) { | 122 IndexableName decode(AnalysisContext context, String filePath, int offset) { |
| 123 throw new UnsupportedError( | 123 throw new UnsupportedError( |
| 124 'Indexable names cannot be decoded through their kind'); | 124 'Indexable names cannot be decoded through their kind'); |
| 125 } | 125 } |
| 126 | 126 |
| 127 @override | 127 @override |
| 128 int encodeHash(StringToInt stringToInt, IndexableObject indexable) { | 128 int encodeHash(StringToInt stringToInt, IndexableName indexable) { |
| 129 String name = (indexable as IndexableName).name; | 129 String name = indexable.name; |
| 130 return stringToInt(name); | 130 return stringToInt(name); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * Constants used when populating and accessing the index. | 135 * Constants used when populating and accessing the index. |
| 136 */ | 136 */ |
| 137 class IndexConstants { | 137 class IndexConstants { |
| 138 /** | 138 /** |
| 139 * Left: the Universe or a Library. | 139 * Left: the Universe or a Library. |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 */ | 362 */ |
| 363 static RelationshipImpl getRelationship(String identifier) { | 363 static RelationshipImpl getRelationship(String identifier) { |
| 364 RelationshipImpl relationship = _RELATIONSHIP_MAP[identifier]; | 364 RelationshipImpl relationship = _RELATIONSHIP_MAP[identifier]; |
| 365 if (relationship == null) { | 365 if (relationship == null) { |
| 366 relationship = new RelationshipImpl(identifier); | 366 relationship = new RelationshipImpl(identifier); |
| 367 _RELATIONSHIP_MAP[identifier] = relationship; | 367 _RELATIONSHIP_MAP[identifier] = relationship; |
| 368 } | 368 } |
| 369 return relationship; | 369 return relationship; |
| 370 } | 370 } |
| 371 } | 371 } |
| OLD | NEW |