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