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

Unified Diff: pkg/analysis_server/lib/src/search/search_domain.dart

Issue 2525693002: Use single unit/node/element. (Closed)
Patch Set: Created 4 years, 1 month 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/search/search_domain.dart
diff --git a/pkg/analysis_server/lib/src/search/search_domain.dart b/pkg/analysis_server/lib/src/search/search_domain.dart
index b77f2df6666936008a456630839b294b20f713e0..1109ede3504c3b0ad4c891f4af6a3fa9768550a1 100644
--- a/pkg/analysis_server/lib/src/search/search_domain.dart
+++ b/pkg/analysis_server/lib/src/search/search_domain.dart
@@ -61,39 +61,30 @@ class SearchDomainHandler implements protocol.RequestHandler {
var params =
new protocol.SearchFindElementReferencesParams.fromRequest(request);
await server.onAnalysisComplete;
- // prepare elements
- List<Element> elements =
- server.getElementsAtOffset(params.file, params.offset);
- elements = elements.map((Element element) {
- if (element is ImportElement) {
- return element.prefix;
- }
- if (element is FieldFormalParameterElement) {
- return element.field;
- }
- if (element is PropertyAccessorElement) {
- return element.variable;
- }
- return element;
- }).where((Element element) {
- return element != null;
- }).toList();
+ // prepare element
+ Element element = server.getElementAtOffset(params.file, params.offset);
+ if (element is ImportElement) {
+ element = (element as ImportElement).prefix;
+ }
+ if (element is FieldFormalParameterElement) {
+ element = (element as FieldFormalParameterElement).field;
+ }
+ if (element is PropertyAccessorElement) {
+ element = (element as PropertyAccessorElement).variable;
+ }
// respond
String searchId = (_nextSearchId++).toString();
var result = new protocol.SearchFindElementReferencesResult();
- if (elements.isNotEmpty) {
+ if (element != null) {
result.id = searchId;
- result.element = protocol.convertElement(elements.first);
+ result.element = protocol.convertElement(element);
}
_sendSearchResult(request, result);
// search elements
- elements.forEach((Element element) async {
- var computer = new ElementReferencesComputer(searchEngine);
- List<protocol.SearchResult> results =
- await computer.compute(element, params.includePotential);
- bool isLast = identical(element, elements.last);
- _sendSearchNotification(searchId, isLast, results);
- });
+ var computer = new ElementReferencesComputer(searchEngine);
+ List<protocol.SearchResult> results =
+ await computer.compute(element, params.includePotential);
+ _sendSearchNotification(searchId, true, results);
}
Future findMemberDeclarations(protocol.Request request) async {
@@ -171,12 +162,11 @@ class SearchDomainHandler implements protocol.RequestHandler {
await server.onAnalysisComplete;
}
// prepare element
- List<Element> elements = server.getElementsAtOffset(file, params.offset);
- if (elements.isEmpty) {
+ Element element = server.getElementAtOffset(file, params.offset);
+ if (element == null) {
_sendTypeHierarchyNull(request);
return;
}
- Element element = elements.first;
// maybe supertype hierarchy only
if (params.superOnly == true) {
TypeHierarchyComputer computer =
« no previous file with comments | « pkg/analysis_server/lib/src/operation/operation_analysis.dart ('k') | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698