| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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 analysis_server.analysis.index.index_core; | 5 library analysis_server.analysis.index.index_core; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/services/index/index.dart'; | 10 import 'package:analysis_server/src/services/index/index.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart'; | 11 import 'package:analyzer/src/generated/engine.dart'; |
| 12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Return the integer value that corresponds to the given [str]. | 15 * Return the integer value that corresponds to the given [string]. The value of |
| 16 * The value of [str] may be `null`. | 16 * [string] may be `null`. |
| 17 * |
| 18 * Clients are not expected to implement this signature. A function of this type |
| 19 * is provided by the framework to clients in order to implement the method |
| 20 * [IndexableObjectKind.encodeHash]. |
| 17 */ | 21 */ |
| 18 typedef int StringToInt(String str); | 22 typedef int StringToInt(String string); |
| 19 | 23 |
| 20 /** | 24 /** |
| 21 * An object that can have a [Relationship] with various [Location]s in a code | 25 * An object that can have a [Relationship] with various [Location]s in a code |
| 22 * base. The object is abstractly represented by a [kind] and an [offset] within | 26 * base. The object is abstractly represented by a [kind] and an [offset] within |
| 23 * a [source]. | 27 * a [source]. |
| 24 * | 28 * |
| 25 * Clients must ensure that two distinct objects in the same source cannot have | 29 * Clients must ensure that two distinct objects in the same source cannot have |
| 26 * the same kind and offset. Failure to do so will make it impossible for | 30 * the same kind and offset. Failure to do so will make it impossible for |
| 27 * clients to identify the model element corresponding to the indexable object. | 31 * clients to identify the model element corresponding to the indexable object. |
| 28 * | 32 * |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 */ | 121 */ |
| 118 static void register(IndexableObjectKind kind) { | 122 static void register(IndexableObjectKind kind) { |
| 119 int index = kind.index; | 123 int index = kind.index; |
| 120 if (_registry.containsKey(index)) { | 124 if (_registry.containsKey(index)) { |
| 121 throw new ArgumentError('duplicate index for kind: $index'); | 125 throw new ArgumentError('duplicate index for kind: $index'); |
| 122 } | 126 } |
| 123 _registry[index] = kind; | 127 _registry[index] = kind; |
| 124 } | 128 } |
| 125 } | 129 } |
| 126 | 130 |
| 127 // A sketch of what the driver routine might look like: | |
| 128 // | |
| 129 //void buildIndexForSource(AnalysisContext context, Source source) { | |
| 130 // IndexStoreImpl store; | |
| 131 // store.aboutToIndex(context, source); | |
| 132 // try { | |
| 133 // for (IndexContributor contributor in contributors) { | |
| 134 // contributor.contributeTo(store, context, source); | |
| 135 // } | |
| 136 // } finally { | |
| 137 // store.doneIndexing(); | |
| 138 // } | |
| 139 //} | |
| 140 | |
| 141 /** | 131 /** |
| 142 * An object used to add relationships to the index. | 132 * An object used to add relationships to the index. |
| 143 * | 133 * |
| 144 * Clients are expected to subtype this class when implementing plugins. | 134 * Clients are expected to subtype this class when implementing plugins. |
| 145 */ | 135 */ |
| 146 abstract class IndexContributor { | 136 abstract class IndexContributor { |
| 147 /** | 137 /** |
| 148 * Contribute relationships existing in the given [object] to the given | 138 * Contribute relationships existing in the given [object] to the given |
| 149 * index [store] in the given [context]. | 139 * index [store] in the given [context]. |
| 150 */ | 140 */ |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 */ | 271 */ |
| 282 abstract class Relationship { | 272 abstract class Relationship { |
| 283 /** | 273 /** |
| 284 * Return a relationship that has the given [identifier]. If the relationship | 274 * Return a relationship that has the given [identifier]. If the relationship |
| 285 * has already been created, then it will be returned, otherwise a new | 275 * has already been created, then it will be returned, otherwise a new |
| 286 * relationship will be created | 276 * relationship will be created |
| 287 */ | 277 */ |
| 288 factory Relationship(String identifier) => | 278 factory Relationship(String identifier) => |
| 289 RelationshipImpl.getRelationship(identifier); | 279 RelationshipImpl.getRelationship(identifier); |
| 290 } | 280 } |
| OLD | NEW |