| 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 engine.index; | 8 library engine.index; |
| 9 | 9 |
| 10 import 'dart:collection' show Queue; | 10 import 'dart:collection' show Queue; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 IndexStore _indexStore; | 29 IndexStore _indexStore; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * The context in which source being removed. | 32 * The context in which source being removed. |
| 33 */ | 33 */ |
| 34 AnalysisContext _context; | 34 AnalysisContext _context; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * The source being removed. | 37 * The source being removed. |
| 38 */ | 38 */ |
| 39 final Source source; | 39 Source source; |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Initialize a newly created operation that will remove the specified resourc
e. | 42 * Initialize a newly created operation that will remove the specified resourc
e. |
| 43 * | 43 * |
| 44 * @param indexStore the index store against which this operation is being run | 44 * @param indexStore the index store against which this operation is being run |
| 45 * @param context the [AnalysisContext] to remove source in | 45 * @param context the [AnalysisContext] to remove source in |
| 46 * @param source the [Source] to remove from index | 46 * @param source the [Source] to remove from index |
| 47 */ | 47 */ |
| 48 RemoveSourceOperation(IndexStore indexStore, AnalysisContext context, this.sou
rce) { | 48 RemoveSourceOperation(IndexStore indexStore, AnalysisContext context, Source s
ource) { |
| 49 this._indexStore = indexStore; | 49 this._indexStore = indexStore; |
| 50 this._context = context; | 50 this._context = context; |
| 51 this.source = source; |
| 51 } | 52 } |
| 52 | 53 |
| 53 @override | 54 @override |
| 54 bool get isQuery => false; | 55 bool get isQuery => false; |
| 55 | 56 |
| 56 @override | 57 @override |
| 57 void performOperation() { | 58 void performOperation() { |
| 58 _indexStore.removeSource(_context, source); | 59 _indexStore.removeSource(_context, source); |
| 59 } | 60 } |
| 60 | 61 |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 IndexStore _indexStore; | 604 IndexStore _indexStore; |
| 604 | 605 |
| 605 /** | 606 /** |
| 606 * The context in which compilation unit was resolved. | 607 * The context in which compilation unit was resolved. |
| 607 */ | 608 */ |
| 608 AnalysisContext _context; | 609 AnalysisContext _context; |
| 609 | 610 |
| 610 /** | 611 /** |
| 611 * The compilation unit being indexed. | 612 * The compilation unit being indexed. |
| 612 */ | 613 */ |
| 613 final CompilationUnit unit; | 614 CompilationUnit unit; |
| 614 | 615 |
| 615 /** | 616 /** |
| 616 * The element of the compilation unit being indexed. | 617 * The element of the compilation unit being indexed. |
| 617 */ | 618 */ |
| 618 CompilationUnitElement _unitElement; | 619 CompilationUnitElement _unitElement; |
| 619 | 620 |
| 620 /** | 621 /** |
| 621 * The source being indexed. | 622 * The source being indexed. |
| 622 */ | 623 */ |
| 623 Source _source; | 624 Source _source; |
| 624 | 625 |
| 625 /** | 626 /** |
| 626 * Initialize a newly created operation that will index the specified unit. | 627 * Initialize a newly created operation that will index the specified unit. |
| 627 * | 628 * |
| 628 * @param indexStore the index store against which this operation is being run | 629 * @param indexStore the index store against which this operation is being run |
| 629 * @param context the context in which compilation unit was resolved | 630 * @param context the context in which compilation unit was resolved |
| 630 * @param unit the fully resolved AST structure | 631 * @param unit the fully resolved AST structure |
| 631 */ | 632 */ |
| 632 IndexUnitOperation(IndexStore indexStore, AnalysisContext context, this.unit)
{ | 633 IndexUnitOperation(IndexStore indexStore, AnalysisContext context, Compilation
Unit unit) { |
| 633 this._indexStore = indexStore; | 634 this._indexStore = indexStore; |
| 634 this._context = context; | 635 this._context = context; |
| 636 this.unit = unit; |
| 635 this._unitElement = unit.element; | 637 this._unitElement = unit.element; |
| 636 this._source = _unitElement.source; | 638 this._source = _unitElement.source; |
| 637 } | 639 } |
| 638 | 640 |
| 639 /** | 641 /** |
| 640 * @return the [Source] to be indexed. | 642 * @return the [Source] to be indexed. |
| 641 */ | 643 */ |
| 642 Source get source => _source; | 644 Source get source => _source; |
| 643 | 645 |
| 644 @override | 646 @override |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 IndexStore _indexStore; | 776 IndexStore _indexStore; |
| 775 | 777 |
| 776 /** | 778 /** |
| 777 * The context to remove container. | 779 * The context to remove container. |
| 778 */ | 780 */ |
| 779 AnalysisContext _context; | 781 AnalysisContext _context; |
| 780 | 782 |
| 781 /** | 783 /** |
| 782 * The source container to remove. | 784 * The source container to remove. |
| 783 */ | 785 */ |
| 784 final SourceContainer container; | 786 SourceContainer container; |
| 785 | 787 |
| 786 /** | 788 /** |
| 787 * Initialize a newly created operation that will remove the specified resourc
e. | 789 * Initialize a newly created operation that will remove the specified resourc
e. |
| 788 * | 790 * |
| 789 * @param indexStore the index store against which this operation is being run | 791 * @param indexStore the index store against which this operation is being run |
| 790 * @param context the [AnalysisContext] to remove container in | 792 * @param context the [AnalysisContext] to remove container in |
| 791 * @param container the [SourceContainer] to remove from index | 793 * @param container the [SourceContainer] to remove from index |
| 792 */ | 794 */ |
| 793 RemoveSourcesOperation(IndexStore indexStore, AnalysisContext context, this.co
ntainer) { | 795 RemoveSourcesOperation(IndexStore indexStore, AnalysisContext context, SourceC
ontainer container) { |
| 794 this._indexStore = indexStore; | 796 this._indexStore = indexStore; |
| 795 this._context = context; | 797 this._context = context; |
| 798 this.container = container; |
| 796 } | 799 } |
| 797 | 800 |
| 798 @override | 801 @override |
| 799 bool get isQuery => false; | 802 bool get isQuery => false; |
| 800 | 803 |
| 801 @override | 804 @override |
| 802 void performOperation() { | 805 void performOperation() { |
| 803 _indexStore.removeSources(_context, container); | 806 _indexStore.removeSources(_context, container); |
| 804 } | 807 } |
| 805 | 808 |
| (...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 */ | 2268 */ |
| 2266 class RemoveContextOperation implements IndexOperation { | 2269 class RemoveContextOperation implements IndexOperation { |
| 2267 /** | 2270 /** |
| 2268 * The index store against which this operation is being run. | 2271 * The index store against which this operation is being run. |
| 2269 */ | 2272 */ |
| 2270 IndexStore _indexStore; | 2273 IndexStore _indexStore; |
| 2271 | 2274 |
| 2272 /** | 2275 /** |
| 2273 * The context being removed. | 2276 * The context being removed. |
| 2274 */ | 2277 */ |
| 2275 final AnalysisContext context; | 2278 AnalysisContext context; |
| 2276 | 2279 |
| 2277 /** | 2280 /** |
| 2278 * Initialize a newly created operation that will remove the specified resourc
e. | 2281 * Initialize a newly created operation that will remove the specified resourc
e. |
| 2279 * | 2282 * |
| 2280 * @param indexStore the index store against which this operation is being run | 2283 * @param indexStore the index store against which this operation is being run |
| 2281 * @param context the [AnalysisContext] to remove | 2284 * @param context the [AnalysisContext] to remove |
| 2282 */ | 2285 */ |
| 2283 RemoveContextOperation(IndexStore indexStore, this.context) { | 2286 RemoveContextOperation(IndexStore indexStore, AnalysisContext context) { |
| 2284 this._indexStore = indexStore; | 2287 this._indexStore = indexStore; |
| 2288 this.context = context; |
| 2285 } | 2289 } |
| 2286 | 2290 |
| 2287 @override | 2291 @override |
| 2288 bool get isQuery => false; | 2292 bool get isQuery => false; |
| 2289 | 2293 |
| 2290 @override | 2294 @override |
| 2291 void performOperation() { | 2295 void performOperation() { |
| 2292 _indexStore.removeContext(context); | 2296 _indexStore.removeContext(context); |
| 2293 } | 2297 } |
| 2294 | 2298 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2310 IndexStore _indexStore; | 2314 IndexStore _indexStore; |
| 2311 | 2315 |
| 2312 /** | 2316 /** |
| 2313 * The context in which [HtmlUnit] was resolved. | 2317 * The context in which [HtmlUnit] was resolved. |
| 2314 */ | 2318 */ |
| 2315 AnalysisContext _context; | 2319 AnalysisContext _context; |
| 2316 | 2320 |
| 2317 /** | 2321 /** |
| 2318 * The [HtmlUnit] being indexed. | 2322 * The [HtmlUnit] being indexed. |
| 2319 */ | 2323 */ |
| 2320 final ht.HtmlUnit unit; | 2324 ht.HtmlUnit unit; |
| 2321 | 2325 |
| 2322 /** | 2326 /** |
| 2323 * The element of the [HtmlUnit] being indexed. | 2327 * The element of the [HtmlUnit] being indexed. |
| 2324 */ | 2328 */ |
| 2325 HtmlElement _htmlElement; | 2329 HtmlElement _htmlElement; |
| 2326 | 2330 |
| 2327 /** | 2331 /** |
| 2328 * The source being indexed. | 2332 * The source being indexed. |
| 2329 */ | 2333 */ |
| 2330 Source _source; | 2334 Source _source; |
| 2331 | 2335 |
| 2332 /** | 2336 /** |
| 2333 * Initialize a newly created operation that will index the specified [HtmlUni
t]. | 2337 * Initialize a newly created operation that will index the specified [HtmlUni
t]. |
| 2334 * | 2338 * |
| 2335 * @param indexStore the index store against which this operation is being run | 2339 * @param indexStore the index store against which this operation is being run |
| 2336 * @param context the context in which [HtmlUnit] was resolved | 2340 * @param context the context in which [HtmlUnit] was resolved |
| 2337 * @param unit the fully resolved [HtmlUnit] | 2341 * @param unit the fully resolved [HtmlUnit] |
| 2338 */ | 2342 */ |
| 2339 IndexHtmlUnitOperation(IndexStore indexStore, AnalysisContext context, this.un
it) { | 2343 IndexHtmlUnitOperation(IndexStore indexStore, AnalysisContext context, ht.Html
Unit unit) { |
| 2340 this._indexStore = indexStore; | 2344 this._indexStore = indexStore; |
| 2341 this._context = context; | 2345 this._context = context; |
| 2346 this.unit = unit; |
| 2342 this._htmlElement = unit.element; | 2347 this._htmlElement = unit.element; |
| 2343 this._source = _htmlElement.source; | 2348 this._source = _htmlElement.source; |
| 2344 } | 2349 } |
| 2345 | 2350 |
| 2346 /** | 2351 /** |
| 2347 * @return the [Source] to be indexed. | 2352 * @return the [Source] to be indexed. |
| 2348 */ | 2353 */ |
| 2349 Source get source => _source; | 2354 Source get source => _source; |
| 2350 | 2355 |
| 2351 @override | 2356 @override |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2379 */ | 2384 */ |
| 2380 class Location { | 2385 class Location { |
| 2381 /** | 2386 /** |
| 2382 * An empty array of locations. | 2387 * An empty array of locations. |
| 2383 */ | 2388 */ |
| 2384 static List<Location> EMPTY_ARRAY = new List<Location>(0); | 2389 static List<Location> EMPTY_ARRAY = new List<Location>(0); |
| 2385 | 2390 |
| 2386 /** | 2391 /** |
| 2387 * The element containing this location. | 2392 * The element containing this location. |
| 2388 */ | 2393 */ |
| 2389 final Element element; | 2394 Element element; |
| 2390 | 2395 |
| 2391 /** | 2396 /** |
| 2392 * The offset of this location within the resource containing the element. | 2397 * The offset of this location within the resource containing the element. |
| 2393 */ | 2398 */ |
| 2394 final int offset; | 2399 int offset = 0; |
| 2395 | 2400 |
| 2396 /** | 2401 /** |
| 2397 * The length of this location. | 2402 * The length of this location. |
| 2398 */ | 2403 */ |
| 2399 final int length; | 2404 int length = 0; |
| 2400 | 2405 |
| 2401 /** | 2406 /** |
| 2402 * Internal field used to hold a key that is referenced at this location. | 2407 * Internal field used to hold a key that is referenced at this location. |
| 2403 */ | 2408 */ |
| 2404 Object internalKey; | 2409 Object internalKey; |
| 2405 | 2410 |
| 2406 /** | 2411 /** |
| 2407 * Initialize a newly create location to be relative to the given element at t
he given offset with | 2412 * Initialize a newly create location to be relative to the given element at t
he given offset with |
| 2408 * the given length. | 2413 * the given length. |
| 2409 * | 2414 * |
| 2410 * @param element the [Element] containing this location | 2415 * @param element the [Element] containing this location |
| 2411 * @param offset the offset of this location within the resource containing th
e element | 2416 * @param offset the offset of this location within the resource containing th
e element |
| 2412 * @param length the length of this location | 2417 * @param length the length of this location |
| 2413 */ | 2418 */ |
| 2414 Location(this.element, this.offset, this.length) { | 2419 Location(Element element, int offset, int length) { |
| 2415 if (element == null) { | 2420 if (element == null) { |
| 2416 throw new IllegalArgumentException("element location cannot be null"); | 2421 throw new IllegalArgumentException("element location cannot be null"); |
| 2417 } | 2422 } |
| 2423 this.element = element; |
| 2424 this.offset = offset; |
| 2425 this.length = length; |
| 2418 } | 2426 } |
| 2419 | 2427 |
| 2420 /** | 2428 /** |
| 2421 * Returns a clone of this [Location]. | 2429 * Returns a clone of this [Location]. |
| 2422 */ | 2430 */ |
| 2423 Location newClone() => new Location(element, offset, length); | 2431 Location newClone() => new Location(element, offset, length); |
| 2424 | 2432 |
| 2425 @override | 2433 @override |
| 2426 String toString() => "[${offset} - ${(offset + length)}) in ${element}"; | 2434 String toString() => "[${offset} - ${(offset + length)}) in ${element}"; |
| 2427 } | 2435 } |
| 2428 | 2436 |
| 2429 /** | 2437 /** |
| 2430 * [IndexStore] which keeps all information in memory, but can write it to strea
m and read | 2438 * [IndexStore] which keeps all information in memory, but can write it to strea
m and read |
| 2431 * later. | 2439 * later. |
| 2432 */ | 2440 */ |
| 2433 abstract class MemoryIndexStore implements IndexStore { | 2441 abstract class MemoryIndexStore implements IndexStore { |
| 2434 } | 2442 } |
| 2435 | 2443 |
| 2436 /** | 2444 /** |
| 2437 * Instances of the [GetRelationshipsOperation] implement an operation used to a
ccess the | 2445 * Instances of the [GetRelationshipsOperation] implement an operation used to a
ccess the |
| 2438 * locations that have a specified relationship with a specified element. | 2446 * locations that have a specified relationship with a specified element. |
| 2439 */ | 2447 */ |
| 2440 class GetRelationshipsOperation implements IndexOperation { | 2448 class GetRelationshipsOperation implements IndexOperation { |
| 2441 IndexStore _indexStore; | 2449 IndexStore _indexStore; |
| 2442 | 2450 |
| 2443 final Element element; | 2451 Element element; |
| 2444 | 2452 |
| 2445 final Relationship relationship; | 2453 Relationship relationship; |
| 2446 | 2454 |
| 2447 final RelationshipCallback callback; | 2455 RelationshipCallback callback; |
| 2448 | 2456 |
| 2449 /** | 2457 /** |
| 2450 * Initialize a newly created operation that will access the locations that ha
ve a specified | 2458 * Initialize a newly created operation that will access the locations that ha
ve a specified |
| 2451 * relationship with a specified element. | 2459 * relationship with a specified element. |
| 2452 */ | 2460 */ |
| 2453 GetRelationshipsOperation(IndexStore indexStore, this.element, this.relationsh
ip, this.callback) { | 2461 GetRelationshipsOperation(IndexStore indexStore, Element element, Relationship
relationship, RelationshipCallback callback) { |
| 2454 this._indexStore = indexStore; | 2462 this._indexStore = indexStore; |
| 2463 this.element = element; |
| 2464 this.relationship = relationship; |
| 2465 this.callback = callback; |
| 2455 } | 2466 } |
| 2456 | 2467 |
| 2457 @override | 2468 @override |
| 2458 bool get isQuery => true; | 2469 bool get isQuery => true; |
| 2459 | 2470 |
| 2460 @override | 2471 @override |
| 2461 void performOperation() { | 2472 void performOperation() { |
| 2462 List<Location> locations; | 2473 List<Location> locations; |
| 2463 locations = _indexStore.getRelationships(element, relationship); | 2474 locations = _indexStore.getRelationships(element, relationship); |
| 2464 callback.hasRelationships(element, relationship, locations); | 2475 callback.hasRelationships(element, relationship, locations); |
| 2465 } | 2476 } |
| 2466 | 2477 |
| 2467 @override | 2478 @override |
| 2468 bool removeWhenSourceRemoved(Source source) => false; | 2479 bool removeWhenSourceRemoved(Source source) => false; |
| 2469 | 2480 |
| 2470 @override | 2481 @override |
| 2471 String toString() => "GetRelationships(${element}, ${relationship})"; | 2482 String toString() => "GetRelationships(${element}, ${relationship})"; |
| 2472 } | 2483 } |
| 2473 | 2484 |
| 2474 /** | 2485 /** |
| 2475 * [Location] with attached data. | 2486 * [Location] with attached data. |
| 2476 */ | 2487 */ |
| 2477 class LocationWithData<D> extends Location { | 2488 class LocationWithData<D> extends Location { |
| 2478 final D data; | 2489 D data; |
| 2479 | 2490 |
| 2480 LocationWithData.con1(Location location, this.data) : super(location.element,
location.offset, location.length); | 2491 LocationWithData.con1(Location location, D data) : super(location.element, loc
ation.offset, location.length) { |
| 2492 this.data = data; |
| 2493 } |
| 2481 | 2494 |
| 2482 LocationWithData.con2(Element element, int offset, int length, this.data) : su
per(element, offset, length); | 2495 LocationWithData.con2(Element element, int offset, int length, D data) : super
(element, offset, length) { |
| 2496 this.data = data; |
| 2497 } |
| 2483 | 2498 |
| 2484 @override | 2499 @override |
| 2485 Location newClone() => new LocationWithData<D>.con2(element, offset, length, d
ata); | 2500 Location newClone() => new LocationWithData<D>.con2(element, offset, length, d
ata); |
| 2486 } | 2501 } |
| 2487 | 2502 |
| 2488 /** | 2503 /** |
| 2489 * The interface <code>RelationshipCallback</code> defines the behavior of objec
ts that are invoked | 2504 * The interface <code>RelationshipCallback</code> defines the behavior of objec
ts that are invoked |
| 2490 * with the results of a query about a given relationship. | 2505 * with the results of a query about a given relationship. |
| 2491 */ | 2506 */ |
| 2492 abstract class RelationshipCallback { | 2507 abstract class RelationshipCallback { |
| 2493 /** | 2508 /** |
| 2494 * This method is invoked when the locations that have a specified relationshi
p with a specified | 2509 * This method is invoked when the locations that have a specified relationshi
p with a specified |
| 2495 * element are available. For example, if the element is a field and the relat
ionship is the | 2510 * element are available. For example, if the element is a field and the relat
ionship is the |
| 2496 * is-referenced-by relationship, then this method will be invoked with each l
ocation at which the | 2511 * is-referenced-by relationship, then this method will be invoked with each l
ocation at which the |
| 2497 * field is referenced. | 2512 * field is referenced. |
| 2498 * | 2513 * |
| 2499 * @param element the [Element] that has the relationship with the locations | 2514 * @param element the [Element] that has the relationship with the locations |
| 2500 * @param relationship the relationship between the given element and the loca
tions | 2515 * @param relationship the relationship between the given element and the loca
tions |
| 2501 * @param locations the locations that were found | 2516 * @param locations the locations that were found |
| 2502 */ | 2517 */ |
| 2503 void hasRelationships(Element element, Relationship relationship, List<Locatio
n> locations); | 2518 void hasRelationships(Element element, Relationship relationship, List<Locatio
n> locations); |
| 2504 } | 2519 } |
| OLD | NEW |