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

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

Issue 402433003: Search only for potential name references to Class members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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/search/search_result.dart'; 10 import 'package:analysis_server/src/search/search_result.dart';
(...skipping 12 matching lines...) Expand all
23 ElementReferencesComputer(this.searchEngine); 23 ElementReferencesComputer(this.searchEngine);
24 24
25 /** 25 /**
26 * Computes [SearchResult]s for [element] references. 26 * Computes [SearchResult]s for [element] references.
27 */ 27 */
28 Future<List<SearchResult>> compute(Element element, bool withPotential) { 28 Future<List<SearchResult>> compute(Element element, bool withPotential) {
29 var futureGroup = new _ConcatFutureGroup<SearchResult>(); 29 var futureGroup = new _ConcatFutureGroup<SearchResult>();
30 // find element references 30 // find element references
31 futureGroup.add(_findElementsReferences(element)); 31 futureGroup.add(_findElementsReferences(element));
32 // add potential references 32 // add potential references
33 if (withPotential) { 33 if (withPotential && _isMemberElement(element)) {
34 String name = element.displayName; 34 String name = element.displayName;
35 var matchesFuture = searchEngine.searchMemberReferences(name); 35 var matchesFuture = searchEngine.searchMemberReferences(name);
36 var resultsFuture = matchesFuture.then((List<SearchMatch> matches) { 36 var resultsFuture = matchesFuture.then((List<SearchMatch> matches) {
37 return matches.where((match) => !match.isResolved).map(toResult); 37 return matches.where((match) => !match.isResolved).map(toResult);
38 }); 38 });
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 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 new SourceRange(nameOffset, nameLength), 98 new SourceRange(nameOffset, nameLength),
99 true, 99 true,
100 false); 100 false);
101 return new SearchResult.fromMatch(searchMatch); 101 return new SearchResult.fromMatch(searchMatch);
102 } 102 }
103 103
104 static SearchResult toResult(SearchMatch match) { 104 static SearchResult toResult(SearchMatch match) {
105 return new SearchResult.fromMatch(match); 105 return new SearchResult.fromMatch(match);
106 } 106 }
107 107
108 static bool _isMemberElement(Element element) {
109 return element.enclosingElement is ClassElement;
110 }
111
108 static bool _isVariableLikeElement(Element element) { 112 static bool _isVariableLikeElement(Element element) {
109 if (element is LocalVariableElement) { 113 if (element is LocalVariableElement) {
110 return true; 114 return true;
111 } 115 }
112 if (element is ParameterElement) { 116 if (element is ParameterElement) {
113 return true; 117 return true;
114 } 118 }
115 if (element is PropertyInducingElement) { 119 if (element is PropertyInducingElement) {
116 return !element.isSynthetic; 120 return !element.isSynthetic;
117 } 121 }
(...skipping 17 matching lines...) Expand all
135 * Adds a [Future] or an [E] value to results. 139 * Adds a [Future] or an [E] value to results.
136 */ 140 */
137 void add(value) { 141 void add(value) {
138 if (value is Future) { 142 if (value is Future) {
139 _futures.add(value); 143 _futures.add(value);
140 } else { 144 } else {
141 _futures.add(new Future.value(<E>[value])); 145 _futures.add(new Future.value(<E>[value]));
142 } 146 }
143 } 147 }
144 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698