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

Unified Diff: pkg/analysis_server/lib/src/services/search/search_engine_internal.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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
index 6126e140f74a5b340ca5e06a228ff4b42a7ad69d..6efd7d0f96c4ffdd7cba25d7dc6738f7a77c87f7 100644
--- a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
+++ b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
@@ -24,10 +24,10 @@ class SearchEngineImpl implements SearchEngine {
@override
Future<List<SearchMatch>> searchElementDeclarations(String name) {
- NameElement element = new NameElement(name);
+ IndexableName indexableName = new IndexableName(name);
_Requestor requestor = new _Requestor(_index);
- requestor.add(
- element, IndexConstants.NAME_IS_DEFINED_BY, MatchKind.DECLARATION);
+ requestor.add(indexableName, IndexConstants.NAME_IS_DEFINED_BY,
+ MatchKind.DECLARATION);
return requestor.merge();
}
@@ -42,13 +42,14 @@ class SearchEngineImpl implements SearchEngine {
@override
Future<List<SearchMatch>> searchMemberReferences(String name) {
- NameElement element = new NameElement(name);
+ IndexableName indexableName = new IndexableName(name);
_Requestor requestor = new _Requestor(_index);
- requestor.add(element, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
- requestor.add(element, IndexConstants.IS_READ_BY, MatchKind.READ);
requestor.add(
- element, IndexConstants.IS_READ_WRITTEN_BY, MatchKind.READ_WRITE);
- requestor.add(element, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
+ indexableName, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
+ requestor.add(indexableName, IndexConstants.IS_READ_BY, MatchKind.READ);
+ requestor.add(
+ indexableName, IndexConstants.IS_READ_WRITTEN_BY, MatchKind.READ_WRITE);
+ requestor.add(indexableName, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
return requestor.merge();
}
@@ -93,9 +94,12 @@ class SearchEngineImpl implements SearchEngine {
@override
Future<List<SearchMatch>> searchSubtypes(ClassElement type) {
_Requestor requestor = new _Requestor(_index);
- requestor.add(type, IndexConstants.IS_EXTENDED_BY, MatchKind.REFERENCE);
- requestor.add(type, IndexConstants.IS_MIXED_IN_BY, MatchKind.REFERENCE);
- requestor.add(type, IndexConstants.IS_IMPLEMENTED_BY, MatchKind.REFERENCE);
+ requestor.addElement(
+ type, IndexConstants.IS_EXTENDED_BY, MatchKind.REFERENCE);
+ requestor.addElement(
+ type, IndexConstants.IS_MIXED_IN_BY, MatchKind.REFERENCE);
+ requestor.addElement(
+ type, IndexConstants.IS_IMPLEMENTED_BY, MatchKind.REFERENCE);
return requestor.merge();
}
@@ -114,7 +118,7 @@ class SearchEngineImpl implements SearchEngine {
Future<List<SearchMatch>> _searchReferences(Element element) {
_Requestor requestor = new _Requestor(_index);
- requestor.add(
+ requestor.addElement(
element, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
return requestor.merge();
}
@@ -122,7 +126,7 @@ class SearchEngineImpl implements SearchEngine {
Future<List<SearchMatch>> _searchReferences_Constructor(
ConstructorElement constructor) {
_Requestor requestor = new _Requestor(_index);
- requestor.add(
+ requestor.addElement(
constructor, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
return requestor.merge();
}
@@ -133,16 +137,20 @@ class SearchEngineImpl implements SearchEngine {
PropertyAccessorElement setter = field.setter;
_Requestor requestor = new _Requestor(_index);
// field itself
- requestor.add(field, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
- requestor.add(field, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
+ requestor.addElement(
+ field, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
+ requestor.addElement(field, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
// getter
if (getter != null) {
- requestor.add(getter, IndexConstants.IS_REFERENCED_BY, MatchKind.READ);
- requestor.add(getter, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
+ requestor.addElement(
+ getter, IndexConstants.IS_REFERENCED_BY, MatchKind.READ);
+ requestor.addElement(
+ getter, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
}
// setter
if (setter != null) {
- requestor.add(setter, IndexConstants.IS_REFERENCED_BY, MatchKind.WRITE);
+ requestor.addElement(
+ setter, IndexConstants.IS_REFERENCED_BY, MatchKind.WRITE);
}
// done
return requestor.merge();
@@ -151,20 +159,23 @@ class SearchEngineImpl implements SearchEngine {
Future<List<SearchMatch>> _searchReferences_Function(
FunctionElement function) {
_Requestor requestor = new _Requestor(_index);
- requestor.add(
+ requestor.addElement(
function, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
- requestor.add(function, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
+ requestor.addElement(
+ function, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
return requestor.merge();
}
Future<List<SearchMatch>> _searchReferences_LocalVariable(
LocalVariableElement variable) {
_Requestor requestor = new _Requestor(_index);
- requestor.add(variable, IndexConstants.IS_READ_BY, MatchKind.READ);
- requestor.add(
+ requestor.addElement(variable, IndexConstants.IS_READ_BY, MatchKind.READ);
+ requestor.addElement(
variable, IndexConstants.IS_READ_WRITTEN_BY, MatchKind.READ_WRITE);
- requestor.add(variable, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
- requestor.add(variable, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
+ requestor.addElement(
+ variable, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
+ requestor.addElement(
+ variable, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
return requestor.merge();
}
@@ -173,21 +184,24 @@ class SearchEngineImpl implements SearchEngine {
if (method is MethodMember) {
method = (method as MethodMember).baseElement;
}
- requestor.add(method, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
- requestor.add(method, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
+ requestor.addElement(
+ method, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
+ requestor.addElement(
+ method, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
return requestor.merge();
}
Future<List<SearchMatch>> _searchReferences_Parameter(
ParameterElement parameter) {
_Requestor requestor = new _Requestor(_index);
- requestor.add(parameter, IndexConstants.IS_READ_BY, MatchKind.READ);
- requestor.add(
+ requestor.addElement(parameter, IndexConstants.IS_READ_BY, MatchKind.READ);
+ requestor.addElement(
parameter, IndexConstants.IS_READ_WRITTEN_BY, MatchKind.READ_WRITE);
- requestor.add(parameter, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
- requestor.add(
+ requestor.addElement(
+ parameter, IndexConstants.IS_WRITTEN_BY, MatchKind.WRITE);
+ requestor.addElement(
parameter, IndexConstants.IS_REFERENCED_BY, MatchKind.REFERENCE);
- requestor.add(
+ requestor.addElement(
parameter, IndexConstants.IS_INVOKED_BY, MatchKind.INVOCATION);
return requestor.merge();
}
@@ -199,9 +213,9 @@ class _Requestor {
_Requestor(this.index);
- void add(Element element, RelationshipImpl relationship, MatchKind kind) {
- Future relationsFuture =
- index.getRelationships(new IndexableElement(element), relationship);
+ void add(IndexableObject indexable, RelationshipImpl relationship,
+ MatchKind kind) {
+ Future relationsFuture = index.getRelationships(indexable, relationship);
Future matchesFuture = relationsFuture.then((List<LocationImpl> locations) {
List<SearchMatch> matches = <SearchMatch>[];
for (LocationImpl location in locations) {
@@ -220,6 +234,12 @@ class _Requestor {
futures.add(matchesFuture);
}
+ void addElement(
+ Element element, RelationshipImpl relationship, MatchKind kind) {
+ IndexableElement indexable = new IndexableElement(element);
+ add(indexable, relationship, kind);
+ }
+
Future<List<SearchMatch>> merge() {
return Future.wait(futures).then((List<List<SearchMatch>> matchesList) {
return matchesList.expand((matches) => matches).toList();

Powered by Google App Engine
This is Rietveld 408576698