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

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

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