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

Side by Side Diff: pkg/analyzer/lib/src/generated/index.dart

Issue 214593008: Rollback pkg/analyzer that breaks code_transformers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // 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;
11 import 'java_core.dart'; 11 import 'java_core.dart';
12 import 'java_engine.dart'; 12 import 'java_engine.dart';
13 import 'source.dart'; 13 import 'source.dart';
14 import 'scanner.dart' show Token; 14 import 'scanner.dart' show Token;
15 import 'ast.dart'; 15 import 'ast.dart';
16 import 'element.dart'; 16 import 'element.dart';
17 import 'resolver.dart' show Namespace, NamespaceBuilder; 17 import 'resolver.dart' show Namespace, NamespaceBuilder;
18 import 'engine.dart'; 18 import 'engine.dart';
19 import 'html.dart' as ht; 19 import 'html.dart' as ht;
20 20
21 /** 21 /**
22 * Instances of the [RemoveSourceOperation] implement an operation that removes from the index 22 * Instances of the [RemoveSourceOperation] implement an operation that removes from the index
23 * any data based on the content of a specified source. 23 * any data based on the content of a specified source.
24 */ 24 */
25 class RemoveSourceOperation implements IndexOperation { 25 class RemoveSourceOperation implements IndexOperation {
26 /** 26 /**
27 * The index store against which this operation is being run. 27 * The index store against which this operation is being run.
28 */ 28 */
29 final 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 final 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(this._indexStore, this._context, this.source); 48 RemoveSourceOperation(IndexStore indexStore, AnalysisContext context, Source s ource) {
49 this._indexStore = indexStore;
50 this._context = context;
51 this.source = source;
52 }
49 53
50 @override 54 @override
51 bool get isQuery => false; 55 bool get isQuery => false;
52 56
53 @override 57 @override
54 void performOperation() { 58 void performOperation() {
55 _indexStore.removeSource(_context, source); 59 _indexStore.removeSource(_context, source);
56 } 60 }
57 61
58 @override 62 @override
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 _keyCount--; 529 _keyCount--;
526 } 530 }
527 } 531 }
528 } 532 }
529 } 533 }
530 } 534 }
531 } 535 }
532 } 536 }
533 537
534 class MemoryIndexStoreImpl_ElementRelationKey { 538 class MemoryIndexStoreImpl_ElementRelationKey {
535 final Element _element; 539 Element _element;
536 540
537 final Relationship _relationship; 541 Relationship _relationship;
538 542
539 MemoryIndexStoreImpl_ElementRelationKey(this._element, this._relationship); 543 MemoryIndexStoreImpl_ElementRelationKey(Element element, Relationship relation ship) {
544 this._element = element;
545 this._relationship = relationship;
546 }
540 547
541 @override 548 @override
542 bool operator ==(Object obj) { 549 bool operator ==(Object obj) {
543 MemoryIndexStoreImpl_ElementRelationKey other = obj as MemoryIndexStoreImpl_ ElementRelationKey; 550 MemoryIndexStoreImpl_ElementRelationKey other = obj as MemoryIndexStoreImpl_ ElementRelationKey;
544 Element otherElement = other._element; 551 Element otherElement = other._element;
545 return identical(other._relationship, _relationship) && otherElement.nameOff set == _element.nameOffset && identical(otherElement.kind, _element.kind) && oth erElement.displayName == _element.displayName && otherElement.source == _element .source; 552 return identical(other._relationship, _relationship) && otherElement.nameOff set == _element.nameOffset && identical(otherElement.kind, _element.kind) && oth erElement.displayName == _element.displayName && otherElement.source == _element .source;
546 } 553 }
547 554
548 @override 555 @override
549 int get hashCode => JavaArrays.makeHashCode([ 556 int get hashCode => JavaArrays.makeHashCode([
550 _element.source, 557 _element.source,
551 _element.nameOffset, 558 _element.nameOffset,
552 _element.kind, 559 _element.kind,
553 _element.displayName, 560 _element.displayName,
554 _relationship]); 561 _relationship]);
555 562
556 @override 563 @override
557 String toString() => "${_element} ${_relationship}"; 564 String toString() => "${_element} ${_relationship}";
558 } 565 }
559 566
560 class MemoryIndexStoreImpl_Source2 { 567 class MemoryIndexStoreImpl_Source2 {
561 final Source _librarySource; 568 Source _librarySource;
562 569
563 final Source _unitSource; 570 Source _unitSource;
564 571
565 MemoryIndexStoreImpl_Source2(this._librarySource, this._unitSource); 572 MemoryIndexStoreImpl_Source2(Source librarySource, Source unitSource) {
573 this._librarySource = librarySource;
574 this._unitSource = unitSource;
575 }
566 576
567 @override 577 @override
568 bool operator ==(Object obj) { 578 bool operator ==(Object obj) {
569 if (identical(obj, this)) { 579 if (identical(obj, this)) {
570 return true; 580 return true;
571 } 581 }
572 if (obj is! MemoryIndexStoreImpl_Source2) { 582 if (obj is! MemoryIndexStoreImpl_Source2) {
573 return false; 583 return false;
574 } 584 }
575 MemoryIndexStoreImpl_Source2 other = obj as MemoryIndexStoreImpl_Source2; 585 MemoryIndexStoreImpl_Source2 other = obj as MemoryIndexStoreImpl_Source2;
576 return other._librarySource == _librarySource && other._unitSource == _unitS ource; 586 return other._librarySource == _librarySource && other._unitSource == _unitS ource;
577 } 587 }
578 588
579 @override 589 @override
580 int get hashCode => JavaArrays.makeHashCode([_librarySource, _unitSource]); 590 int get hashCode => JavaArrays.makeHashCode([_librarySource, _unitSource]);
581 591
582 @override 592 @override
583 String toString() => "${_librarySource} ${_unitSource}"; 593 String toString() => "${_librarySource} ${_unitSource}";
584 } 594 }
585 595
586 /** 596 /**
587 * Instances of the [IndexUnitOperation] implement an operation that adds data t o the index 597 * Instances of the [IndexUnitOperation] implement an operation that adds data t o the index
588 * based on the resolved [CompilationUnit]. 598 * based on the resolved [CompilationUnit].
589 */ 599 */
590 class IndexUnitOperation implements IndexOperation { 600 class IndexUnitOperation implements IndexOperation {
591 /** 601 /**
592 * The index store against which this operation is being run. 602 * The index store against which this operation is being run.
593 */ 603 */
594 final IndexStore _indexStore; 604 IndexStore _indexStore;
595 605
596 /** 606 /**
597 * The context in which compilation unit was resolved. 607 * The context in which compilation unit was resolved.
598 */ 608 */
599 final AnalysisContext _context; 609 AnalysisContext _context;
600 610
601 /** 611 /**
602 * The compilation unit being indexed. 612 * The compilation unit being indexed.
603 */ 613 */
604 final CompilationUnit unit; 614 CompilationUnit unit;
605 615
606 /** 616 /**
607 * The element of the compilation unit being indexed. 617 * The element of the compilation unit being indexed.
608 */ 618 */
609 CompilationUnitElement _unitElement; 619 CompilationUnitElement _unitElement;
610 620
611 /** 621 /**
612 * The source being indexed. 622 * The source being indexed.
613 */ 623 */
614 Source _source; 624 Source _source;
615 625
616 /** 626 /**
617 * Initialize a newly created operation that will index the specified unit. 627 * Initialize a newly created operation that will index the specified unit.
618 * 628 *
619 * @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
620 * @param context the context in which compilation unit was resolved 630 * @param context the context in which compilation unit was resolved
621 * @param unit the fully resolved AST structure 631 * @param unit the fully resolved AST structure
622 */ 632 */
623 IndexUnitOperation(this._indexStore, this._context, this.unit) { 633 IndexUnitOperation(IndexStore indexStore, AnalysisContext context, Compilation Unit unit) {
634 this._indexStore = indexStore;
635 this._context = context;
636 this.unit = unit;
624 this._unitElement = unit.element; 637 this._unitElement = unit.element;
625 this._source = _unitElement.source; 638 this._source = _unitElement.source;
626 } 639 }
627 640
628 /** 641 /**
629 * @return the [Source] to be indexed. 642 * @return the [Source] to be indexed.
630 */ 643 */
631 Source get source => _source; 644 Source get source => _source;
632 645
633 @override 646 @override
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 } 711 }
699 712
700 /** 713 /**
701 * Relationship between an element and a location. Relationships are identified by a globally unique 714 * Relationship between an element and a location. Relationships are identified by a globally unique
702 * identifier. 715 * identifier.
703 */ 716 */
704 class Relationship { 717 class Relationship {
705 /** 718 /**
706 * The unique identifier for this relationship. 719 * The unique identifier for this relationship.
707 */ 720 */
708 final String _uniqueId; 721 String _uniqueId;
709 722
710 /** 723 /**
711 * A table mapping relationship identifiers to relationships. 724 * A table mapping relationship identifiers to relationships.
712 */ 725 */
713 static Map<String, Relationship> _RelationshipMap = {}; 726 static Map<String, Relationship> _RelationshipMap = {};
714 727
715 /** 728 /**
716 * Return the relationship with the given unique identifier. 729 * Return the relationship with the given unique identifier.
717 * 730 *
718 * @param uniqueId the unique identifier for the relationship 731 * @param uniqueId the unique identifier for the relationship
(...skipping 11 matching lines...) Expand all
730 /** 743 /**
731 * @return all registered [Relationship]s. 744 * @return all registered [Relationship]s.
732 */ 745 */
733 static Iterable<Relationship> values() => _RelationshipMap.values; 746 static Iterable<Relationship> values() => _RelationshipMap.values;
734 747
735 /** 748 /**
736 * Initialize a newly created relationship to have the given unique identifier . 749 * Initialize a newly created relationship to have the given unique identifier .
737 * 750 *
738 * @param uniqueId the unique identifier for this relationship 751 * @param uniqueId the unique identifier for this relationship
739 */ 752 */
740 Relationship(this._uniqueId); 753 Relationship(String uniqueId) {
754 this._uniqueId = uniqueId;
755 }
741 756
742 /** 757 /**
743 * Return the unique identifier for this relationship. 758 * Return the unique identifier for this relationship.
744 * 759 *
745 * @return the unique identifier for this relationship 760 * @return the unique identifier for this relationship
746 */ 761 */
747 String get identifier => _uniqueId; 762 String get identifier => _uniqueId;
748 763
749 @override 764 @override
750 String toString() => _uniqueId; 765 String toString() => _uniqueId;
751 } 766 }
752 767
753 /** 768 /**
754 * Instances of the [RemoveSourcesOperation] implement an operation that removes from the 769 * Instances of the [RemoveSourcesOperation] implement an operation that removes from the
755 * index any data based on the content of source belonging to a [SourceContainer ]. 770 * index any data based on the content of source belonging to a [SourceContainer ].
756 */ 771 */
757 class RemoveSourcesOperation implements IndexOperation { 772 class RemoveSourcesOperation implements IndexOperation {
758 /** 773 /**
759 * The index store against which this operation is being run. 774 * The index store against which this operation is being run.
760 */ 775 */
761 final IndexStore _indexStore; 776 IndexStore _indexStore;
762 777
763 /** 778 /**
764 * The context to remove container. 779 * The context to remove container.
765 */ 780 */
766 final AnalysisContext _context; 781 AnalysisContext _context;
767 782
768 /** 783 /**
769 * The source container to remove. 784 * The source container to remove.
770 */ 785 */
771 final SourceContainer container; 786 SourceContainer container;
772 787
773 /** 788 /**
774 * 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.
775 * 790 *
776 * @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
777 * @param context the [AnalysisContext] to remove container in 792 * @param context the [AnalysisContext] to remove container in
778 * @param container the [SourceContainer] to remove from index 793 * @param container the [SourceContainer] to remove from index
779 */ 794 */
780 RemoveSourcesOperation(this._indexStore, this._context, this.container); 795 RemoveSourcesOperation(IndexStore indexStore, AnalysisContext context, SourceC ontainer container) {
796 this._indexStore = indexStore;
797 this._context = context;
798 this.container = container;
799 }
781 800
782 @override 801 @override
783 bool get isQuery => false; 802 bool get isQuery => false;
784 803
785 @override 804 @override
786 void performOperation() { 805 void performOperation() {
787 _indexStore.removeSources(_context, container); 806 _indexStore.removeSources(_context, container);
788 } 807 }
789 808
790 @override 809 @override
(...skipping 12 matching lines...) Expand all
803 } 822 }
804 823
805 /** 824 /**
806 * The enumeration <code>ProcessorState</code> represents the possible states of an operation 825 * The enumeration <code>ProcessorState</code> represents the possible states of an operation
807 * processor. 826 * processor.
808 */ 827 */
809 class ProcessorState extends Enum<ProcessorState> { 828 class ProcessorState extends Enum<ProcessorState> {
810 /** 829 /**
811 * The processor is ready to be run (has not been run before). 830 * The processor is ready to be run (has not been run before).
812 */ 831 */
813 static const ProcessorState READY = const ProcessorState('READY', 0); 832 static final ProcessorState READY = new ProcessorState('READY', 0);
814 833
815 /** 834 /**
816 * The processor is currently performing operations. 835 * The processor is currently performing operations.
817 */ 836 */
818 static const ProcessorState RUNNING = const ProcessorState('RUNNING', 1); 837 static final ProcessorState RUNNING = new ProcessorState('RUNNING', 1);
819 838
820 /** 839 /**
821 * The processor is currently performing operations but has been asked to stop . 840 * The processor is currently performing operations but has been asked to stop .
822 */ 841 */
823 static const ProcessorState STOP_REQESTED = const ProcessorState('STOP_REQESTE D', 2); 842 static final ProcessorState STOP_REQESTED = new ProcessorState('STOP_REQESTED' , 2);
824 843
825 /** 844 /**
826 * The processor has stopped performing operations and cannot be used again. 845 * The processor has stopped performing operations and cannot be used again.
827 */ 846 */
828 static const ProcessorState STOPPED = const ProcessorState('STOPPED', 3); 847 static final ProcessorState STOPPED = new ProcessorState('STOPPED', 3);
829 848
830 static const List<ProcessorState> values = const [READY, RUNNING, STOP_REQESTE D, STOPPED]; 849 static final List<ProcessorState> values = [READY, RUNNING, STOP_REQESTED, STO PPED];
831 850
832 const ProcessorState(String name, int ordinal) : super(name, ordinal); 851 ProcessorState(String name, int ordinal) : super(name, ordinal);
833 } 852 }
834 853
835 /** 854 /**
836 * Constants used when populating and accessing the index. 855 * Constants used when populating and accessing the index.
837 */ 856 */
838 abstract class IndexConstants { 857 abstract class IndexConstants {
839 /** 858 /**
840 * An element used to represent the universe. 859 * An element used to represent the universe.
841 */ 860 */
842 static final Element UNIVERSE = UniverseElement.INSTANCE; 861 static final Element UNIVERSE = UniverseElement.INSTANCE;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 static final Relationship ANGULAR_CLOSING_TAG_REFERENCE = Relationship.getRela tionship("angular-closing-tag-reference"); 996 static final Relationship ANGULAR_CLOSING_TAG_REFERENCE = Relationship.getRela tionship("angular-closing-tag-reference");
978 } 997 }
979 998
980 /** 999 /**
981 * Visits resolved [HtmlUnit] and adds relationships into [IndexStore]. 1000 * Visits resolved [HtmlUnit] and adds relationships into [IndexStore].
982 */ 1001 */
983 class AngularHtmlIndexContributor extends ExpressionVisitor { 1002 class AngularHtmlIndexContributor extends ExpressionVisitor {
984 /** 1003 /**
985 * The [IndexStore] to record relations into. 1004 * The [IndexStore] to record relations into.
986 */ 1005 */
987 final IndexStore _store; 1006 IndexStore _store;
988 1007
989 /** 1008 /**
990 * The index contributor used to index Dart [Expression]s. 1009 * The index contributor used to index Dart [Expression]s.
991 */ 1010 */
992 IndexContributor _indexContributor; 1011 IndexContributor _indexContributor;
993 1012
994 HtmlElement _htmlUnitElement; 1013 HtmlElement _htmlUnitElement;
995 1014
996 /** 1015 /**
997 * Initialize a newly created Angular HTML index contributor. 1016 * Initialize a newly created Angular HTML index contributor.
998 * 1017 *
999 * @param store the [IndexStore] to record relations into. 1018 * @param store the [IndexStore] to record relations into.
1000 */ 1019 */
1001 AngularHtmlIndexContributor(this._store) { 1020 AngularHtmlIndexContributor(IndexStore store) {
1002 _indexContributor = new IndexContributor_AngularHtmlIndexContributor(_store, this); 1021 this._store = store;
1022 _indexContributor = new IndexContributor_AngularHtmlIndexContributor(store, this);
1003 } 1023 }
1004 1024
1005 @override 1025 @override
1006 void visitExpression(Expression expression) { 1026 void visitExpression(Expression expression) {
1007 // NgFilter 1027 // NgFilter
1008 if (expression is SimpleIdentifier) { 1028 if (expression is SimpleIdentifier) {
1009 SimpleIdentifier identifier = expression; 1029 SimpleIdentifier identifier = expression;
1010 Element element = identifier.bestElement; 1030 Element element = identifier.bestElement;
1011 if (element is AngularElement) { 1031 if (element is AngularElement) {
1012 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, _cr eateLocationForIdentifier(identifier)); 1032 _store.recordRelationship(element, IndexConstants.ANGULAR_REFERENCE, _cr eateLocationForIdentifier(identifier));
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 if (parent is PropertyAccess) { 1561 if (parent is PropertyAccess) {
1542 return identical(parent.propertyName, node); 1562 return identical(parent.propertyName, node);
1543 } 1563 }
1544 if (parent is MethodInvocation) { 1564 if (parent is MethodInvocation) {
1545 MethodInvocation invocation = parent; 1565 MethodInvocation invocation = parent;
1546 return invocation.realTarget != null && identical(invocation.methodName, n ode); 1566 return invocation.realTarget != null && identical(invocation.methodName, n ode);
1547 } 1567 }
1548 return false; 1568 return false;
1549 } 1569 }
1550 1570
1551 final IndexStore _store; 1571 IndexStore _store;
1552 1572
1553 LibraryElement _libraryElement; 1573 LibraryElement _libraryElement;
1554 1574
1555 Map<ImportElement, Set<Element>> _importElementsMap = {}; 1575 Map<ImportElement, Set<Element>> _importElementsMap = {};
1556 1576
1557 /** 1577 /**
1558 * A stack whose top element (the element with the largest index) is an elemen t representing the 1578 * A stack whose top element (the element with the largest index) is an elemen t representing the
1559 * inner-most enclosing scope. 1579 * inner-most enclosing scope.
1560 */ 1580 */
1561 Queue<Element> _elementStack = new Queue(); 1581 Queue<Element> _elementStack = new Queue();
1562 1582
1563 IndexContributor(this._store); 1583 IndexContributor(IndexStore store) {
1584 this._store = store;
1585 }
1564 1586
1565 /** 1587 /**
1566 * Enter a new scope represented by the given [Element]. 1588 * Enter a new scope represented by the given [Element].
1567 */ 1589 */
1568 void enterScope(Element element) { 1590 void enterScope(Element element) {
1569 _elementStack.addFirst(element); 1591 _elementStack.addFirst(element);
1570 } 1592 }
1571 1593
1572 /** 1594 /**
1573 * @return the inner-most enclosing [Element], may be `null`. 1595 * @return the inner-most enclosing [Element], may be `null`.
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 2187
2166 @override 2188 @override
2167 ElementKind get kind => ElementKind.NAME; 2189 ElementKind get kind => ElementKind.NAME;
2168 } 2190 }
2169 2191
2170 /** 2192 /**
2171 * Visits resolved [CompilationUnit] and adds Angular specific relationships int o 2193 * Visits resolved [CompilationUnit] and adds Angular specific relationships int o
2172 * [IndexStore]. 2194 * [IndexStore].
2173 */ 2195 */
2174 class AngularDartIndexContributor extends GeneralizingAstVisitor<Object> { 2196 class AngularDartIndexContributor extends GeneralizingAstVisitor<Object> {
2175 final IndexStore _store; 2197 IndexStore _store;
2176 2198
2177 AngularDartIndexContributor(this._store); 2199 AngularDartIndexContributor(IndexStore store) {
2200 this._store = store;
2201 }
2178 2202
2179 @override 2203 @override
2180 Object visitClassDeclaration(ClassDeclaration node) { 2204 Object visitClassDeclaration(ClassDeclaration node) {
2181 ClassElement classElement = node.element; 2205 ClassElement classElement = node.element;
2182 if (classElement != null) { 2206 if (classElement != null) {
2183 List<ToolkitObjectElement> toolkitObjects = classElement.toolkitObjects; 2207 List<ToolkitObjectElement> toolkitObjects = classElement.toolkitObjects;
2184 for (ToolkitObjectElement object in toolkitObjects) { 2208 for (ToolkitObjectElement object in toolkitObjects) {
2185 if (object is AngularComponentElement) { 2209 if (object is AngularComponentElement) {
2186 _indexComponent(object); 2210 _indexComponent(object);
2187 } 2211 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 } 2263 }
2240 2264
2241 /** 2265 /**
2242 * Instances of the [RemoveContextOperation] implement an operation that removes from the 2266 * Instances of the [RemoveContextOperation] implement an operation that removes from the
2243 * index any data based on the specified [AnalysisContext]. 2267 * index any data based on the specified [AnalysisContext].
2244 */ 2268 */
2245 class RemoveContextOperation implements IndexOperation { 2269 class RemoveContextOperation implements IndexOperation {
2246 /** 2270 /**
2247 * The index store against which this operation is being run. 2271 * The index store against which this operation is being run.
2248 */ 2272 */
2249 final IndexStore _indexStore; 2273 IndexStore _indexStore;
2250 2274
2251 /** 2275 /**
2252 * The context being removed. 2276 * The context being removed.
2253 */ 2277 */
2254 final AnalysisContext context; 2278 AnalysisContext context;
2255 2279
2256 /** 2280 /**
2257 * 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.
2258 * 2282 *
2259 * @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
2260 * @param context the [AnalysisContext] to remove 2284 * @param context the [AnalysisContext] to remove
2261 */ 2285 */
2262 RemoveContextOperation(this._indexStore, this.context); 2286 RemoveContextOperation(IndexStore indexStore, AnalysisContext context) {
2287 this._indexStore = indexStore;
2288 this.context = context;
2289 }
2263 2290
2264 @override 2291 @override
2265 bool get isQuery => false; 2292 bool get isQuery => false;
2266 2293
2267 @override 2294 @override
2268 void performOperation() { 2295 void performOperation() {
2269 _indexStore.removeContext(context); 2296 _indexStore.removeContext(context);
2270 } 2297 }
2271 2298
2272 @override 2299 @override
2273 bool removeWhenSourceRemoved(Source source) => false; 2300 bool removeWhenSourceRemoved(Source source) => false;
2274 2301
2275 @override 2302 @override
2276 String toString() => "RemoveContext(${context})"; 2303 String toString() => "RemoveContext(${context})";
2277 } 2304 }
2278 2305
2279 /** 2306 /**
2280 * Instances of the [IndexHtmlUnitOperation] implement an operation that adds da ta to the 2307 * Instances of the [IndexHtmlUnitOperation] implement an operation that adds da ta to the
2281 * index based on the resolved [HtmlUnit]. 2308 * index based on the resolved [HtmlUnit].
2282 */ 2309 */
2283 class IndexHtmlUnitOperation implements IndexOperation { 2310 class IndexHtmlUnitOperation implements IndexOperation {
2284 /** 2311 /**
2285 * The index store against which this operation is being run. 2312 * The index store against which this operation is being run.
2286 */ 2313 */
2287 final IndexStore _indexStore; 2314 IndexStore _indexStore;
2288 2315
2289 /** 2316 /**
2290 * The context in which [HtmlUnit] was resolved. 2317 * The context in which [HtmlUnit] was resolved.
2291 */ 2318 */
2292 final AnalysisContext _context; 2319 AnalysisContext _context;
2293 2320
2294 /** 2321 /**
2295 * The [HtmlUnit] being indexed. 2322 * The [HtmlUnit] being indexed.
2296 */ 2323 */
2297 final ht.HtmlUnit unit; 2324 ht.HtmlUnit unit;
2298 2325
2299 /** 2326 /**
2300 * The element of the [HtmlUnit] being indexed. 2327 * The element of the [HtmlUnit] being indexed.
2301 */ 2328 */
2302 HtmlElement _htmlElement; 2329 HtmlElement _htmlElement;
2303 2330
2304 /** 2331 /**
2305 * The source being indexed. 2332 * The source being indexed.
2306 */ 2333 */
2307 Source _source; 2334 Source _source;
2308 2335
2309 /** 2336 /**
2310 * 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].
2311 * 2338 *
2312 * @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
2313 * @param context the context in which [HtmlUnit] was resolved 2340 * @param context the context in which [HtmlUnit] was resolved
2314 * @param unit the fully resolved [HtmlUnit] 2341 * @param unit the fully resolved [HtmlUnit]
2315 */ 2342 */
2316 IndexHtmlUnitOperation(this._indexStore, this._context, this.unit) { 2343 IndexHtmlUnitOperation(IndexStore indexStore, AnalysisContext context, ht.Html Unit unit) {
2344 this._indexStore = indexStore;
2345 this._context = context;
2346 this.unit = unit;
2317 this._htmlElement = unit.element; 2347 this._htmlElement = unit.element;
2318 this._source = _htmlElement.source; 2348 this._source = _htmlElement.source;
2319 } 2349 }
2320 2350
2321 /** 2351 /**
2322 * @return the [Source] to be indexed. 2352 * @return the [Source] to be indexed.
2323 */ 2353 */
2324 Source get source => _source; 2354 Source get source => _source;
2325 2355
2326 @override 2356 @override
(...skipping 27 matching lines...) Expand all
2354 */ 2384 */
2355 class Location { 2385 class Location {
2356 /** 2386 /**
2357 * An empty array of locations. 2387 * An empty array of locations.
2358 */ 2388 */
2359 static List<Location> EMPTY_ARRAY = new List<Location>(0); 2389 static List<Location> EMPTY_ARRAY = new List<Location>(0);
2360 2390
2361 /** 2391 /**
2362 * The element containing this location. 2392 * The element containing this location.
2363 */ 2393 */
2364 final Element element; 2394 Element element;
2365 2395
2366 /** 2396 /**
2367 * The offset of this location within the resource containing the element. 2397 * The offset of this location within the resource containing the element.
2368 */ 2398 */
2369 final int offset; 2399 int offset = 0;
2370 2400
2371 /** 2401 /**
2372 * The length of this location. 2402 * The length of this location.
2373 */ 2403 */
2374 final int length; 2404 int length = 0;
2375 2405
2376 /** 2406 /**
2377 * 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.
2378 */ 2408 */
2379 Object internalKey; 2409 Object internalKey;
2380 2410
2381 /** 2411 /**
2382 * 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
2383 * the given length. 2413 * the given length.
2384 * 2414 *
2385 * @param element the [Element] containing this location 2415 * @param element the [Element] containing this location
2386 * @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
2387 * @param length the length of this location 2417 * @param length the length of this location
2388 */ 2418 */
2389 Location(this.element, this.offset, this.length) { 2419 Location(Element element, int offset, int length) {
2390 if (element == null) { 2420 if (element == null) {
2391 throw new IllegalArgumentException("element location cannot be null"); 2421 throw new IllegalArgumentException("element location cannot be null");
2392 } 2422 }
2423 this.element = element;
2424 this.offset = offset;
2425 this.length = length;
2393 } 2426 }
2394 2427
2395 /** 2428 /**
2396 * Returns a clone of this [Location]. 2429 * Returns a clone of this [Location].
2397 */ 2430 */
2398 Location newClone() => new Location(element, offset, length); 2431 Location newClone() => new Location(element, offset, length);
2399 2432
2400 @override 2433 @override
2401 String toString() => "[${offset} - ${(offset + length)}) in ${element}"; 2434 String toString() => "[${offset} - ${(offset + length)}) in ${element}";
2402 } 2435 }
2403 2436
2404 /** 2437 /**
2405 * [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
2406 * later. 2439 * later.
2407 */ 2440 */
2408 abstract class MemoryIndexStore implements IndexStore { 2441 abstract class MemoryIndexStore implements IndexStore {
2409 } 2442 }
2410 2443
2411 /** 2444 /**
2412 * 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
2413 * locations that have a specified relationship with a specified element. 2446 * locations that have a specified relationship with a specified element.
2414 */ 2447 */
2415 class GetRelationshipsOperation implements IndexOperation { 2448 class GetRelationshipsOperation implements IndexOperation {
2416 final IndexStore _indexStore; 2449 IndexStore _indexStore;
2417 2450
2418 final Element element; 2451 Element element;
2419 2452
2420 final Relationship relationship; 2453 Relationship relationship;
2421 2454
2422 final RelationshipCallback callback; 2455 RelationshipCallback callback;
2423 2456
2424 /** 2457 /**
2425 * 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
2426 * relationship with a specified element. 2459 * relationship with a specified element.
2427 */ 2460 */
2428 GetRelationshipsOperation(this._indexStore, this.element, this.relationship, t his.callback); 2461 GetRelationshipsOperation(IndexStore indexStore, Element element, Relationship relationship, RelationshipCallback callback) {
2462 this._indexStore = indexStore;
2463 this.element = element;
2464 this.relationship = relationship;
2465 this.callback = callback;
2466 }
2429 2467
2430 @override 2468 @override
2431 bool get isQuery => true; 2469 bool get isQuery => true;
2432 2470
2433 @override 2471 @override
2434 void performOperation() { 2472 void performOperation() {
2435 List<Location> locations; 2473 List<Location> locations;
2436 locations = _indexStore.getRelationships(element, relationship); 2474 locations = _indexStore.getRelationships(element, relationship);
2437 callback.hasRelationships(element, relationship, locations); 2475 callback.hasRelationships(element, relationship, locations);
2438 } 2476 }
2439 2477
2440 @override 2478 @override
2441 bool removeWhenSourceRemoved(Source source) => false; 2479 bool removeWhenSourceRemoved(Source source) => false;
2442 2480
2443 @override 2481 @override
2444 String toString() => "GetRelationships(${element}, ${relationship})"; 2482 String toString() => "GetRelationships(${element}, ${relationship})";
2445 } 2483 }
2446 2484
2447 /** 2485 /**
2448 * [Location] with attached data. 2486 * [Location] with attached data.
2449 */ 2487 */
2450 class LocationWithData<D> extends Location { 2488 class LocationWithData<D> extends Location {
2451 final D data; 2489 D data;
2452 2490
2453 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 }
2454 2494
2455 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 }
2456 2498
2457 @override 2499 @override
2458 Location newClone() => new LocationWithData<D>.con2(element, offset, length, d ata); 2500 Location newClone() => new LocationWithData<D>.con2(element, offset, length, d ata);
2459 } 2501 }
2460 2502
2461 /** 2503 /**
2462 * 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
2463 * with the results of a query about a given relationship. 2505 * with the results of a query about a given relationship.
2464 */ 2506 */
2465 abstract class RelationshipCallback { 2507 abstract class RelationshipCallback {
2466 /** 2508 /**
2467 * 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
2468 * 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
2469 * 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
2470 * field is referenced. 2512 * field is referenced.
2471 * 2513 *
2472 * @param element the [Element] that has the relationship with the locations 2514 * @param element the [Element] that has the relationship with the locations
2473 * @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
2474 * @param locations the locations that were found 2516 * @param locations the locations that were found
2475 */ 2517 */
2476 void hasRelationships(Element element, Relationship relationship, List<Locatio n> locations); 2518 void hasRelationships(Element element, Relationship relationship, List<Locatio n> locations);
2477 } 2519 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/html.dart ('k') | pkg/analyzer/lib/src/generated/instrumentation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698