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

Side by Side Diff: pkg/analysis_server/lib/src/search/element_references.dart

Issue 1842063003: Start making server strong mode clean (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove unintended change Created 4 years, 8 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
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 search.element_references; 5 library search.element_references;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/collections.dart'; 9 import 'package:analysis_server/src/collections.dart';
10 import 'package:analysis_server/src/protocol_server.dart' 10 import 'package:analysis_server/src/protocol_server.dart'
(...skipping 28 matching lines...) Expand all
39 futureGroup.add(resultsFuture); 39 futureGroup.add(resultsFuture);
40 } 40 }
41 // merge results 41 // merge results
42 return futureGroup.future; 42 return futureGroup.future;
43 } 43 }
44 44
45 /** 45 /**
46 * Returns a [Future] completing with a [List] of references to [element] or 46 * Returns a [Future] completing with a [List] of references to [element] or
47 * to the corresponding hierarchy [Element]s. 47 * to the corresponding hierarchy [Element]s.
48 */ 48 */
49 Future<List<SearchResult>> _findElementsReferences(Element element) { 49 Future<List<SearchResult>> _findElementsReferences(Element element) async {
50 return _getRefElements(element).then((Iterable<Element> refElements) { 50 Iterable<Element> refElements = await _getRefElements(element);
51 var futureGroup = new _ConcatFutureGroup<SearchResult>(); 51 var futureGroup = new _ConcatFutureGroup<SearchResult>();
52 for (Element refElement in refElements) { 52 for (Element refElement in refElements) {
53 // add declaration 53 // add declaration
54 if (_isDeclarationInteresting(refElement)) { 54 if (_isDeclarationInteresting(refElement)) {
55 SearchResult searchResult = _newDeclarationResult(refElement); 55 SearchResult searchResult = _newDeclarationResult(refElement);
56 futureGroup.add(searchResult); 56 futureGroup.add(searchResult);
57 }
58 // do search
59 futureGroup.add(_findSingleElementReferences(refElement));
60 } 57 }
61 return futureGroup.future; 58 // do search
62 }); 59 futureGroup.add(_findSingleElementReferences(refElement));
60 }
61 return futureGroup.future;
63 } 62 }
64 63
65 /** 64 /**
66 * Returns a [Future] completing with a [List] of references to [element]. 65 * Returns a [Future] completing with a [List] of references to [element].
67 */ 66 */
68 Future<List<SearchResult>> _findSingleElementReferences(Element element) { 67 Future<List<SearchResult>> _findSingleElementReferences(Element element) {
69 Future<List<SearchMatch>> matchesFuture = 68 Future<List<SearchMatch>> matchesFuture =
70 searchEngine.searchReferences(element); 69 searchEngine.searchReferences(element);
71 return matchesFuture.then((List<SearchMatch> matches) { 70 return matchesFuture.then((List<SearchMatch> matches) {
72 return matches.map(toResult).toList(); 71 return matches.map(toResult).toList();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 141
143 Future<List<E>> get future { 142 Future<List<E>> get future {
144 return Future.wait(_futures).then(concatToList); 143 return Future.wait(_futures).then(concatToList);
145 } 144 }
146 145
147 /** 146 /**
148 * Adds a [Future] or an [E] value to results. 147 * Adds a [Future] or an [E] value to results.
149 */ 148 */
150 void add(value) { 149 void add(value) {
151 if (value is Future) { 150 if (value is Future) {
152 _futures.add(value); 151 _futures.add(value as Future<List<E>>);
153 } else { 152 } else {
154 _futures.add(new Future.value(<E>[value])); 153 _futures.add(new Future.value(<E>[value as E]));
155 } 154 }
156 } 155 }
157 } 156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698