OLD | NEW |
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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library services.src.search.search_engine; | 8 library services.src.search.search_engine; |
9 | 9 |
10 ///** | 10 import 'dart:async'; |
11 // * Instances of the class <code>AndSearchPattern</code> implement a search pat
tern that matches | 11 |
12 // * elements that match all of several other search patterns. | 12 import 'package:analysis_services/index/index.dart'; |
13 // */ | 13 import 'package:analysis_services/search/search_engine.dart'; |
14 //class AndSearchPattern implements SearchPattern { | 14 import 'package:analyzer/src/generated/element.dart'; |
15 // /** | 15 import 'package:analyzer/src/generated/source.dart'; |
16 // * The patterns used to determine whether this pattern matches an element. | 16 |
17 // */ | 17 |
18 // final List<SearchPattern> _patterns; | 18 /** |
19 // | 19 * A [SearchEngine] implementation. |
20 // /** | 20 */ |
21 // * Initialize a newly created search pattern to match elements that match al
l of several other | 21 class SearchEngineImpl implements SearchEngine { |
22 // * search patterns. | 22 final Index _index; |
23 // * | 23 |
24 // * @param patterns the patterns used to determine whether this pattern match
es an element | 24 SearchEngineImpl(this._index); |
25 // */ | 25 |
26 // AndSearchPattern(this._patterns); | 26 @override |
27 // | 27 Future<List<SearchMatch>> searchMemberDeclarations(String name) { |
28 // @override | 28 NameElement element = new NameElement(name); |
29 // MatchQuality matches(Element element) { | 29 _Requestor requestor = new _Requestor(_index); |
30 // MatchQuality highestQuality = null; | 30 requestor.add( |
31 // for (SearchPattern pattern in _patterns) { | 31 element, |
32 // MatchQuality quality = pattern.matches(element); | 32 IndexConstants.IS_DEFINED_BY, |
33 // if (quality == null) { | 33 MatchKind.NAME_DECLARATION); |
34 // return null; | 34 return requestor.merge().then((matches) { |
35 // } | 35 return matches.where((match) { |
36 // if (highestQuality == null) { | 36 return match.element.enclosingElement is ClassElement; |
37 // highestQuality = quality; | 37 }).toList(); |
38 // } else { | 38 }); |
39 // highestQuality = highestQuality.max(quality); | 39 } |
40 // } | 40 |
41 // } | 41 @override |
42 // return highestQuality; | 42 Future<List<SearchMatch>> searchMemberReferences(String name) { |
43 // } | 43 NameElement element = new NameElement(name); |
44 //} | 44 _Requestor requestor = new _Requestor(_index); |
45 // | 45 // rought |
46 ///** | 46 // requestor.add( |
47 // * Instances of the class <code>CamelCaseSearchPattern</code> implement a sear
ch pattern that | 47 // element, |
48 // * matches elements whose name matches a partial identifier where camel case c
onventions are used to | 48 // IndexConstants.IS_REFERENCED_BY_QUALIFIED_RESOLVED, |
49 // * perform what is essentially multiple prefix matches. | 49 // MatchKind.NAME_REFERENCE_RESOLVED); |
50 // */ | 50 // requestor.add( |
51 //class CamelCaseSearchPattern implements SearchPattern { | 51 // element, |
52 // /** | 52 // IndexConstants.IS_REFERENCED_BY_QUALIFIED_UNRESOLVED, |
53 // * The pattern that matching elements must match. | 53 // MatchKind.NAME_REFERENCE_UNRESOLVED, |
54 // */ | 54 // isResolved: false); |
55 // List<int> _pattern; | 55 // granular resolved operations |
56 // | 56 requestor.add( |
57 // /** | 57 element, |
58 // * A flag indicating whether the pattern and the name being matched must hav
e exactly the same | 58 IndexConstants.NAME_IS_INVOKED_BY_RESOLVED, |
59 // * number of parts (i.e. the same number of uppercase characters). | 59 MatchKind.NAME_INVOCATION_RESOLVED); |
60 // */ | 60 requestor.add( |
61 // final bool _samePartCount; | 61 element, |
62 // | 62 IndexConstants.NAME_IS_READ_BY_RESOLVED, |
63 // /** | 63 MatchKind.NAME_READ_RESOLVED); |
64 // * Initialize a newly created search pattern to match elements whose names m
atch the given | 64 requestor.add( |
65 // * camel-case pattern. | 65 element, |
66 // * | 66 IndexConstants.NAME_IS_READ_WRITTEN_BY_RESOLVED, |
67 // * @param pattern the pattern that matching elements must match | 67 MatchKind.NAME_READ_WRITE_RESOLVED); |
68 // * @param samePartCount `true` if the pattern and the name being matched mus
t have | 68 requestor.add( |
69 // * exactly the same number of parts (i.e. the same number of upperc
ase characters) | 69 element, |
70 // */ | 70 IndexConstants.NAME_IS_WRITTEN_BY_RESOLVED, |
71 // CamelCaseSearchPattern(String pattern, this._samePartCount) { | 71 MatchKind.NAME_WRITE_RESOLVED); |
72 // this._pattern = pattern.toCharArray(); | 72 // granular unresolved operations |
73 // } | 73 requestor.add( |
74 // | 74 element, |
75 // @override | 75 IndexConstants.NAME_IS_INVOKED_BY_UNRESOLVED, |
76 // MatchQuality matches(Element element) { | 76 MatchKind.NAME_INVOCATION_UNRESOLVED, |
77 // String name = element.displayName; | 77 isResolved: false); |
78 // if (name == null) { | 78 requestor.add( |
79 // return null; | 79 element, |
80 // } | 80 IndexConstants.NAME_IS_READ_BY_UNRESOLVED, |
81 // if (CharOperation.camelCaseMatch(_pattern, name.toCharArray(), _samePartCo
unt)) { | 81 MatchKind.NAME_READ_UNRESOLVED, |
82 // return MatchQuality.EXACT; | 82 isResolved: false); |
83 // } | 83 requestor.add( |
84 // return null; | 84 element, |
85 // } | 85 IndexConstants.NAME_IS_READ_WRITTEN_BY_UNRESOLVED, |
86 //} | 86 MatchKind.NAME_READ_WRITE_UNRESOLVED, |
87 // | 87 isResolved: false); |
88 ///** | 88 requestor.add( |
89 // * Instances of the class `CountingSearchListener` listen for search results,
passing those | 89 element, |
90 // * results on to a wrapped listener, but ensure that the wrapped search listen
er receives only one | 90 IndexConstants.NAME_IS_WRITTEN_BY_UNRESOLVED, |
91 // * notification that the search is complete. | 91 MatchKind.NAME_WRITE_UNRESOLVED, |
92 // */ | 92 isResolved: false); |
93 //class CountingSearchListener implements SearchListener { | 93 // done |
94 // /** | 94 return requestor.merge(); |
95 // * The number of times that this listener expects to be told that the search
is complete before | 95 } |
96 // * passing the information along to the wrapped listener. | 96 |
97 // */ | 97 @override |
98 // int _completionCount = 0; | 98 Future<List<SearchMatch>> searchReferences(Element element) { |
99 // | 99 if (element.kind == ElementKind.ANGULAR_COMPONENT || |
100 // /** | 100 element.kind == ElementKind.ANGULAR_CONTROLLER || |
101 // * The listener that will be notified as results are received and when the g
iven number of search | 101 element.kind == ElementKind.ANGULAR_FORMATTER || |
102 // * complete notifications have been received. | 102 element.kind == ElementKind.ANGULAR_PROPERTY || |
103 // */ | 103 element.kind == ElementKind.ANGULAR_SCOPE_PROPERTY || |
104 // final SearchListener _wrappedListener; | 104 element.kind == ElementKind.ANGULAR_SELECTOR) { |
105 // | 105 return _searchReferences_Angular(element as AngularElement); |
106 // /** | 106 } else if (element.kind == ElementKind.CLASS) { |
107 // * Initialize a newly created search listener to pass search results on to t
he given listener and | 107 return _searchReferences_Class(element as ClassElement); |
108 // * to notify the given listener that the search is complete after getting th
e given number of | 108 } else if (element.kind == ElementKind.COMPILATION_UNIT) { |
109 // * notifications. | 109 return _searchReferences_CompilationUnit( |
110 // * | 110 element as CompilationUnitElement); |
111 // * @param completionCount the number of times that this listener expects to
be told that the | 111 } else if (element.kind == ElementKind.CONSTRUCTOR) { |
112 // * search is complete | 112 return _searchReferences_Constructor(element as ConstructorElement); |
113 // * @param wrappedListener the listener that will be notified as results are
received | 113 } else if (element.kind == ElementKind.FIELD || |
114 // */ | 114 element.kind == ElementKind.TOP_LEVEL_VARIABLE) { |
115 // CountingSearchListener(int completionCount, this._wrappedListener) { | 115 return _searchReferences_Field(element as PropertyInducingElement); |
116 // this._completionCount = completionCount; | 116 } else if (element.kind == ElementKind.FUNCTION) { |
117 // if (completionCount == 0) { | 117 return _searchReferences_Function(element as FunctionElement); |
118 // _wrappedListener.searchComplete(); | 118 } else if (element.kind == ElementKind.GETTER || |
119 // } | 119 element.kind == ElementKind.SETTER) { |
120 // } | 120 return _searchReferences_PropertyAccessor( |
121 // | 121 element as PropertyAccessorElement); |
122 // @override | 122 } else if (element.kind == ElementKind.IMPORT) { |
123 // void matchFound(SearchMatch match) { | 123 return _searchReferences_Import(element as ImportElement); |
124 // _wrappedListener.matchFound(match); | 124 } else if (element.kind == ElementKind.LIBRARY) { |
125 // } | 125 return _searchReferences_Library(element as LibraryElement); |
126 // | 126 } else if (element.kind == ElementKind.LOCAL_VARIABLE) { |
127 // @override | 127 return _searchReferences_LocalVariable(element as LocalVariableElement); |
128 // void searchComplete() { | 128 } else if (element.kind == ElementKind.METHOD) { |
129 // _completionCount--; | 129 return _searchReferences_Method(element as MethodElement); |
130 // if (_completionCount <= 0) { | 130 } else if (element.kind == ElementKind.PARAMETER) { |
131 // _wrappedListener.searchComplete(); | 131 return _searchReferences_Parameter(element as ParameterElement); |
132 // } | 132 } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) { |
133 // } | 133 return _searchReferences_FunctionTypeAlias( |
134 //} | 134 element as FunctionTypeAliasElement); |
135 // | 135 } else if (element.kind == ElementKind.TYPE_PARAMETER) { |
136 ///** | 136 return _searchReferences_TypeParameter(element as TypeParameterElement); |
137 // * Instances of the class <code>ExactSearchPattern</code> implement a search p
attern that matches | 137 } |
138 // * elements whose name matches a specified identifier exactly. | 138 return new Future.value(<SearchMatch>[]); |
139 // */ | 139 } |
140 //class ExactSearchPattern implements SearchPattern { | 140 |
141 // /** | 141 @override |
142 // * The identifier that matching elements must be equal to. | 142 Future<List<SearchMatch>> searchSubtypes(ClassElement type) { |
143 // */ | 143 _Requestor requestor = new _Requestor(_index); |
144 // final String _identifier; | 144 requestor.add( |
145 // | 145 type, |
146 // /** | 146 IndexConstants.IS_EXTENDED_BY, |
147 // * A flag indicating whether a case sensitive match is to be performed. | 147 MatchKind.EXTENDS_REFERENCE); |
148 // */ | 148 requestor.add( |
149 // final bool _caseSensitive; | 149 type, |
150 // | 150 IndexConstants.IS_MIXED_IN_BY, |
151 // /** | 151 MatchKind.WITH_REFERENCE); |
152 // * Initialize a newly created search pattern to match elements whose names b
egin with the given | 152 requestor.add( |
153 // * prefix. | 153 type, |
154 // * | 154 IndexConstants.IS_IMPLEMENTED_BY, |
155 // * @param identifier the identifier that matching elements must be equal to | 155 MatchKind.IMPLEMENTS_REFERENCE); |
156 // * @param caseSensitive `true` if a case sensitive match is to be performed | 156 return requestor.merge(); |
157 // */ | 157 } |
158 // ExactSearchPattern(this._identifier, this._caseSensitive); | 158 |
159 // | 159 @override |
160 // @override | 160 Future<List<SearchMatch>> searchTopLevelDeclarations(String pattern) { |
161 // MatchQuality matches(Element element) { | 161 UniverseElement universe = UniverseElement.INSTANCE; |
162 // String name = element.displayName; | 162 _Requestor requestor = new _Requestor(_index); |
163 // if (name == null) { | 163 requestor.add( |
164 // return null; | 164 universe, |
165 // } | 165 IndexConstants.DEFINES_CLASS, |
166 // if (_caseSensitive && name == _identifier) { | 166 MatchKind.CLASS_DECLARATION); |
167 // return MatchQuality.EXACT; | 167 requestor.add( |
168 // } | 168 universe, |
169 // if (!_caseSensitive && javaStringEqualsIgnoreCase(name, _identifier)) { | 169 IndexConstants.DEFINES_CLASS_ALIAS, |
170 // return MatchQuality.EXACT; | 170 MatchKind.CLASS_ALIAS_DECLARATION); |
171 // } | 171 requestor.add( |
172 // return null; | 172 universe, |
173 // } | 173 IndexConstants.DEFINES_FUNCTION_TYPE, |
174 //} | 174 MatchKind.FUNCTION_TYPE_DECLARATION); |
175 // | 175 requestor.add( |
176 ///** | 176 universe, |
177 // * Instances of the class <code>FilteredSearchListener</code> implement a sear
ch listener that | 177 IndexConstants.DEFINES_FUNCTION, |
178 // * delegates to another search listener after removing matches that do not pas
s a given filter. | 178 MatchKind.FUNCTION_DECLARATION); |
179 // */ | 179 requestor.add( |
180 //class FilteredSearchListener extends WrappedSearchListener { | 180 universe, |
181 // /** | 181 IndexConstants.DEFINES_VARIABLE, |
182 // * The filter used to filter the matches. | 182 MatchKind.VARIABLE_DECLARATION); |
183 // */ | 183 RegExp regExp = new RegExp(pattern); |
184 // final SearchFilter _filter; | 184 return requestor.merge().then((List<SearchMatch> matches) { |
185 // | 185 return matches.where((SearchMatch match) { |
186 // /** | 186 String name = match.element.displayName; |
187 // * Initialize a newly created search listener to pass on any matches that pa
ss the given filter to | 187 return regExp.hasMatch(name); |
188 // * the given listener. | 188 }).toList(); |
189 // * | 189 }); |
190 // * @param filter the filter used to filter the matches | 190 } |
191 // * @param listener the search listener being wrapped | 191 |
192 // */ | 192 Future<List<SearchMatch>> _searchReferences_Angular(AngularElement element) { |
193 // FilteredSearchListener(this._filter, SearchListener listener) : super(listen
er); | 193 _Requestor requestor = new _Requestor(_index); |
194 // | 194 requestor.add( |
195 // @override | 195 element, |
196 // void matchFound(SearchMatch match) { | 196 IndexConstants.ANGULAR_REFERENCE, |
197 // if (_filter.passes(match)) { | 197 MatchKind.ANGULAR_REFERENCE); |
198 // propagateMatch(match); | 198 requestor.add( |
199 // } | 199 element, |
200 // } | 200 IndexConstants.ANGULAR_CLOSING_TAG_REFERENCE, |
201 //} | 201 MatchKind.ANGULAR_CLOSING_TAG_REFERENCE); |
202 // | 202 return requestor.merge(); |
203 ///** | 203 } |
204 // * [SearchListener] used by [SearchEngineImpl] internally to gather asynchrono
us results | 204 |
205 // * and return them synchronously. | 205 Future<List<SearchMatch>> _searchReferences_Class(ClassElement clazz) { |
206 // */ | 206 _Requestor requestor = new _Requestor(_index); |
207 //class GatheringSearchListener implements SearchListener { | 207 requestor.add( |
208 // /** | 208 clazz, |
209 // * A list containing the matches that have been found so far. | 209 IndexConstants.IS_REFERENCED_BY, |
210 // */ | 210 MatchKind.TYPE_REFERENCE); |
211 // List<SearchMatch> _matches = []; | 211 return requestor.merge(); |
212 // | 212 } |
213 // /** | 213 |
214 // * A flag indicating whether the search is complete. | 214 Future<List<SearchMatch>> |
215 // */ | 215 _searchReferences_CompilationUnit(CompilationUnitElement unit) { |
216 // bool _isComplete = false; | 216 _Requestor requestor = new _Requestor(_index); |
217 // | 217 requestor.add( |
218 // /** | 218 unit, |
219 // * @return the the matches that have been found. | 219 IndexConstants.IS_REFERENCED_BY, |
220 // */ | 220 MatchKind.UNIT_REFERENCE); |
221 // List<SearchMatch> get matches { | 221 return requestor.merge(); |
222 // _matches.sort(SearchMatch.SORT_BY_ELEMENT_NAME); | 222 } |
223 // return _matches; | 223 |
224 // } | 224 Future<List<SearchMatch>> |
225 // | 225 _searchReferences_Constructor(ConstructorElement constructor) { |
226 // /** | 226 _Requestor requestor = new _Requestor(_index); |
227 // * Return `true` if the search is complete. | 227 requestor.add( |
228 // * | 228 constructor, |
229 // * @return `true` if the search is complete | 229 IndexConstants.IS_DEFINED_BY, |
230 // */ | 230 MatchKind.CONSTRUCTOR_DECLARATION); |
231 // bool get isComplete => _isComplete; | 231 requestor.add( |
232 // | 232 constructor, |
233 // @override | 233 IndexConstants.IS_REFERENCED_BY, |
234 // void matchFound(SearchMatch match) { | 234 MatchKind.CONSTRUCTOR_REFERENCE); |
235 // _matches.add(match); | 235 return requestor.merge(); |
236 // } | 236 } |
237 // | 237 |
238 // @override | 238 Future<List<SearchMatch>> |
239 // void searchComplete() { | 239 _searchReferences_Field(PropertyInducingElement field) { |
240 // _isComplete = true; | 240 PropertyAccessorElement getter = field.getter; |
241 // } | 241 PropertyAccessorElement setter = field.setter; |
242 //} | 242 _Requestor requestor = new _Requestor(_index); |
243 // | 243 // field itself |
244 ///** | 244 requestor.add( |
245 // * Instances of the class <code>LibrarySearchScope</code> implement a search s
cope that encompasses | 245 field, |
246 // * everything in a given collection of libraries. | 246 IndexConstants.IS_REFERENCED_BY, |
247 // */ | 247 MatchKind.FIELD_REFERENCE); |
248 //class LibrarySearchScope implements SearchScope { | 248 requestor.add( |
249 // /** | 249 field, |
250 // * The libraries defining which elements are included in the scope. | 250 IndexConstants.IS_REFERENCED_BY_QUALIFIED, |
251 // */ | 251 MatchKind.FIELD_REFERENCE); |
252 // final List<LibraryElement> libraries; | 252 // getter |
253 // | 253 if (getter != null) { |
254 // /** | 254 requestor.add( |
255 // * Create a search scope that encompasses everything in the given libraries. | 255 getter, |
256 // * | 256 IndexConstants.IS_REFERENCED_BY_QUALIFIED, |
257 // * @param libraries the libraries defining which elements are included in th
e scope | 257 MatchKind.FIELD_READ); |
258 // */ | 258 requestor.add( |
259 // LibrarySearchScope.con1(Iterable<LibraryElement> libraries) : this.con2(new
List.from(libraries)); | 259 getter, |
260 // | 260 IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, |
261 // /** | 261 MatchKind.FIELD_READ); |
262 // * Create a search scope that encompasses everything in the given libraries. | 262 requestor.add( |
263 // * | 263 getter, |
264 // * @param libraries the libraries defining which elements are included in th
e scope | 264 IndexConstants.IS_INVOKED_BY_QUALIFIED, |
265 // */ | 265 MatchKind.FIELD_INVOCATION); |
266 // LibrarySearchScope.con2(this.libraries); | 266 requestor.add( |
267 // | 267 getter, |
268 // @override | 268 IndexConstants.IS_INVOKED_BY_UNQUALIFIED, |
269 // bool encloses(Element element) { | 269 MatchKind.FIELD_INVOCATION); |
270 // LibraryElement elementLibrary = element.getAncestor((element) => element i
s LibraryElement); | 270 } |
271 // return ArrayUtils.contains(libraries, elementLibrary); | 271 // setter |
272 // } | 272 if (setter != null) { |
273 //} | 273 requestor.add( |
274 // | 274 setter, |
275 ///** | 275 IndexConstants.IS_REFERENCED_BY_QUALIFIED, |
276 // * Instances of the class <code>NameMatchingSearchListener</code> implement a
search listener that | 276 MatchKind.FIELD_WRITE); |
277 // * delegates to another search listener after removing matches that do not mat
ch a given pattern. | 277 requestor.add( |
278 // */ | 278 setter, |
279 //class NameMatchingSearchListener extends WrappedSearchListener { | 279 IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, |
280 // /** | 280 MatchKind.FIELD_WRITE); |
281 // * The pattern used to filter the matches. | 281 } |
282 // */ | 282 // done |
283 // final SearchPattern _pattern; | 283 return requestor.merge(); |
284 // | 284 } |
285 // /** | 285 |
286 // * Initialize a newly created search listener to pass on any matches that ma
tch the given pattern | 286 Future<List<SearchMatch>> |
287 // * to the given listener. | 287 _searchReferences_Function(FunctionElement function) { |
288 // * | 288 _Requestor requestor = new _Requestor(_index); |
289 // * @param pattern the pattern used to filter the matches | 289 requestor.add( |
290 // * @param listener the search listener being wrapped | 290 function, |
291 // */ | 291 IndexConstants.IS_REFERENCED_BY, |
292 // NameMatchingSearchListener(this._pattern, SearchListener listener) : super(l
istener); | 292 MatchKind.FUNCTION_REFERENCE); |
293 // | 293 requestor.add( |
294 // @override | 294 function, |
295 // void matchFound(SearchMatch match) { | 295 IndexConstants.IS_INVOKED_BY, |
296 // if (_pattern.matches(match.element) != null) { | 296 MatchKind.FUNCTION_EXECUTION); |
297 // propagateMatch(match); | 297 return requestor.merge(); |
298 // } | 298 } |
299 // } | 299 |
300 //} | 300 Future<List<SearchMatch>> |
301 // | 301 _searchReferences_FunctionTypeAlias(FunctionTypeAliasElement alias) { |
302 ///** | 302 _Requestor requestor = new _Requestor(_index); |
303 // * Instances of the class <code>OrSearchPattern</code> implement a search patt
ern that matches | 303 requestor.add( |
304 // * elements that match any one of several other search patterns. | 304 alias, |
305 // */ | 305 IndexConstants.IS_REFERENCED_BY, |
306 //class OrSearchPattern implements SearchPattern { | 306 MatchKind.FUNCTION_TYPE_REFERENCE); |
307 // /** | 307 return requestor.merge(); |
308 // * The patterns used to determine whether this pattern matches an element. | 308 } |
309 // */ | 309 |
310 // final List<SearchPattern> _patterns; | 310 Future<List<SearchMatch>> _searchReferences_Import(ImportElement imp) { |
311 // | 311 _Requestor requestor = new _Requestor(_index); |
312 // /** | 312 requestor.add( |
313 // * Initialize a newly created search pattern to match elements that match an
y one of several other | 313 imp, |
314 // * search patterns. | 314 IndexConstants.IS_REFERENCED_BY, |
315 // * | 315 MatchKind.IMPORT_REFERENCE); |
316 // * @param patterns the patterns used to determine whether this pattern match
es an element | 316 return requestor.merge(); |
317 // */ | 317 } |
318 // OrSearchPattern(this._patterns); | 318 |
319 // | 319 Future<List<SearchMatch>> _searchReferences_Library(LibraryElement library) { |
320 // @override | 320 _Requestor requestor = new _Requestor(_index); |
321 // MatchQuality matches(Element element) { | 321 requestor.add( |
322 // // Do we want to return the highest quality of match rather than stopping | 322 library, |
323 // // after the first match? Doing so would be more accurate, but slower. | 323 IndexConstants.IS_REFERENCED_BY, |
324 // for (SearchPattern pattern in _patterns) { | 324 MatchKind.LIBRARY_REFERENCE); |
325 // MatchQuality quality = pattern.matches(element); | 325 return requestor.merge(); |
326 // if (quality != null) { | 326 } |
327 // return quality; | 327 |
328 // } | 328 Future<List<SearchMatch>> |
329 // } | 329 _searchReferences_LocalVariable(LocalVariableElement variable) { |
330 // return null; | 330 _Requestor requestor = new _Requestor(_index); |
331 // } | 331 requestor.add(variable, IndexConstants.IS_READ_BY, MatchKind.VARIABLE_READ); |
332 //} | 332 requestor.add( |
333 // | 333 variable, |
334 ///** | 334 IndexConstants.IS_READ_WRITTEN_BY, |
335 // * Instances of the class <code>PrefixSearchPattern</code> implement a search
pattern that matches | 335 MatchKind.VARIABLE_READ_WRITE); |
336 // * elements whose name has a given prefix. | 336 requestor.add( |
337 // */ | 337 variable, |
338 //class PrefixSearchPattern implements SearchPattern { | 338 IndexConstants.IS_WRITTEN_BY, |
339 // /** | 339 MatchKind.VARIABLE_WRITE); |
340 // * The prefix that matching elements must start with. | 340 requestor.add( |
341 // */ | 341 variable, |
342 // final String _prefix; | 342 IndexConstants.IS_INVOKED_BY, |
343 // | 343 MatchKind.FUNCTION_EXECUTION); |
344 // /** | 344 return requestor.merge(); |
345 // * A flag indicating whether a case sensitive match is to be performed. | 345 } |
346 // */ | 346 |
347 // final bool _caseSensitive; | 347 Future<List<SearchMatch>> _searchReferences_Method(MethodElement method) { |
348 // | 348 _Requestor requestor = new _Requestor(_index); |
349 // /** | 349 if (method is MethodMember) { |
350 // * Initialize a newly created search pattern to match elements whose names b
egin with the given | 350 method = (method as MethodMember).baseElement; |
351 // * prefix. | 351 } |
352 // * | 352 requestor.add( |
353 // * @param prefix the prefix that matching elements must start with | 353 method, |
354 // * @param caseSensitive `true` if a case sensitive match is to be performed | 354 IndexConstants.IS_REFERENCED_BY_QUALIFIED, |
355 // */ | 355 MatchKind.METHOD_REFERENCE); |
356 // PrefixSearchPattern(this._prefix, this._caseSensitive); | 356 requestor.add( |
357 // | 357 method, |
358 // @override | 358 IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, |
359 // MatchQuality matches(Element element) { | 359 MatchKind.METHOD_REFERENCE); |
360 // if (element == null) { | 360 requestor.add( |
361 // return null; | 361 method, |
362 // } | 362 IndexConstants.IS_INVOKED_BY_QUALIFIED, |
363 // String name = element.displayName; | 363 MatchKind.METHOD_INVOCATION); |
364 // if (name == null) { | 364 requestor.add( |
365 // return null; | 365 method, |
366 // } | 366 IndexConstants.IS_INVOKED_BY_UNQUALIFIED, |
367 // if (_caseSensitive && startsWith(name, _prefix)) { | 367 MatchKind.METHOD_INVOCATION); |
368 // return MatchQuality.EXACT; | 368 return requestor.merge(); |
369 // } | 369 } |
370 // if (!_caseSensitive && startsWithIgnoreCase(name, _prefix)) { | 370 |
371 // return MatchQuality.EXACT; | 371 Future<List<SearchMatch>> |
372 // } | 372 _searchReferences_Parameter(ParameterElement parameter) { |
373 // return null; | 373 _Requestor requestor = new _Requestor(_index); |
374 // } | 374 requestor.add( |
375 //} | 375 parameter, |
376 // | 376 IndexConstants.IS_READ_BY, |
377 ///** | 377 MatchKind.VARIABLE_READ); |
378 // * Instances of the class <code>RegularExpressionSearchPattern</code> implemen
t a search pattern | 378 requestor.add( |
379 // * that matches elements whose name matches a given regular expression. | 379 parameter, |
380 // */ | 380 IndexConstants.IS_READ_WRITTEN_BY, |
381 //class RegularExpressionSearchPattern implements SearchPattern { | 381 MatchKind.VARIABLE_READ_WRITE); |
382 // /** | 382 requestor.add( |
383 // * The regular expression pattern that matching elements must match. | 383 parameter, |
384 // */ | 384 IndexConstants.IS_WRITTEN_BY, |
385 // RegExp _pattern; | 385 MatchKind.VARIABLE_WRITE); |
386 // | 386 requestor.add( |
387 // /** | 387 parameter, |
388 // * Initialize a newly created search pattern to match elements whose names b
egin with the given | 388 IndexConstants.IS_REFERENCED_BY, |
389 // * prefix. | 389 MatchKind.NAMED_PARAMETER_REFERENCE); |
390 // * | 390 requestor.add( |
391 // * @param regularExpression the regular expression that matching elements mu
st match | 391 parameter, |
392 // * @param caseSensitive `true` if a case sensitive match is to be performed | 392 IndexConstants.IS_INVOKED_BY, |
393 // */ | 393 MatchKind.FUNCTION_EXECUTION); |
394 // RegularExpressionSearchPattern(String regularExpression, bool caseSensitive)
{ | 394 return requestor.merge(); |
395 // _pattern = new RegExp(regularExpression); | 395 } |
396 // } | 396 |
397 // | 397 Future<List<SearchMatch>> |
398 // @override | 398 _searchReferences_PropertyAccessor(PropertyAccessorElement accessor) { |
399 // MatchQuality matches(Element element) { | 399 _Requestor requestor = new _Requestor(_index); |
400 // if (element == null) { | 400 requestor.add( |
401 // return null; | 401 accessor, |
402 // } | 402 IndexConstants.IS_REFERENCED_BY_QUALIFIED, |
403 // String name = element.displayName; | 403 MatchKind.PROPERTY_ACCESSOR_REFERENCE); |
404 // if (name == null) { | 404 requestor.add( |
405 // return null; | 405 accessor, |
406 // } | 406 IndexConstants.IS_REFERENCED_BY_UNQUALIFIED, |
407 // if (new JavaPatternMatcher(_pattern, name).matches()) { | 407 MatchKind.PROPERTY_ACCESSOR_REFERENCE); |
408 // return MatchQuality.EXACT; | 408 return requestor.merge(); |
409 // } | 409 } |
410 // return null; | 410 |
411 // } | 411 Future<List<SearchMatch>> |
412 //} | 412 _searchReferences_TypeParameter(TypeParameterElement typeParameter) { |
413 // | 413 _Requestor requestor = new _Requestor(_index); |
414 ///** | 414 requestor.add( |
415 // * Factory for [SearchEngine]. | 415 typeParameter, |
416 // */ | 416 IndexConstants.IS_REFERENCED_BY, |
417 //class SearchEngineFactory { | 417 MatchKind.TYPE_PARAMETER_REFERENCE); |
418 // /** | 418 return requestor.merge(); |
419 // * @return the new [SearchEngine] instance based on the given [Index]. | 419 } |
420 // */ | 420 } |
421 // static SearchEngine createSearchEngine(Index index) => new SearchEngineImpl(
index); | 421 |
422 //} | 422 |
423 | 423 class _Requestor { |
424 ///** | 424 final List<Future<List<SearchMatch>>> futures = <Future<List<SearchMatch>>>[]; |
425 // * Implementation of [SearchEngine]. | 425 final Index index; |
426 // */ | 426 |
427 //class SearchEngineImpl implements SearchEngine { | 427 _Requestor(this.index); |
428 // /** | 428 |
429 // * Apply the given filter to the given listener. | 429 void add(Element element2, Relationship relationship, MatchKind kind, |
430 // * | 430 {bool isResolved: true}) { |
431 // * @param filter the filter to be used before passing matches on to the list
ener, or `null` | 431 Future relationsFuture = index.getRelationships(element2, relationship); |
432 // * if all matches should be passed on | 432 Future matchesFuture = relationsFuture.then((List<Location> locations) { |
433 // * @param listener the listener that will only be given matches that pass th
e filter | 433 bool isQualified = |
434 // * @return a search listener that will pass to the given listener any matche
s that pass the given | 434 relationship == IndexConstants.IS_REFERENCED_BY_QUALIFIED || |
435 // * filter | 435 relationship == IndexConstants.IS_INVOKED_BY_QUALIFIED; |
436 // */ | 436 List<SearchMatch> matches = <SearchMatch>[]; |
437 // static SearchListener _applyFilter(SearchFilter filter, SearchListener liste
ner) { | 437 for (Location location in locations) { |
438 // if (filter == null) { | 438 Element element = location.element; |
439 // return listener; | 439 matches.add( |
440 // } | 440 new SearchMatch( |
441 // return new FilteredSearchListener(filter, listener); | 441 kind, |
442 // } | 442 element, |
443 // | 443 new SourceRange(location.offset, location.length), |
444 // /** | 444 isResolved, |
445 // * Apply the given pattern to the given listener. | 445 isQualified)); |
446 // * | 446 } |
447 // * @param pattern the pattern to be used before passing matches on to the li
stener, or | 447 return matches; |
448 // * `null` if all matches should be passed on | 448 }); |
449 // * @param listener the listener that will only be given matches that match t
he pattern | 449 futures.add(matchesFuture); |
450 // * @return a search listener that will pass to the given listener any matche
s that match the given | 450 } |
451 // * pattern | 451 |
452 // */ | 452 Future<List<SearchMatch>> merge() { |
453 // static SearchListener _applyPattern(SearchPattern pattern, SearchListener li
stener) { | 453 return Future.wait(futures).then((List<List<SearchMatch>> matchesList) { |
454 // if (pattern == null) { | 454 return matchesList.expand((matches) => matches).toList(); |
455 // return listener; | 455 }); |
456 // } | 456 } |
457 // return new NameMatchingSearchListener(pattern, listener); | 457 } |
458 // } | |
459 // | |
460 // static List<Element> _createElements(SearchScope scope) { | |
461 // if (scope is LibrarySearchScope) { | |
462 // return scope.libraries; | |
463 // } | |
464 // return <Element> [IndexConstants.UNIVERSE]; | |
465 // } | |
466 // | |
467 // static RelationshipCallback _newCallback(MatchKind matchKind, SearchScope sc
ope, SearchListener listener) => new SearchEngineImpl_RelationshipCallbackImpl(s
cope, matchKind, listener); | |
468 // | |
469 // /** | |
470 // * The index used to respond to the search requests. | |
471 // */ | |
472 // final Index _index; | |
473 // | |
474 // /** | |
475 // * Initialize a newly created search engine to use the given index. | |
476 // * | |
477 // * @param index the index used to respond to the search requests | |
478 // */ | |
479 // SearchEngineImpl(this._index); | |
480 // | |
481 // @override | |
482 // Set<DartType> searchAssignedTypes(PropertyInducingElement variable, SearchSc
ope scope) { | |
483 // PropertyAccessorElement setter = variable.setter; | |
484 // int numRequests = (setter != null ? 2 : 0) + 2; | |
485 // // find locations | |
486 // List<Location> locations = []; | |
487 // CountDownLatch latch = new CountDownLatch(numRequests); | |
488 // if (setter != null) { | |
489 // _index.getRelationships(setter, IndexConstants.IS_REFERENCED_BY_QUALIFIE
D, new Callback()); | |
490 // _index.getRelationships(setter, IndexConstants.IS_REFERENCED_BY_UNQUALIF
IED, new Callback()); | |
491 // } | |
492 // _index.getRelationships(variable, IndexConstants.IS_REFERENCED_BY, new Cal
lback()); | |
493 // _index.getRelationships(variable, IndexConstants.IS_DEFINED_BY, new Callba
ck()); | |
494 // Uninterruptibles.awaitUninterruptibly(latch); | |
495 // // get types from locations | |
496 // Set<DartType> types = new Set(); | |
497 // for (Location location in locations) { | |
498 // // check scope | |
499 // if (scope != null) { | |
500 // Element targetElement = location.element; | |
501 // if (!scope.encloses(targetElement)) { | |
502 // continue; | |
503 // } | |
504 // } | |
505 // // we need data | |
506 // if (location is! LocationWithData) { | |
507 // continue; | |
508 // } | |
509 // LocationWithData locationWithData = location as LocationWithData; | |
510 // // add type | |
511 // Object data = locationWithData.data; | |
512 // if (data is DartType) { | |
513 // DartType type = data as DartType; | |
514 // types.add(type); | |
515 // } | |
516 // } | |
517 // // done | |
518 // return types; | |
519 // } | |
520 // | |
521 // @override | |
522 // List<SearchMatch> searchDeclarations(String name, SearchScope scope, SearchF
ilter filter) => _gatherResults(new SearchRunner_SearchEngineImpl_searchDeclarat
ions(this, name, scope, filter)); | |
523 // | |
524 // @override | |
525 // void searchDeclarations2(String name, SearchScope scope, SearchFilter filter
, SearchListener listener) { | |
526 // assert(listener != null); | |
527 // listener = _applyFilter(filter, listener); | |
528 // _index.getRelationships(new NameElementImpl(name), IndexConstants.IS_DEFIN
ED_BY, _newCallback(MatchKind.NAME_DECLARATION, scope, listener)); | |
529 // } | |
530 // | |
531 // @override | |
532 // List<SearchMatch> searchFunctionDeclarations(SearchScope scope, SearchPatter
n pattern, SearchFilter filter) => _gatherResults(new SearchRunner_SearchEngineI
mpl_searchFunctionDeclarations(this, scope, pattern, filter)); | |
533 // | |
534 // @override | |
535 // void searchFunctionDeclarations2(SearchScope scope, SearchPattern pattern, S
earchFilter filter, SearchListener listener) { | |
536 // assert(listener != null); | |
537 // List<Element> elements = _createElements(scope); | |
538 // listener = _applyPattern(pattern, listener); | |
539 // listener = _applyFilter(filter, listener); | |
540 // listener = new CountingSearchListener(elements.length, listener); | |
541 // for (Element element in elements) { | |
542 // _index.getRelationships(element, IndexConstants.DEFINES_FUNCTION, _newCa
llback(MatchKind.FUNCTION_DECLARATION, scope, listener)); | |
543 // } | |
544 // } | |
545 // | |
546 // @override | |
547 // List<SearchMatch> searchQualifiedMemberReferences(String name, SearchScope s
cope, SearchFilter filter) => _gatherResults(new SearchRunner_SearchEngineImpl_s
earchQualifiedMemberReferences(this, name, scope, filter)); | |
548 // | |
549 // @override | |
550 // void searchQualifiedMemberReferences2(String name, SearchScope scope, Search
Filter filter, SearchListener listener) { | |
551 // assert(listener != null); | |
552 // listener = _applyFilter(filter, listener); | |
553 // listener = new CountingSearchListener(10, listener); | |
554 // _index.getRelationships(new NameElementImpl(name), IndexConstants.IS_REFER
ENCED_BY_QUALIFIED_RESOLVED, _newCallback(MatchKind.NAME_REFERENCE_RESOLVED, sco
pe, listener)); | |
555 // _index.getRelationships(new NameElementImpl(name), IndexConstants.IS_REFER
ENCED_BY_QUALIFIED_UNRESOLVED, _newCallback(MatchKind.NAME_REFERENCE_UNRESOLVED,
scope, listener)); | |
556 // // granular resolved operations | |
557 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
INVOKED_BY_RESOLVED, _newCallback(MatchKind.NAME_INVOCATION_RESOLVED, scope, lis
tener)); | |
558 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
READ_BY_RESOLVED, _newCallback(MatchKind.NAME_READ_RESOLVED, scope, listener)); | |
559 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
READ_WRITTEN_BY_RESOLVED, _newCallback(MatchKind.NAME_READ_WRITE_RESOLVED, scope
, listener)); | |
560 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
WRITTEN_BY_RESOLVED, _newCallback(MatchKind.NAME_WRITE_RESOLVED, scope, listener
)); | |
561 // // granular unresolved operations | |
562 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
INVOKED_BY_UNRESOLVED, _newCallback(MatchKind.NAME_INVOCATION_UNRESOLVED, scope,
listener)); | |
563 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
READ_BY_UNRESOLVED, _newCallback(MatchKind.NAME_READ_UNRESOLVED, scope, listener
)); | |
564 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
READ_WRITTEN_BY_UNRESOLVED, _newCallback(MatchKind.NAME_READ_WRITE_UNRESOLVED, s
cope, listener)); | |
565 // _index.getRelationships(new NameElementImpl(name), IndexConstants.NAME_IS_
WRITTEN_BY_UNRESOLVED, _newCallback(MatchKind.NAME_WRITE_UNRESOLVED, scope, list
ener)); | |
566 // } | |
567 // | |
568 // @override | |
569 // List<SearchMatch> searchReferences(Element element, SearchScope scope, Searc
hFilter filter) => _gatherResults(new SearchRunner_SearchEngineImpl_searchRefere
nces(this, element, scope, filter)); | |
570 // | |
571 // @override | |
572 // void searchReferences2(Element element, SearchScope scope, SearchFilter filt
er, SearchListener listener) { | |
573 // if (element == null) { | |
574 // listener.searchComplete(); | |
575 // return; | |
576 // } | |
577 // if (element is Member) { | |
578 // element = (element as Member).baseElement; | |
579 // } | |
580 // while (true) { | |
581 // if (element.kind == ElementKind.ANGULAR_COMPONENT || element.kind == Ele
mentKind.ANGULAR_CONTROLLER || element.kind == ElementKind.ANGULAR_FORMATTER ||
element.kind == ElementKind.ANGULAR_PROPERTY || element.kind == ElementKind.ANGU
LAR_SCOPE_PROPERTY || element.kind == ElementKind.ANGULAR_SELECTOR) { | |
582 // _searchReferences(element as AngularElement, scope, filter, listener); | |
583 // return; | |
584 // } else if (element.kind == ElementKind.CLASS) { | |
585 // _searchReferences2(element as ClassElement, scope, filter, listener); | |
586 // return; | |
587 // } else if (element.kind == ElementKind.COMPILATION_UNIT) { | |
588 // _searchReferences3(element as CompilationUnitElement, scope, filter, l
istener); | |
589 // return; | |
590 // } else if (element.kind == ElementKind.CONSTRUCTOR) { | |
591 // _searchReferences4(element as ConstructorElement, scope, filter, liste
ner); | |
592 // return; | |
593 // } else if (element.kind == ElementKind.FIELD || element.kind == ElementK
ind.TOP_LEVEL_VARIABLE) { | |
594 // _searchReferences12(element as PropertyInducingElement, scope, filter,
listener); | |
595 // return; | |
596 // } else if (element.kind == ElementKind.FUNCTION) { | |
597 // _searchReferences5(element as FunctionElement, scope, filter, listener
); | |
598 // return; | |
599 // } else if (element.kind == ElementKind.GETTER || element.kind == Element
Kind.SETTER) { | |
600 // _searchReferences11(element as PropertyAccessorElement, scope, filter,
listener); | |
601 // return; | |
602 // } else if (element.kind == ElementKind.IMPORT) { | |
603 // _searchReferences7(element as ImportElement, scope, filter, listener); | |
604 // return; | |
605 // } else if (element.kind == ElementKind.LIBRARY) { | |
606 // _searchReferences8(element as LibraryElement, scope, filter, listener)
; | |
607 // return; | |
608 // } else if (element.kind == ElementKind.LOCAL_VARIABLE) { | |
609 // _searchReferences14(element as LocalVariableElement, scope, filter, li
stener); | |
610 // return; | |
611 // } else if (element.kind == ElementKind.METHOD) { | |
612 // _searchReferences9(element as MethodElement, scope, filter, listener); | |
613 // return; | |
614 // } else if (element.kind == ElementKind.PARAMETER) { | |
615 // _searchReferences10(element as ParameterElement, scope, filter, listen
er); | |
616 // return; | |
617 // } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) { | |
618 // _searchReferences6(element as FunctionTypeAliasElement, scope, filter,
listener); | |
619 // return; | |
620 // } else if (element.kind == ElementKind.TYPE_PARAMETER) { | |
621 // _searchReferences13(element as TypeParameterElement, scope, filter, li
stener); | |
622 // return; | |
623 // } else { | |
624 // listener.searchComplete(); | |
625 // return; | |
626 // } | |
627 // break; | |
628 // } | |
629 // } | |
630 // | |
631 // @override | |
632 // List<SearchMatch> searchSubtypes(ClassElement type, SearchScope scope, Searc
hFilter filter) => _gatherResults(new SearchRunner_SearchEngineImpl_searchSubtyp
es(this, type, scope, filter)); | |
633 // | |
634 // @override | |
635 // void searchSubtypes2(ClassElement type, SearchScope scope, SearchFilter filt
er, SearchListener listener) { | |
636 // assert(listener != null); | |
637 // listener = _applyFilter(filter, listener); | |
638 // listener = new CountingSearchListener(3, listener); | |
639 // _index.getRelationships(type, IndexConstants.IS_EXTENDED_BY, _newCallback(
MatchKind.EXTENDS_REFERENCE, scope, listener)); | |
640 // _index.getRelationships(type, IndexConstants.IS_MIXED_IN_BY, _newCallback(
MatchKind.WITH_REFERENCE, scope, listener)); | |
641 // _index.getRelationships(type, IndexConstants.IS_IMPLEMENTED_BY, _newCallba
ck(MatchKind.IMPLEMENTS_REFERENCE, scope, listener)); | |
642 // } | |
643 // | |
644 // @override | |
645 // List<SearchMatch> searchTypeDeclarations(SearchScope scope, SearchPattern pa
ttern, SearchFilter filter) => _gatherResults(new SearchRunner_SearchEngineImpl_
searchTypeDeclarations(this, scope, pattern, filter)); | |
646 // | |
647 // @override | |
648 // void searchTypeDeclarations2(SearchScope scope, SearchPattern pattern, Searc
hFilter filter, SearchListener listener) { | |
649 // assert(listener != null); | |
650 // List<Element> elements = _createElements(scope); | |
651 // listener = _applyPattern(pattern, listener); | |
652 // listener = _applyFilter(filter, listener); | |
653 // listener = new CountingSearchListener(elements.length * 3, listener); | |
654 // for (Element element in elements) { | |
655 // _index.getRelationships(element, IndexConstants.DEFINES_CLASS, _newCallb
ack(MatchKind.CLASS_DECLARATION, scope, listener)); | |
656 // _index.getRelationships(element, IndexConstants.DEFINES_CLASS_ALIAS, _ne
wCallback(MatchKind.CLASS_ALIAS_DECLARATION, scope, listener)); | |
657 // _index.getRelationships(element, IndexConstants.DEFINES_FUNCTION_TYPE, _
newCallback(MatchKind.FUNCTION_TYPE_DECLARATION, scope, listener)); | |
658 // } | |
659 // } | |
660 // | |
661 // @override | |
662 // List<SearchMatch> searchVariableDeclarations(SearchScope scope, SearchPatter
n pattern, SearchFilter filter) => _gatherResults(new SearchRunner_SearchEngineI
mpl_searchVariableDeclarations(this, scope, pattern, filter)); | |
663 // | |
664 // @override | |
665 // void searchVariableDeclarations2(SearchScope scope, SearchPattern pattern, S
earchFilter filter, SearchListener listener) { | |
666 // assert(listener != null); | |
667 // List<Element> elements = _createElements(scope); | |
668 // listener = _applyPattern(pattern, listener); | |
669 // listener = _applyFilter(filter, listener); | |
670 // listener = new CountingSearchListener(elements.length, listener); | |
671 // for (Element element in elements) { | |
672 // _index.getRelationships(element, IndexConstants.DEFINES_VARIABLE, _newCa
llback(MatchKind.VARIABLE_DECLARATION, scope, listener)); | |
673 // } | |
674 // } | |
675 // | |
676 // /** | |
677 // * Use the given runner to perform the given number of asynchronous searches
, then wait until the | |
678 // * search has completed and return the results that were produced. | |
679 // * | |
680 // * @param runner the runner used to perform an asynchronous search | |
681 // * @return the results that were produced @ if the results of at least one o
f the searched could | |
682 // * not be computed | |
683 // */ | |
684 // List<SearchMatch> _gatherResults(SearchEngineImpl_SearchRunner runner) { | |
685 // GatheringSearchListener listener = new GatheringSearchListener(); | |
686 // runner.performSearch(listener); | |
687 // while (!listener.isComplete) { | |
688 // Thread.yield(); | |
689 // } | |
690 // return listener.matches; | |
691 // } | |
692 // | |
693 // void _searchReferences(AngularElement element, SearchScope scope, SearchFilt
er filter, SearchListener listener) { | |
694 // assert(listener != null); | |
695 // listener = _applyFilter(filter, listener); | |
696 // listener = new CountingSearchListener(2, listener); | |
697 // _index.getRelationships(element, IndexConstants.ANGULAR_REFERENCE, _newCal
lback(MatchKind.ANGULAR_REFERENCE, scope, listener)); | |
698 // _index.getRelationships(element, IndexConstants.ANGULAR_CLOSING_TAG_REFERE
NCE, _newCallback(MatchKind.ANGULAR_CLOSING_TAG_REFERENCE, scope, listener)); | |
699 // } | |
700 // | |
701 // void _searchReferences2(ClassElement type, SearchScope scope, SearchFilter f
ilter, SearchListener listener) { | |
702 // assert(listener != null); | |
703 // listener = _applyFilter(filter, listener); | |
704 // _index.getRelationships(type, IndexConstants.IS_REFERENCED_BY, _newCallbac
k(MatchKind.TYPE_REFERENCE, scope, listener)); | |
705 // } | |
706 // | |
707 // void _searchReferences3(CompilationUnitElement unit, SearchScope scope, Sear
chFilter filter, SearchListener listener) { | |
708 // assert(listener != null); | |
709 // listener = _applyFilter(filter, listener); | |
710 // _index.getRelationships(unit, IndexConstants.IS_REFERENCED_BY, _newCallbac
k(MatchKind.UNIT_REFERENCE, scope, listener)); | |
711 // } | |
712 // | |
713 // void _searchReferences4(ConstructorElement constructor, SearchScope scope, S
earchFilter filter, SearchListener listener) { | |
714 // assert(listener != null); | |
715 // listener = _applyFilter(filter, listener); | |
716 // listener = new CountingSearchListener(2, listener); | |
717 // _index.getRelationships(constructor, IndexConstants.IS_DEFINED_BY, _newCal
lback(MatchKind.CONSTRUCTOR_DECLARATION, scope, listener)); | |
718 // _index.getRelationships(constructor, IndexConstants.IS_REFERENCED_BY, _new
Callback(MatchKind.CONSTRUCTOR_REFERENCE, scope, listener)); | |
719 // } | |
720 // | |
721 // void _searchReferences5(FunctionElement function, SearchScope scope, SearchF
ilter filter, SearchListener listener) { | |
722 // assert(listener != null); | |
723 // listener = _applyFilter(filter, listener); | |
724 // listener = new CountingSearchListener(2, listener); | |
725 // _index.getRelationships(function, IndexConstants.IS_REFERENCED_BY, _newCal
lback(MatchKind.FUNCTION_REFERENCE, scope, listener)); | |
726 // _index.getRelationships(function, IndexConstants.IS_INVOKED_BY, _newCallba
ck(MatchKind.FUNCTION_EXECUTION, scope, listener)); | |
727 // } | |
728 // | |
729 // void _searchReferences6(FunctionTypeAliasElement alias, SearchScope scope, S
earchFilter filter, SearchListener listener) { | |
730 // assert(listener != null); | |
731 // listener = _applyFilter(filter, listener); | |
732 // _index.getRelationships(alias, IndexConstants.IS_REFERENCED_BY, _newCallba
ck(MatchKind.FUNCTION_TYPE_REFERENCE, scope, listener)); | |
733 // } | |
734 // | |
735 // void _searchReferences7(ImportElement imp, SearchScope scope, SearchFilter f
ilter, SearchListener listener) { | |
736 // assert(listener != null); | |
737 // listener = _applyFilter(filter, listener); | |
738 // _index.getRelationships(imp, IndexConstants.IS_REFERENCED_BY, _newCallback
(MatchKind.IMPORT_REFERENCE, scope, listener)); | |
739 // } | |
740 // | |
741 // void _searchReferences8(LibraryElement library, SearchScope scope, SearchFil
ter filter, SearchListener listener) { | |
742 // assert(listener != null); | |
743 // listener = _applyFilter(filter, listener); | |
744 // _index.getRelationships(library, IndexConstants.IS_REFERENCED_BY, _newCall
back(MatchKind.LIBRARY_REFERENCE, scope, listener)); | |
745 // } | |
746 // | |
747 // void _searchReferences9(MethodElement method, SearchScope scope, SearchFilte
r filter, SearchListener listener) { | |
748 // assert(listener != null); | |
749 // listener = _applyFilter(filter, listener); | |
750 // // TODO(scheglov) use "5" when add named matches | |
751 // listener = new CountingSearchListener(4, listener); | |
752 // // exact matches | |
753 // _index.getRelationships(method, IndexConstants.IS_INVOKED_BY_UNQUALIFIED,
_newCallback(MatchKind.METHOD_INVOCATION, scope, listener)); | |
754 // _index.getRelationships(method, IndexConstants.IS_INVOKED_BY_QUALIFIED, _n
ewCallback(MatchKind.METHOD_INVOCATION, scope, listener)); | |
755 // _index.getRelationships(method, IndexConstants.IS_REFERENCED_BY_UNQUALIFIE
D, _newCallback(MatchKind.METHOD_REFERENCE, scope, listener)); | |
756 // _index.getRelationships(method, IndexConstants.IS_REFERENCED_BY_QUALIFIED,
_newCallback(MatchKind.METHOD_REFERENCE, scope, listener)); | |
757 // } | |
758 // | |
759 // void _searchReferences10(ParameterElement parameter, SearchScope scope, Sear
chFilter filter, SearchListener listener) { | |
760 // assert(listener != null); | |
761 // listener = _applyFilter(filter, listener); | |
762 // listener = new CountingSearchListener(5, listener); | |
763 // _index.getRelationships(parameter, IndexConstants.IS_READ_BY, _newCallback
(MatchKind.VARIABLE_READ, scope, listener)); | |
764 // _index.getRelationships(parameter, IndexConstants.IS_READ_WRITTEN_BY, _new
Callback(MatchKind.VARIABLE_READ_WRITE, scope, listener)); | |
765 // _index.getRelationships(parameter, IndexConstants.IS_WRITTEN_BY, _newCallb
ack(MatchKind.VARIABLE_WRITE, scope, listener)); | |
766 // _index.getRelationships(parameter, IndexConstants.IS_REFERENCED_BY, _newCa
llback(MatchKind.NAMED_PARAMETER_REFERENCE, scope, listener)); | |
767 // _index.getRelationships(parameter, IndexConstants.IS_INVOKED_BY, _newCallb
ack(MatchKind.FUNCTION_EXECUTION, scope, listener)); | |
768 // } | |
769 // | |
770 // void _searchReferences11(PropertyAccessorElement accessor, SearchScope scope
, SearchFilter filter, SearchListener listener) { | |
771 // assert(listener != null); | |
772 // listener = _applyFilter(filter, listener); | |
773 // listener = new CountingSearchListener(2, listener); | |
774 // _index.getRelationships(accessor, IndexConstants.IS_REFERENCED_BY_QUALIFIE
D, _newCallback(MatchKind.PROPERTY_ACCESSOR_REFERENCE, scope, listener)); | |
775 // _index.getRelationships(accessor, IndexConstants.IS_REFERENCED_BY_UNQUALIF
IED, _newCallback(MatchKind.PROPERTY_ACCESSOR_REFERENCE, scope, listener)); | |
776 // } | |
777 // | |
778 // void _searchReferences12(PropertyInducingElement field, SearchScope scope, S
earchFilter filter, SearchListener listener) { | |
779 // assert(listener != null); | |
780 // PropertyAccessorElement getter = field.getter; | |
781 // PropertyAccessorElement setter = field.setter; | |
782 // int numRequests = (getter != null ? 4 : 0) + (setter != null ? 2 : 0) + 2; | |
783 // listener = _applyFilter(filter, listener); | |
784 // listener = new CountingSearchListener(numRequests, listener); | |
785 // if (getter != null) { | |
786 // _index.getRelationships(getter, IndexConstants.IS_REFERENCED_BY_QUALIFIE
D, _newCallback(MatchKind.FIELD_READ, scope, listener)); | |
787 // _index.getRelationships(getter, IndexConstants.IS_REFERENCED_BY_UNQUALIF
IED, _newCallback(MatchKind.FIELD_READ, scope, listener)); | |
788 // _index.getRelationships(getter, IndexConstants.IS_INVOKED_BY_QUALIFIED,
_newCallback(MatchKind.FIELD_INVOCATION, scope, listener)); | |
789 // _index.getRelationships(getter, IndexConstants.IS_INVOKED_BY_UNQUALIFIED
, _newCallback(MatchKind.FIELD_INVOCATION, scope, listener)); | |
790 // } | |
791 // if (setter != null) { | |
792 // _index.getRelationships(setter, IndexConstants.IS_REFERENCED_BY_QUALIFIE
D, _newCallback(MatchKind.FIELD_WRITE, scope, listener)); | |
793 // _index.getRelationships(setter, IndexConstants.IS_REFERENCED_BY_UNQUALIF
IED, _newCallback(MatchKind.FIELD_WRITE, scope, listener)); | |
794 // } | |
795 // _index.getRelationships(field, IndexConstants.IS_REFERENCED_BY, _newCallba
ck(MatchKind.FIELD_REFERENCE, scope, listener)); | |
796 // _index.getRelationships(field, IndexConstants.IS_REFERENCED_BY_QUALIFIED,
_newCallback(MatchKind.FIELD_REFERENCE, scope, listener)); | |
797 // } | |
798 // | |
799 // void _searchReferences13(TypeParameterElement typeParameter, SearchScope sco
pe, SearchFilter filter, SearchListener listener) { | |
800 // assert(listener != null); | |
801 // listener = _applyFilter(filter, listener); | |
802 // _index.getRelationships(typeParameter, IndexConstants.IS_REFERENCED_BY, _n
ewCallback(MatchKind.TYPE_PARAMETER_REFERENCE, scope, listener)); | |
803 // } | |
804 // | |
805 // void _searchReferences14(VariableElement variable, SearchScope scope, Search
Filter filter, SearchListener listener) { | |
806 // assert(listener != null); | |
807 // listener = _applyFilter(filter, listener); | |
808 // listener = new CountingSearchListener(4, listener); | |
809 // _index.getRelationships(variable, IndexConstants.IS_READ_BY, _newCallback(
MatchKind.VARIABLE_READ, scope, listener)); | |
810 // _index.getRelationships(variable, IndexConstants.IS_READ_WRITTEN_BY, _newC
allback(MatchKind.VARIABLE_READ_WRITE, scope, listener)); | |
811 // _index.getRelationships(variable, IndexConstants.IS_WRITTEN_BY, _newCallba
ck(MatchKind.VARIABLE_WRITE, scope, listener)); | |
812 // _index.getRelationships(variable, IndexConstants.IS_INVOKED_BY, _newCallba
ck(MatchKind.FUNCTION_EXECUTION, scope, listener)); | |
813 // } | |
814 //} | |
815 // | |
816 ///** | |
817 // * Instances of the class <code>RelationshipCallbackImpl</code> implement a ca
llback that can be | |
818 // * used to report results to a search listener. | |
819 // */ | |
820 //class SearchEngineImpl_RelationshipCallbackImpl implements RelationshipCallbac
k { | |
821 // final SearchScope _scope; | |
822 // | |
823 // /** | |
824 // * The kind of matches that are represented by the results that will be prov
ided to this | |
825 // * callback. | |
826 // */ | |
827 // final MatchKind _matchKind; | |
828 // | |
829 // /** | |
830 // * The search listener that should be notified when results are found. | |
831 // */ | |
832 // final SearchListener _listener; | |
833 // | |
834 // /** | |
835 // * Initialize a newly created callback to report matches of the given kind t
o the given listener | |
836 // * when results are found. | |
837 // * | |
838 // * @param scope the [SearchScope] to return matches from, may be `null` to r
eturn | |
839 // * all matches | |
840 // * @param matchKind the kind of matches that are represented by the results | |
841 // * @param listener the search listener that should be notified when results
are found | |
842 // */ | |
843 // SearchEngineImpl_RelationshipCallbackImpl(this._scope, this._matchKind, this
._listener); | |
844 // | |
845 // @override | |
846 // void hasRelationships(Element element, Relationship relationship, List<Locat
ion> locations) { | |
847 // for (Location location in locations) { | |
848 // Element targetElement = location.element; | |
849 // // check scope | |
850 // if (_scope != null && !_scope.encloses(targetElement)) { | |
851 // continue; | |
852 // } | |
853 // SourceRange range = new SourceRange(location.offset, location.length); | |
854 // // TODO(scheglov) IndexConstants.DYNAMIC for MatchQuality.NAME | |
855 // MatchQuality quality = MatchQuality.EXACT; | |
856 // // MatchQuality quality = element.getResource() != IndexConstan
ts.DYNAMIC | |
857 // // ? MatchQuality.EXACT : MatchQuality.NAME; | |
858 // SearchMatch match = new SearchMatch(quality, _matchKind, targetElement,
range); | |
859 // match.qualified = identical(relationship, IndexConstants.IS_REFERENCED_B
Y_QUALIFIED) || identical(relationship, IndexConstants.IS_INVOKED_BY_QUALIFIED); | |
860 // _listener.matchFound(match); | |
861 // } | |
862 // _listener.searchComplete(); | |
863 // } | |
864 //} | |
865 // | |
866 ///** | |
867 // * The interface <code>SearchRunner</code> defines the behavior of objects tha
t can be used to | |
868 // * perform an asynchronous search. | |
869 // */ | |
870 //abstract class SearchEngineImpl_SearchRunner { | |
871 // /** | |
872 // * Perform an asynchronous search, passing the results to the given listener
. | |
873 // * | |
874 // * @param listener the listener to which search results should be passed @ i
f the results could | |
875 // * not be computed | |
876 // */ | |
877 // void performSearch(SearchListener listener); | |
878 //} | |
879 // | |
880 ///** | |
881 // * The interface <code>SearchListener</code> defines the behavior of objects t
hat are listening for | |
882 // * the results of a search. | |
883 // */ | |
884 //abstract class SearchListener { | |
885 // /** | |
886 // * Record the fact that the given match was found. | |
887 // * | |
888 // * @param match the match that was found | |
889 // */ | |
890 // void matchFound(SearchMatch match); | |
891 // | |
892 // /** | |
893 // * This method is invoked when the search is complete and no additional matc
hes will be found. | |
894 // */ | |
895 // void searchComplete(); | |
896 //} | |
897 | |
898 ///** | |
899 // * The class <code>SearchPatternFactory</code> defines utility methods that ca
n be used to create | |
900 // * search patterns. | |
901 // */ | |
902 //class SearchPatternFactory { | |
903 // /** | |
904 // * Create a pattern that will match any element that is matched by all of th
e given patterns. If | |
905 // * no patterns are given, then the resulting pattern will not match any elem
ents. | |
906 // * | |
907 // * @param patterns the patterns that must all be matched in order for the ne
w pattern to be | |
908 // * matched | |
909 // * @return the pattern that was created | |
910 // */ | |
911 // static SearchPattern createAndPattern(List<SearchPattern> patterns) { | |
912 // if (patterns.length == 1) { | |
913 // return patterns[0]; | |
914 // } | |
915 // return new AndSearchPattern(patterns); | |
916 // } | |
917 // | |
918 // /** | |
919 // * Create a pattern that will match any element whose name matches a partial
identifier where | |
920 // * camel case conventions are used to perform what is essentially multiple p
refix matches. | |
921 // * | |
922 // * @param pattern the pattern that matching elements must match | |
923 // * @param samePartCount `true` if the pattern and the name being matched mus
t have | |
924 // * exactly the same number of parts (i.e. the same number of upperc
ase characters) | |
925 // * @return the pattern that was created | |
926 // */ | |
927 // static SearchPattern createCamelCasePattern(String prefix, bool samePartCoun
t) => new CamelCaseSearchPattern(prefix, samePartCount); | |
928 // | |
929 // /** | |
930 // * Create a pattern that will match any element whose name matches a specifi
ed identifier exactly. | |
931 // * | |
932 // * @param identifier the identifier that matching elements must be equal to | |
933 // * @param caseSensitive `true` if a case sensitive match is to be performed | |
934 // * @return the pattern that was created | |
935 // */ | |
936 // static SearchPattern createExactPattern(String identifier, bool caseSensitiv
e) => new ExactSearchPattern(identifier, caseSensitive); | |
937 // | |
938 // /** | |
939 // * Create a pattern that will match any element that is matched by at least
one of the given | |
940 // * patterns. If no patterns are given, then the resulting pattern will not m
atch any elements. | |
941 // * | |
942 // * @param patterns the patterns used to determine whether the new pattern is
matched | |
943 // * @return the pattern that was created | |
944 // */ | |
945 // static SearchPattern createOrPattern(List<SearchPattern> patterns) { | |
946 // if (patterns.length == 1) { | |
947 // return patterns[0]; | |
948 // } | |
949 // return new OrSearchPattern(patterns); | |
950 // } | |
951 // | |
952 // /** | |
953 // * Create a pattern that will match any element whose name starts with the g
iven prefix. | |
954 // * | |
955 // * @param prefix the prefix of names that match the pattern | |
956 // * @param caseSensitive `true` if a case sensitive match is to be performed | |
957 // * @return the pattern that was created | |
958 // */ | |
959 // static SearchPattern createPrefixPattern(String prefix, bool caseSensitive)
=> new PrefixSearchPattern(prefix, caseSensitive); | |
960 // | |
961 // /** | |
962 // * Create a pattern that will match any element whose name matches a regular
expression. | |
963 // * | |
964 // * @param regularExpression the regular expression that matching elements mu
st match | |
965 // * @param caseSensitive `true` if a case sensitive match is to be performed | |
966 // * @return the pattern that was created | |
967 // */ | |
968 // static SearchPattern createRegularExpressionPattern(String regularExpression
, bool caseSensitive) => new RegularExpressionSearchPattern(regularExpression, c
aseSensitive); | |
969 // | |
970 // /** | |
971 // * Create a pattern that will match any element whose name matches a pattern
containing wildcard | |
972 // * characters. The wildcard characters that are currently supported are '?'
(to match any single | |
973 // * character) and '*' (to match zero or more characters). | |
974 // * | |
975 // * @param pattern the pattern that matching elements must match | |
976 // * @param caseSensitive `true` if a case sensitive match is to be performed | |
977 // * @return the pattern that was created | |
978 // */ | |
979 // static SearchPattern createWildcardPattern(String pattern, bool caseSensitiv
e) => new WildcardSearchPattern(pattern, caseSensitive); | |
980 //} | |
981 // | |
982 //class SearchRunner_SearchEngineImpl_searchDeclarations implements SearchEngine
Impl_SearchRunner { | |
983 // final SearchEngineImpl SearchEngineImpl_this; | |
984 // | |
985 // String name; | |
986 // | |
987 // SearchScope scope; | |
988 // | |
989 // SearchFilter filter; | |
990 // | |
991 // SearchRunner_SearchEngineImpl_searchDeclarations(this.SearchEngineImpl_this,
this.name, this.scope, this.filter); | |
992 // | |
993 // @override | |
994 // void performSearch(SearchListener listener) { | |
995 // SearchEngineImpl_this.searchDeclarations2(name, scope, filter, listener); | |
996 // } | |
997 //} | |
998 // | |
999 //class SearchRunner_SearchEngineImpl_searchFunctionDeclarations implements Sear
chEngineImpl_SearchRunner { | |
1000 // final SearchEngineImpl SearchEngineImpl_this; | |
1001 // | |
1002 // SearchScope scope; | |
1003 // | |
1004 // SearchPattern pattern; | |
1005 // | |
1006 // SearchFilter filter; | |
1007 // | |
1008 // SearchRunner_SearchEngineImpl_searchFunctionDeclarations(this.SearchEngineIm
pl_this, this.scope, this.pattern, this.filter); | |
1009 // | |
1010 // @override | |
1011 // void performSearch(SearchListener listener) { | |
1012 // SearchEngineImpl_this.searchFunctionDeclarations2(scope, pattern, filter,
listener); | |
1013 // } | |
1014 //} | |
1015 // | |
1016 //class SearchRunner_SearchEngineImpl_searchQualifiedMemberReferences implements
SearchEngineImpl_SearchRunner { | |
1017 // final SearchEngineImpl SearchEngineImpl_this; | |
1018 // | |
1019 // String name; | |
1020 // | |
1021 // SearchScope scope; | |
1022 // | |
1023 // SearchFilter filter; | |
1024 // | |
1025 // SearchRunner_SearchEngineImpl_searchQualifiedMemberReferences(this.SearchEng
ineImpl_this, this.name, this.scope, this.filter); | |
1026 // | |
1027 // @override | |
1028 // void performSearch(SearchListener listener) { | |
1029 // SearchEngineImpl_this.searchQualifiedMemberReferences2(name, scope, filter
, listener); | |
1030 // } | |
1031 //} | |
1032 // | |
1033 //class SearchRunner_SearchEngineImpl_searchReferences implements SearchEngineIm
pl_SearchRunner { | |
1034 // final SearchEngineImpl SearchEngineImpl_this; | |
1035 // | |
1036 // Element element; | |
1037 // | |
1038 // SearchScope scope; | |
1039 // | |
1040 // SearchFilter filter; | |
1041 // | |
1042 // SearchRunner_SearchEngineImpl_searchReferences(this.SearchEngineImpl_this, t
his.element, this.scope, this.filter); | |
1043 // | |
1044 // @override | |
1045 // void performSearch(SearchListener listener) { | |
1046 // SearchEngineImpl_this.searchReferences2(element, scope, filter, listener); | |
1047 // } | |
1048 //} | |
1049 // | |
1050 //class SearchRunner_SearchEngineImpl_searchSubtypes implements SearchEngineImpl
_SearchRunner { | |
1051 // final SearchEngineImpl SearchEngineImpl_this; | |
1052 // | |
1053 // ClassElement type; | |
1054 // | |
1055 // SearchScope scope; | |
1056 // | |
1057 // SearchFilter filter; | |
1058 // | |
1059 // SearchRunner_SearchEngineImpl_searchSubtypes(this.SearchEngineImpl_this, thi
s.type, this.scope, this.filter); | |
1060 // | |
1061 // @override | |
1062 // void performSearch(SearchListener listener) { | |
1063 // SearchEngineImpl_this.searchSubtypes2(type, scope, filter, listener); | |
1064 // } | |
1065 //} | |
1066 // | |
1067 //class SearchRunner_SearchEngineImpl_searchTypeDeclarations implements SearchEn
gineImpl_SearchRunner { | |
1068 // final SearchEngineImpl SearchEngineImpl_this; | |
1069 // | |
1070 // SearchScope scope; | |
1071 // | |
1072 // SearchPattern pattern; | |
1073 // | |
1074 // SearchFilter filter; | |
1075 // | |
1076 // SearchRunner_SearchEngineImpl_searchTypeDeclarations(this.SearchEngineImpl_t
his, this.scope, this.pattern, this.filter); | |
1077 // | |
1078 // @override | |
1079 // void performSearch(SearchListener listener) { | |
1080 // SearchEngineImpl_this.searchTypeDeclarations2(scope, pattern, filter, list
ener); | |
1081 // } | |
1082 //} | |
1083 // | |
1084 //class SearchRunner_SearchEngineImpl_searchVariableDeclarations implements Sear
chEngineImpl_SearchRunner { | |
1085 // final SearchEngineImpl SearchEngineImpl_this; | |
1086 // | |
1087 // SearchScope scope; | |
1088 // | |
1089 // SearchPattern pattern; | |
1090 // | |
1091 // SearchFilter filter; | |
1092 // | |
1093 // SearchRunner_SearchEngineImpl_searchVariableDeclarations(this.SearchEngineIm
pl_this, this.scope, this.pattern, this.filter); | |
1094 // | |
1095 // @override | |
1096 // void performSearch(SearchListener listener) { | |
1097 // SearchEngineImpl_this.searchVariableDeclarations2(scope, pattern, filter,
listener); | |
1098 // } | |
1099 //} | |
1100 // | |
1101 ///** | |
1102 // * The class <code>SearchScopeFactory</code> defines utility methods that can
be used to create | |
1103 // * search scopes. | |
1104 // */ | |
1105 //class SearchScopeFactory { | |
1106 // /** | |
1107 // * A search scope that encompasses everything in the "universe". Because it
does not hold any | |
1108 // * state there is no reason not to share a single instance. | |
1109 // */ | |
1110 // static SearchScope _UNIVERSE_SCOPE = new UniverseSearchScope(); | |
1111 // | |
1112 // /** | |
1113 // * Create a search scope that encompasses everything in the given library. | |
1114 // * | |
1115 // * @param library the library defining which elements are included in the sc
ope | |
1116 // * @return the search scope that was created | |
1117 // */ | |
1118 // static SearchScope createLibraryScope(Iterable<LibraryElement> libraries) =>
new LibrarySearchScope.con1(libraries); | |
1119 // | |
1120 // /** | |
1121 // * Create a search scope that encompasses everything in the given libraries. | |
1122 // * | |
1123 // * @param libraries the libraries defining which elements are included in th
e scope | |
1124 // * @return the search scope that was created | |
1125 // */ | |
1126 // static SearchScope createLibraryScope2(List<LibraryElement> libraries) => ne
w LibrarySearchScope.con2(libraries); | |
1127 // | |
1128 // /** | |
1129 // * Create a search scope that encompasses everything in the given library. | |
1130 // * | |
1131 // * @param library the library defining which elements are included in the sc
ope | |
1132 // * @return the search scope that was created | |
1133 // */ | |
1134 // static SearchScope createLibraryScope3(LibraryElement library) => new Librar
ySearchScope.con2([library]); | |
1135 // | |
1136 // /** | |
1137 // * Create a search scope that encompasses everything in the universe. | |
1138 // * | |
1139 // * @return the search scope that was created | |
1140 // */ | |
1141 // static SearchScope createUniverseScope() => _UNIVERSE_SCOPE; | |
1142 //} | |
1143 // | |
1144 ///** | |
1145 // * The [SearchScope] that encompasses everything in the universe. | |
1146 // */ | |
1147 //class UniverseSearchScope implements SearchScope { | |
1148 // @override | |
1149 // bool encloses(Element element) => true; | |
1150 //} | |
1151 // | |
1152 ///** | |
1153 // * Instances of the class <code>WildcardSearchPattern</code> implement a searc
h pattern that matches | |
1154 // * elements whose name matches a pattern with wildcard characters. The wildcar
d characters that are | |
1155 // * currently supported are '?' (to match any single character) and '*' (to mat
ch zero or more | |
1156 // * characters). | |
1157 // */ | |
1158 //class WildcardSearchPattern implements SearchPattern { | |
1159 // /** | |
1160 // * The pattern that matching elements must match. | |
1161 // */ | |
1162 // List<int> _pattern; | |
1163 // | |
1164 // /** | |
1165 // * A flag indicating whether a case sensitive match is to be performed. | |
1166 // */ | |
1167 // final bool _caseSensitive; | |
1168 // | |
1169 // /** | |
1170 // * Initialize a newly created search pattern to match elements whose names b
egin with the given | |
1171 // * prefix. | |
1172 // * | |
1173 // * @param pattern the pattern that matching elements must match | |
1174 // * @param caseSensitive `true` if a case sensitive match is to be performed | |
1175 // */ | |
1176 // WildcardSearchPattern(String pattern, this._caseSensitive) { | |
1177 // this._pattern = _caseSensitive ? pattern.toCharArray() : pattern.toLowerCa
se().toCharArray(); | |
1178 // } | |
1179 // | |
1180 // @override | |
1181 // MatchQuality matches(Element element) { | |
1182 // if (element == null) { | |
1183 // return null; | |
1184 // } | |
1185 // String name = element.displayName; | |
1186 // if (name == null) { | |
1187 // return null; | |
1188 // } | |
1189 // if (CharOperation.match(_pattern, name.toCharArray(), _caseSensitive)) { | |
1190 // return MatchQuality.EXACT; | |
1191 // } | |
1192 // return null; | |
1193 // } | |
1194 //} | |
1195 // | |
1196 ///** | |
1197 // * Instances of the class <code>ScopedSearchListener</code> implement a search
listener that | |
1198 // * delegates to another search listener after removing matches that are outsid
e a given scope. | |
1199 // */ | |
1200 //abstract class WrappedSearchListener implements SearchListener { | |
1201 // /** | |
1202 // * The listener being wrapped. | |
1203 // */ | |
1204 // SearchListener _baseListener; | |
1205 // | |
1206 // /** | |
1207 // * Initialize a newly created search listener to wrap the given listener. | |
1208 // * | |
1209 // * @param listener the search listener being wrapped | |
1210 // */ | |
1211 // WrappedSearchListener(SearchListener listener) { | |
1212 // _baseListener = listener; | |
1213 // } | |
1214 // | |
1215 // @override | |
1216 // void searchComplete() { | |
1217 // _baseListener.searchComplete(); | |
1218 // } | |
1219 // | |
1220 // /** | |
1221 // * Pass the given match on to the wrapped listener. | |
1222 // * | |
1223 // * @param match the match to be propagated | |
1224 // */ | |
1225 // void propagateMatch(SearchMatch match) { | |
1226 // _baseListener.matchFound(match); | |
1227 // } | |
1228 //} | |
OLD | NEW |