Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: pkg/analysis_server/lib/src/services/index/index.dart

Issue 1347943006: Replace NameElement with IndexableName. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/index/index_contributor.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/analysis/index/index_core.dart'; 9 import 'package:analysis_server/analysis/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 * After calling this method operations may not be executed. 71 * After calling this method operations may not be executed.
72 */ 72 */
73 void stop(); 73 void stop();
74 } 74 }
75 75
76 /** 76 /**
77 * An [Element] which is used to index references to the name without specifying 77 * An [Element] which is used to index references to the name without specifying
78 * a concrete kind of this name - field, method or something else. 78 * a concrete kind of this name - field, method or something else.
79 */ 79 */
80 class IndexableName implements IndexableObject { 80 class IndexableName implements IndexableObject {
81 // TODO(brianwilkerson) Replace NameElement with this class. This will require
82 // generalizing the search engine to use IndexableObject rather than Element.
scheglov 2015/09/21 18:33:47 Actually no. NameElement is used only in searchEl
83 /** 81 /**
84 * The name to be indexed. 82 * The name to be indexed.
85 */ 83 */
86 final String name; 84 final String name;
87 85
88 /** 86 /**
89 * Initialize a newly created indexable name to represent the given [name]. 87 * Initialize a newly created indexable name to represent the given [name].
90 */ 88 */
91 IndexableName(this.name); 89 IndexableName(this.name);
92 90
93 @override 91 @override
94 IndexableObjectKind get kind => IndexableNameKind.INSTANCE; 92 IndexableObjectKind get kind => IndexableNameKind.INSTANCE;
95 93
96 @override 94 @override
97 int get length => 0; 95 int get length => 0;
98 96
99 @override 97 @override
100 int get offset { 98 int get offset {
101 return -1; 99 return -1;
102 } 100 }
103 101
104 @override 102 @override
105 Source get source => null; 103 Source get source => null;
106 104
107 @override 105 @override
106 bool operator ==(Object object) =>
107 object is IndexableName && object.name == name;
108
109 @override
108 String toString() => name; 110 String toString() => name;
109 } 111 }
110 112
111 /** 113 /**
112 * The kind of an indexable name. 114 * The kind of an indexable name.
113 */ 115 */
114 class IndexableNameKind implements IndexableObjectKind { 116 class IndexableNameKind implements IndexableObjectKind {
115 /** 117 /**
116 * The unique instance of this class. 118 * The unique instance of this class.
117 */ 119 */
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 * A [LocationImpl] with attached data. 315 * A [LocationImpl] with attached data.
314 */ 316 */
315 class LocationWithData<D> extends LocationImpl { 317 class LocationWithData<D> extends LocationImpl {
316 final D data; 318 final D data;
317 319
318 LocationWithData(LocationImpl location, this.data) 320 LocationWithData(LocationImpl location, this.data)
319 : super(location.indexable, location.offset, location.length); 321 : super(location.indexable, location.offset, location.length);
320 } 322 }
321 323
322 /** 324 /**
323 * An [Element] which is used to index references to the name without specifying
324 * a concrete kind of this name - field, method or something else.
325 */
326 class NameElement extends ElementImpl {
327 NameElement(String name) : super(name, -1);
328
329 @override
330 ElementKind get kind => ElementKind.NAME;
331
332 @override
333 accept(ElementVisitor visitor) => null;
334 }
335
336 /**
337 * Relationship between an element and a location. Relationships are identified 325 * Relationship between an element and a location. Relationships are identified
338 * by a globally unique identifier. 326 * by a globally unique identifier.
339 */ 327 */
340 class RelationshipImpl implements Relationship { 328 class RelationshipImpl implements Relationship {
341 /** 329 /**
342 * A table mapping relationship identifiers to relationships. 330 * A table mapping relationship identifiers to relationships.
343 */ 331 */
344 static Map<String, RelationshipImpl> _RELATIONSHIP_MAP = {}; 332 static Map<String, RelationshipImpl> _RELATIONSHIP_MAP = {};
345 333
346 /** 334 /**
(...skipping 27 matching lines...) Expand all
374 */ 362 */
375 static RelationshipImpl getRelationship(String identifier) { 363 static RelationshipImpl getRelationship(String identifier) {
376 RelationshipImpl relationship = _RELATIONSHIP_MAP[identifier]; 364 RelationshipImpl relationship = _RELATIONSHIP_MAP[identifier];
377 if (relationship == null) { 365 if (relationship == null) {
378 relationship = new RelationshipImpl(identifier); 366 relationship = new RelationshipImpl(identifier);
379 _RELATIONSHIP_MAP[identifier] = relationship; 367 _RELATIONSHIP_MAP[identifier] = relationship;
380 } 368 }
381 return relationship; 369 return relationship;
382 } 370 }
383 } 371 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/index/index_contributor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698