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

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

Issue 68233003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3
3 library engine; 4 library engine;
5
4 import 'java_core.dart'; 6 import 'java_core.dart';
5 import 'java_engine.dart'; 7 import 'java_engine.dart';
6 import 'utilities_collection.dart'; 8 import 'utilities_collection.dart';
7 import 'utilities_general.dart'; 9 import 'utilities_general.dart';
8 import 'instrumentation.dart'; 10 import 'instrumentation.dart';
9 import 'error.dart'; 11 import 'error.dart';
10 import 'source.dart'; 12 import 'source.dart';
11 import 'scanner.dart' show Token, Scanner, CharSequenceReader; 13 import 'scanner.dart' show Token, Scanner, CharSequenceReader;
12 import 'ast.dart'; 14 import 'ast.dart';
13 import 'parser.dart' show Parser; 15 import 'parser.dart' show Parser;
14 import 'sdk.dart' show DartSdk; 16 import 'sdk.dart' show DartSdk;
15 import 'element.dart'; 17 import 'element.dart';
16 import 'resolver.dart'; 18 import 'resolver.dart';
17 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit; 19 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit;
20
18 /** 21 /**
19 * The unique instance of the class `AnalysisEngine` serves as the entry point f or the 22 * The unique instance of the class `AnalysisEngine` serves as the entry point f or the
20 * functionality provided by the analysis engine. 23 * functionality provided by the analysis engine.
21 * 24 *
22 * @coverage dart.engine 25 * @coverage dart.engine
23 */ 26 */
24 class AnalysisEngine { 27 class AnalysisEngine {
25
26 /** 28 /**
27 * The suffix used for Dart source files. 29 * The suffix used for Dart source files.
28 */ 30 */
29 static String SUFFIX_DART = "dart"; 31 static String SUFFIX_DART = "dart";
30 32
31 /** 33 /**
32 * The short suffix used for HTML files. 34 * The short suffix used for HTML files.
33 */ 35 */
34 static String SUFFIX_HTM = "htm"; 36 static String SUFFIX_HTM = "htm";
35 37
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 * Set the logger that should receive information about errors within the anal ysis engine to the 100 * Set the logger that should receive information about errors within the anal ysis engine to the
99 * given logger. 101 * given logger.
100 * 102 *
101 * @param logger the logger that should receive information about errors withi n the analysis 103 * @param logger the logger that should receive information about errors withi n the analysis
102 * engine 104 * engine
103 */ 105 */
104 void set logger(Logger logger) { 106 void set logger(Logger logger) {
105 this._logger = logger == null ? Logger.NULL : logger; 107 this._logger = logger == null ? Logger.NULL : logger;
106 } 108 }
107 } 109 }
110
108 /** 111 /**
109 * Container with statistics about the [AnalysisContext]. 112 * Container with statistics about the [AnalysisContext].
110 */ 113 */
111 abstract class AnalysisContentStatistics { 114 abstract class AnalysisContentStatistics {
112
113 /** 115 /**
114 * Return the exceptions that caused some entries to have a state of [CacheSta te#ERROR]. 116 * Return the exceptions that caused some entries to have a state of [CacheSta te#ERROR].
115 * 117 *
116 * @return the exceptions that caused some entries to have a state of [CacheSt ate#ERROR] 118 * @return the exceptions that caused some entries to have a state of [CacheSt ate#ERROR]
117 */ 119 */
118 List<AnalysisException> get exceptions; 120 List<AnalysisException> get exceptions;
119 121
120 /** 122 /**
121 * Return the statistics for each kind of cached data. 123 * Return the statistics for each kind of cached data.
122 * 124 *
123 * @return the statistics for each kind of cached data 125 * @return the statistics for each kind of cached data
124 */ 126 */
125 List<AnalysisContentStatistics_CacheRow> get cacheRows; 127 List<AnalysisContentStatistics_CacheRow> get cacheRows;
126 } 128 }
129
127 /** 130 /**
128 * Information about single item in the cache. 131 * Information about single item in the cache.
129 */ 132 */
130 abstract class AnalysisContentStatistics_CacheRow { 133 abstract class AnalysisContentStatistics_CacheRow {
131 int get errorCount; 134 int get errorCount;
135
132 int get flushedCount; 136 int get flushedCount;
137
133 int get inProcessCount; 138 int get inProcessCount;
139
134 int get invalidCount; 140 int get invalidCount;
141
135 String get name; 142 String get name;
143
136 int get validCount; 144 int get validCount;
137 } 145 }
146
138 /** 147 /**
139 * The interface `AnalysisContext` defines the behavior of objects that represen t a context in 148 * The interface `AnalysisContext` defines the behavior of objects that represen t a context in
140 * which a single analysis can be performed and incrementally maintained. The co ntext includes such 149 * which a single analysis can be performed and incrementally maintained. The co ntext includes such
141 * information as the version of the SDK being analyzed against as well as the p ackage-root used to 150 * information as the version of the SDK being analyzed against as well as the p ackage-root used to
142 * resolve 'package:' URI's. (Both of which are known indirectly through the [So urceFactory 151 * resolve 'package:' URI's. (Both of which are known indirectly through the [So urceFactory
143 ].) 152 ].)
144 * 153 *
145 * An analysis context also represents the state of the analysis, which includes knowing which 154 * An analysis context also represents the state of the analysis, which includes knowing which
146 * sources have been included in the analysis (either directly or indirectly) an d the results of the 155 * sources have been included in the analysis (either directly or indirectly) an d the results of the
147 * analysis. Sources must be added and removed from the context using the method 156 * analysis. Sources must be added and removed from the context using the method
(...skipping 15 matching lines...) Expand all
163 * up-to-date. For such clients there is a mechanism that allows them to increme ntally perform 172 * up-to-date. For such clients there is a mechanism that allows them to increme ntally perform
164 * needed analysis and get notified of the consequent changes to the analysis re sults. This 173 * needed analysis and get notified of the consequent changes to the analysis re sults. This
165 * mechanism is realized by the method [performAnalysisTask]. 174 * mechanism is realized by the method [performAnalysisTask].
166 * 175 *
167 * Analysis engine allows for having more than one context. This can be used, fo r example, to 176 * Analysis engine allows for having more than one context. This can be used, fo r example, to
168 * perform one analysis based on the state of files on disk and a separate analy sis based on the 177 * perform one analysis based on the state of files on disk and a separate analy sis based on the
169 * state of those files in open editors. It can also be used to perform an analy sis based on a 178 * state of those files in open editors. It can also be used to perform an analy sis based on a
170 * proposed future state, such as the state after a refactoring. 179 * proposed future state, such as the state after a refactoring.
171 */ 180 */
172 abstract class AnalysisContext { 181 abstract class AnalysisContext {
173
174 /** 182 /**
175 * Apply the changes specified by the given change set to this context. Any an alysis results that 183 * Apply the changes specified by the given change set to this context. Any an alysis results that
176 * have been invalidated by these changes will be removed. 184 * have been invalidated by these changes will be removed.
177 * 185 *
178 * @param changeSet a description of the changes that are to be applied 186 * @param changeSet a description of the changes that are to be applied
179 */ 187 */
180 void applyChanges(ChangeSet changeSet); 188 void applyChanges(ChangeSet changeSet);
181 189
182 /** 190 /**
183 * Return the documentation comment for the given element as it appears in the original source 191 * Return the documentation comment for the given element as it appears in the original source
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 621
614 /** 622 /**
615 * Given a collection of sources with content that has changed, return an [Ite rable] 623 * Given a collection of sources with content that has changed, return an [Ite rable]
616 * identifying the sources that need to be resolved. 624 * identifying the sources that need to be resolved.
617 * 625 *
618 * @param changedSources an array of sources (not `null`, contains no `null`s) 626 * @param changedSources an array of sources (not `null`, contains no `null`s)
619 * @return An iterable returning the sources to be resolved 627 * @return An iterable returning the sources to be resolved
620 */ 628 */
621 Iterable<Source> sourcesToResolve(List<Source> changedSources); 629 Iterable<Source> sourcesToResolve(List<Source> changedSources);
622 } 630 }
631
623 /** 632 /**
624 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor mation for the 633 * The interface `AnalysisErrorInfo` contains the analysis errors and line infor mation for the
625 * errors. 634 * errors.
626 */ 635 */
627 abstract class AnalysisErrorInfo { 636 abstract class AnalysisErrorInfo {
628
629 /** 637 /**
630 * Return the errors that as a result of the analysis, or `null` if there were no errors. 638 * Return the errors that as a result of the analysis, or `null` if there were no errors.
631 * 639 *
632 * @return the errors as a result of the analysis 640 * @return the errors as a result of the analysis
633 */ 641 */
634 List<AnalysisError> get errors; 642 List<AnalysisError> get errors;
635 643
636 /** 644 /**
637 * Return the line information associated with the errors, or `null` if there were no 645 * Return the line information associated with the errors, or `null` if there were no
638 * errors. 646 * errors.
639 * 647 *
640 * @return the line information associated with the errors 648 * @return the line information associated with the errors
641 */ 649 */
642 LineInfo get lineInfo; 650 LineInfo get lineInfo;
643 } 651 }
652
644 /** 653 /**
645 * Instances of the class `AnalysisException` represent an exception that occurr ed during the 654 * Instances of the class `AnalysisException` represent an exception that occurr ed during the
646 * analysis of one or more sources. 655 * analysis of one or more sources.
647 * 656 *
648 * @coverage dart.engine 657 * @coverage dart.engine
649 */ 658 */
650 class AnalysisException extends JavaException { 659 class AnalysisException extends JavaException {
651
652 /** 660 /**
653 * Initialize a newly created exception. 661 * Initialize a newly created exception.
654 */ 662 */
655 AnalysisException() : super(); 663 AnalysisException() : super();
656 664
657 /** 665 /**
658 * Initialize a newly created exception to have the given message. 666 * Initialize a newly created exception to have the given message.
659 * 667 *
660 * @param message the message associated with the exception 668 * @param message the message associated with the exception
661 */ 669 */
662 AnalysisException.con1(String message) : super(message); 670 AnalysisException.con1(String message) : super(message);
663 671
664 /** 672 /**
665 * Initialize a newly created exception to have the given message and cause. 673 * Initialize a newly created exception to have the given message and cause.
666 * 674 *
667 * @param message the message associated with the exception 675 * @param message the message associated with the exception
668 * @param cause the underlying exception that caused this exception 676 * @param cause the underlying exception that caused this exception
669 */ 677 */
670 AnalysisException.con2(String message, Exception cause) : super(message, cause ); 678 AnalysisException.con2(String message, Exception cause) : super(message, cause );
671 679
672 /** 680 /**
673 * Initialize a newly created exception to have the given cause. 681 * Initialize a newly created exception to have the given cause.
674 * 682 *
675 * @param cause the underlying exception that caused this exception 683 * @param cause the underlying exception that caused this exception
676 */ 684 */
677 AnalysisException.con3(Exception cause) : super.withCause(cause); 685 AnalysisException.con3(Exception cause) : super.withCause(cause);
678 } 686 }
687
679 /** 688 /**
680 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a 689 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a
681 * set of analysis options used to control the behavior of an analysis context. 690 * set of analysis options used to control the behavior of an analysis context.
682 */ 691 */
683 abstract class AnalysisOptions { 692 abstract class AnalysisOptions {
684
685 /** 693 /**
686 * Return the maximum number of sources for which AST structures should be kep t in the cache. 694 * Return the maximum number of sources for which AST structures should be kep t in the cache.
687 * 695 *
688 * @return the maximum number of sources for which AST structures should be ke pt in the cache 696 * @return the maximum number of sources for which AST structures should be ke pt in the cache
689 */ 697 */
690 int get cacheSize; 698 int get cacheSize;
691 699
692 /** 700 /**
693 * Return `true` if analysis is to generate dart2js related hint results. 701 * Return `true` if analysis is to generate dart2js related hint results.
694 * 702 *
(...skipping 10 matching lines...) Expand all
705 bool get hint; 713 bool get hint;
706 714
707 /** 715 /**
708 * Return `true` if analysis is to use strict mode. In strict mode, error repo rting is based 716 * Return `true` if analysis is to use strict mode. In strict mode, error repo rting is based
709 * exclusively on the static type information. 717 * exclusively on the static type information.
710 * 718 *
711 * @return `true` if analysis is to use strict mode 719 * @return `true` if analysis is to use strict mode
712 */ 720 */
713 bool get strictMode; 721 bool get strictMode;
714 } 722 }
723
715 /** 724 /**
716 * Instances of the class `AnalysisResult` 725 * Instances of the class `AnalysisResult`
717 */ 726 */
718 class AnalysisResult { 727 class AnalysisResult {
719
720 /** 728 /**
721 * The change notices associated with this result, or `null` if there were no changes and 729 * The change notices associated with this result, or `null` if there were no changes and
722 * there is no more work to be done. 730 * there is no more work to be done.
723 */ 731 */
724 List<ChangeNotice> changeNotices; 732 List<ChangeNotice> changeNotices;
725 733
726 /** 734 /**
727 * The number of milliseconds required to determine which task was to be perfo rmed. 735 * The number of milliseconds required to determine which task was to be perfo rmed.
728 */ 736 */
729 int getTime = 0; 737 int getTime = 0;
(...skipping 16 matching lines...) Expand all
746 * @param taskClassName the name of the class of the task that was performed 754 * @param taskClassName the name of the class of the task that was performed
747 * @param performTime the number of milliseconds required to perform the task 755 * @param performTime the number of milliseconds required to perform the task
748 */ 756 */
749 AnalysisResult(List<ChangeNotice> notices, int getTime, String taskClassName, int performTime) { 757 AnalysisResult(List<ChangeNotice> notices, int getTime, String taskClassName, int performTime) {
750 this.changeNotices = notices; 758 this.changeNotices = notices;
751 this.getTime = getTime; 759 this.getTime = getTime;
752 this.taskClassName = taskClassName; 760 this.taskClassName = taskClassName;
753 this.performTime = performTime; 761 this.performTime = performTime;
754 } 762 }
755 } 763 }
764
756 /** 765 /**
757 * The interface `ChangeNotice` defines the behavior of objects that represent a change to the 766 * The interface `ChangeNotice` defines the behavior of objects that represent a change to the
758 * analysis results associated with a given source. 767 * analysis results associated with a given source.
759 * 768 *
760 * @coverage dart.engine 769 * @coverage dart.engine
761 */ 770 */
762 abstract class ChangeNotice implements AnalysisErrorInfo { 771 abstract class ChangeNotice implements AnalysisErrorInfo {
763
764 /** 772 /**
765 * Return the fully resolved AST that changed as a result of the analysis, or `null` if the 773 * Return the fully resolved AST that changed as a result of the analysis, or `null` if the
766 * AST was not changed. 774 * AST was not changed.
767 * 775 *
768 * @return the fully resolved AST that changed as a result of the analysis 776 * @return the fully resolved AST that changed as a result of the analysis
769 */ 777 */
770 CompilationUnit get compilationUnit; 778 CompilationUnit get compilationUnit;
771 779
772 /** 780 /**
773 * Return the source for which the result is being reported. 781 * Return the source for which the result is being reported.
774 * 782 *
775 * @return the source for which the result is being reported 783 * @return the source for which the result is being reported
776 */ 784 */
777 Source get source; 785 Source get source;
778 } 786 }
787
779 /** 788 /**
780 * Instances of the class `ChangeSet` indicate what sources have been added, cha nged, or 789 * Instances of the class `ChangeSet` indicate what sources have been added, cha nged, or
781 * removed. 790 * removed.
782 * 791 *
783 * @coverage dart.engine 792 * @coverage dart.engine
784 */ 793 */
785 class ChangeSet { 794 class ChangeSet {
786
787 /** 795 /**
788 * A list containing the sources that have been added. 796 * A list containing the sources that have been added.
789 */ 797 */
790 final List<Source> added3 = new List<Source>(); 798 final List<Source> added3 = new List<Source>();
791 799
792 /** 800 /**
793 * A list containing the sources that have been changed. 801 * A list containing the sources that have been changed.
794 */ 802 */
795 final List<Source> changed3 = new List<Source>(); 803 final List<Source> changed3 = new List<Source>();
796 804
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 /** 853 /**
846 * Record that the specified source container has been removed. 854 * Record that the specified source container has been removed.
847 * 855 *
848 * @param container the source container that was removed 856 * @param container the source container that was removed
849 */ 857 */
850 void removedContainer(SourceContainer container) { 858 void removedContainer(SourceContainer container) {
851 if (container != null) { 859 if (container != null) {
852 removedContainers.add(container); 860 removedContainers.add(container);
853 } 861 }
854 } 862 }
863
855 String toString() { 864 String toString() {
856 JavaStringBuilder builder = new JavaStringBuilder(); 865 JavaStringBuilder builder = new JavaStringBuilder();
857 bool needsSeparator = appendSources(builder, added3, false, "added"); 866 bool needsSeparator = appendSources(builder, added3, false, "added");
858 needsSeparator = appendSources(builder, changed3, needsSeparator, "changed") ; 867 needsSeparator = appendSources(builder, changed3, needsSeparator, "changed") ;
859 appendSources(builder, removed3, needsSeparator, "removed"); 868 appendSources(builder, removed3, needsSeparator, "removed");
860 int count = removedContainers.length; 869 int count = removedContainers.length;
861 if (count > 0) { 870 if (count > 0) {
862 if (removed3.isEmpty) { 871 if (removed3.isEmpty) {
863 if (needsSeparator) { 872 if (needsSeparator) {
864 builder.append("; "); 873 builder.append("; ");
(...skipping 30 matching lines...) Expand all
895 builder.append(label); 904 builder.append(label);
896 String prefix = " "; 905 String prefix = " ";
897 for (Source source in sources) { 906 for (Source source in sources) {
898 builder.append(prefix); 907 builder.append(prefix);
899 builder.append(source.fullName); 908 builder.append(source.fullName);
900 prefix = ", "; 909 prefix = ", ";
901 } 910 }
902 return true; 911 return true;
903 } 912 }
904 } 913 }
914
905 /** 915 /**
906 * Instances of the class `AnalysisCache` implement an LRU cache of information related to 916 * Instances of the class `AnalysisCache` implement an LRU cache of information related to
907 * analysis. 917 * analysis.
908 */ 918 */
909 class AnalysisCache { 919 class AnalysisCache {
910
911 /** 920 /**
912 * A table mapping the sources known to the context to the information known a bout the source. 921 * A table mapping the sources known to the context to the information known a bout the source.
913 */ 922 */
914 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); 923 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>();
915 924
916 /** 925 /**
917 * The maximum number of sources for which AST structures should be kept in th e cache. 926 * The maximum number of sources for which AST structures should be kept in th e cache.
918 */ 927 */
919 int _maxCacheSize = 0; 928 int _maxCacheSize = 0;
920 929
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 * 1033 *
1025 * @return `true` if a structure was flushed 1034 * @return `true` if a structure was flushed
1026 */ 1035 */
1027 bool flushAstFromCache() { 1036 bool flushAstFromCache() {
1028 Source removedSource = removeAstToFlush(); 1037 Source removedSource = removeAstToFlush();
1029 if (removedSource == null) { 1038 if (removedSource == null) {
1030 return false; 1039 return false;
1031 } 1040 }
1032 SourceEntry sourceEntry = _sourceMap[removedSource]; 1041 SourceEntry sourceEntry = _sourceMap[removedSource];
1033 if (sourceEntry is HtmlEntry) { 1042 if (sourceEntry is HtmlEntry) {
1034 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 1043 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
1035 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); 1044 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
1036 _sourceMap[removedSource] = htmlCopy; 1045 _sourceMap[removedSource] = htmlCopy;
1037 } else if (sourceEntry is DartEntry) { 1046 } else if (sourceEntry is DartEntry) {
1038 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 1047 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
1039 dartCopy.flushAstStructures(); 1048 dartCopy.flushAstStructures();
1040 _sourceMap[removedSource] = dartCopy; 1049 _sourceMap[removedSource] = dartCopy;
1041 } 1050 }
1042 return true; 1051 return true;
1043 } 1052 }
1044 1053
1045 /** 1054 /**
1046 * Remove and return one source from the list of recently used sources whose A ST structure can be 1055 * Remove and return one source from the list of recently used sources whose A ST structure can be
1047 * flushed from the cache. The source that will be returned will be the source that has been 1056 * flushed from the cache. The source that will be returned will be the source that has been
1048 * unreferenced for the longest period of time but that is not a priority for analysis. 1057 * unreferenced for the longest period of time but that is not a priority for analysis.
(...skipping 11 matching lines...) Expand all
1060 sourceToRemove = i; 1069 sourceToRemove = i;
1061 } 1070 }
1062 } 1071 }
1063 if (sourceToRemove < 0) { 1072 if (sourceToRemove < 0) {
1064 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush data from the cache", new JavaException()); 1073 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush data from the cache", new JavaException());
1065 return null; 1074 return null;
1066 } 1075 }
1067 return _recentlyUsed.removeAt(sourceToRemove); 1076 return _recentlyUsed.removeAt(sourceToRemove);
1068 } 1077 }
1069 } 1078 }
1079
1070 /** 1080 /**
1071 * Instances of the class `CacheRetentionPolicy` define the behavior of objects that determine 1081 * Instances of the class `CacheRetentionPolicy` define the behavior of objects that determine
1072 * how important it is for data to be retained in the analysis cache. 1082 * how important it is for data to be retained in the analysis cache.
1073 */ 1083 */
1074 abstract class CacheRetentionPolicy { 1084 abstract class CacheRetentionPolicy {
1075
1076 /** 1085 /**
1077 * Return the priority of retaining the AST structure for the given source. 1086 * Return the priority of retaining the AST structure for the given source.
1078 * 1087 *
1079 * @param source the source whose AST structure is being considered for remova l 1088 * @param source the source whose AST structure is being considered for remova l
1080 * @param sourceEntry the entry representing the source 1089 * @param sourceEntry the entry representing the source
1081 * @return the priority of retaining the AST structure for the given source 1090 * @return the priority of retaining the AST structure for the given source
1082 */ 1091 */
1083 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry); 1092 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry);
1084 } 1093 }
1094
1085 /** 1095 /**
1086 * The enumeration `CacheState` defines the possible states of cached data. 1096 * The enumeration `CacheState` defines the possible states of cached data.
1087 */ 1097 */
1088 class CacheState extends Enum<CacheState> { 1098 class CacheState extends Enum<CacheState> {
1089
1090 /** 1099 /**
1091 * The data is not in the cache and the last time an attempt was made to compu te the data an 1100 * The data is not in the cache and the last time an attempt was made to compu te the data an
1092 * exception occurred, making it pointless to attempt. 1101 * exception occurred, making it pointless to attempt.
1093 * 1102 *
1094 * Valid Transitions: 1103 * Valid Transitions:
1095 * 1104 *
1096 * * [INVALID] if a source was modified that might cause the data to be comput able 1105 * * [INVALID] if a source was modified that might cause the data to be comput able
1097 * 1106 *
1098 */ 1107 */
1099 static final CacheState ERROR = new CacheState('ERROR', 0); 1108 static final CacheState ERROR = new CacheState('ERROR', 0);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 /** 1143 /**
1135 * The data is in the cache and up-to-date. 1144 * The data is in the cache and up-to-date.
1136 * 1145 *
1137 * Valid Transitions: 1146 * Valid Transitions:
1138 * 1147 *
1139 * * [FLUSHED] if the data is removed in order to manage memory usage 1148 * * [FLUSHED] if the data is removed in order to manage memory usage
1140 * * [INVALID] if a source was modified in such a way as to invalidate the pre vious data 1149 * * [INVALID] if a source was modified in such a way as to invalidate the pre vious data
1141 * 1150 *
1142 */ 1151 */
1143 static final CacheState VALID = new CacheState('VALID', 4); 1152 static final CacheState VALID = new CacheState('VALID', 4);
1153
1144 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V ALID]; 1154 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V ALID];
1155
1145 CacheState(String name, int ordinal) : super(name, ordinal); 1156 CacheState(String name, int ordinal) : super(name, ordinal);
1146 } 1157 }
1158
1147 /** 1159 /**
1148 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation 1160 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation
1149 * cached by an analysis context about an individual Dart file. 1161 * cached by an analysis context about an individual Dart file.
1150 * 1162 *
1151 * @coverage dart.engine 1163 * @coverage dart.engine
1152 */ 1164 */
1153 abstract class DartEntry implements SourceEntry { 1165 abstract class DartEntry implements SourceEntry {
1154
1155 /** 1166 /**
1156 * The data descriptor representing the library element for the library. This data is only 1167 * The data descriptor representing the library element for the library. This data is only
1157 * available for Dart files that are the defining compilation unit of a librar y. 1168 * available for Dart files that are the defining compilation unit of a librar y.
1158 */ 1169 */
1159 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT"); 1170 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT");
1160 1171
1161 /** 1172 /**
1162 * The data descriptor representing the list of exported libraries. This data is only available 1173 * The data descriptor representing the list of exported libraries. This data is only available
1163 * for Dart files that are the defining compilation unit of a library. 1174 * for Dart files that are the defining compilation unit of a library.
1164 */ 1175 */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 /** 1278 /**
1268 * Return the value of the data represented by the given descriptor in the con text of the given 1279 * Return the value of the data represented by the given descriptor in the con text of the given
1269 * library, or `null` if the data represented by the descriptor is not in the cache. 1280 * library, or `null` if the data represented by the descriptor is not in the cache.
1270 * 1281 *
1271 * @param descriptor the descriptor representing which data is to be returned 1282 * @param descriptor the descriptor representing which data is to be returned
1272 * @param librarySource the source of the defining compilation unit of the lib rary that is the 1283 * @param librarySource the source of the defining compilation unit of the lib rary that is the
1273 * context for the data 1284 * context for the data
1274 * @return the value of the data represented by the given descriptor and libra ry 1285 * @return the value of the data represented by the given descriptor and libra ry
1275 */ 1286 */
1276 Object getValue2(DataDescriptor descriptor, Source librarySource); 1287 Object getValue2(DataDescriptor descriptor, Source librarySource);
1288
1277 DartEntryImpl get writableCopy; 1289 DartEntryImpl get writableCopy;
1278 1290
1279 /** 1291 /**
1280 * Return `true` if the data represented by the given descriptor is marked as being invalid. 1292 * Return `true` if the data represented by the given descriptor is marked as being invalid.
1281 * If the descriptor represents library-specific data then this method will re turn `true` if 1293 * If the descriptor represents library-specific data then this method will re turn `true` if
1282 * the data associated with any library it marked as invalid. 1294 * the data associated with any library it marked as invalid.
1283 * 1295 *
1284 * @param descriptor the descriptor representing which data is being tested 1296 * @param descriptor the descriptor representing which data is being tested
1285 * @return `true` if the data is marked as being invalid 1297 * @return `true` if the data is marked as being invalid
1286 */ 1298 */
1287 bool hasInvalidData(DataDescriptor descriptor); 1299 bool hasInvalidData(DataDescriptor descriptor);
1288 1300
1289 /** 1301 /**
1290 * Return `true` if this data is safe to use in refactoring. 1302 * Return `true` if this data is safe to use in refactoring.
1291 */ 1303 */
1292 bool get isRefactoringSafe; 1304 bool get isRefactoringSafe;
1293 } 1305 }
1306
1294 /** 1307 /**
1295 * Instances of the class `DartEntryImpl` implement a [DartEntry]. 1308 * Instances of the class `DartEntryImpl` implement a [DartEntry].
1296 * 1309 *
1297 * @coverage dart.engine 1310 * @coverage dart.engine
1298 */ 1311 */
1299 class DartEntryImpl extends SourceEntryImpl implements DartEntry { 1312 class DartEntryImpl extends SourceEntryImpl implements DartEntry {
1300
1301 /** 1313 /**
1302 * The state of the cached source kind. 1314 * The state of the cached source kind.
1303 */ 1315 */
1304 CacheState _sourceKindState = CacheState.INVALID; 1316 CacheState _sourceKindState = CacheState.INVALID;
1305 1317
1306 /** 1318 /**
1307 * The kind of this source. 1319 * The kind of this source.
1308 */ 1320 */
1309 SourceKind _sourceKind = SourceKind.UNKNOWN; 1321 SourceKind _sourceKind = SourceKind.UNKNOWN;
1310 1322
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 * Flush any AST structures being maintained by this entry. 1439 * Flush any AST structures being maintained by this entry.
1428 */ 1440 */
1429 void flushAstStructures() { 1441 void flushAstStructures() {
1430 if (identical(_parsedUnitState, CacheState.VALID)) { 1442 if (identical(_parsedUnitState, CacheState.VALID)) {
1431 _parsedUnitState = CacheState.FLUSHED; 1443 _parsedUnitState = CacheState.FLUSHED;
1432 _parsedUnitAccessed = false; 1444 _parsedUnitAccessed = false;
1433 _parsedUnit = null; 1445 _parsedUnit = null;
1434 } 1446 }
1435 _resolutionState.flushAstStructures(); 1447 _resolutionState.flushAstStructures();
1436 } 1448 }
1449
1437 List<AnalysisError> get allErrors { 1450 List<AnalysisError> get allErrors {
1438 List<AnalysisError> errors = new List<AnalysisError>(); 1451 List<AnalysisError> errors = new List<AnalysisError>();
1439 for (AnalysisError error in _parseErrors) { 1452 for (AnalysisError error in _parseErrors) {
1440 errors.add(error); 1453 errors.add(error);
1441 } 1454 }
1442 DartEntryImpl_ResolutionState state = _resolutionState; 1455 DartEntryImpl_ResolutionState state = _resolutionState;
1443 while (state != null) { 1456 while (state != null) {
1444 for (AnalysisError error in state._resolutionErrors) { 1457 for (AnalysisError error in state._resolutionErrors) {
1445 errors.add(error); 1458 errors.add(error);
1446 } 1459 }
1447 for (AnalysisError error in state._verificationErrors) { 1460 for (AnalysisError error in state._verificationErrors) {
1448 errors.add(error); 1461 errors.add(error);
1449 } 1462 }
1450 for (AnalysisError error in state._hints) { 1463 for (AnalysisError error in state._hints) {
1451 errors.add(error); 1464 errors.add(error);
1452 } 1465 }
1453 state = state._nextState; 1466 state = state._nextState;
1454 } 1467 }
1455 ; 1468 ;
1456 if (errors.length == 0) { 1469 if (errors.length == 0) {
1457 return AnalysisError.NO_ERRORS; 1470 return AnalysisError.NO_ERRORS;
1458 } 1471 }
1459 return new List.from(errors); 1472 return new List.from(errors);
1460 } 1473 }
1474
1461 CompilationUnit get anyParsedCompilationUnit { 1475 CompilationUnit get anyParsedCompilationUnit {
1462 if (identical(_parsedUnitState, CacheState.VALID)) { 1476 if (identical(_parsedUnitState, CacheState.VALID)) {
1463 _parsedUnitAccessed = true; 1477 _parsedUnitAccessed = true;
1464 return _parsedUnit; 1478 return _parsedUnit;
1465 } 1479 }
1466 return anyResolvedCompilationUnit; 1480 return anyResolvedCompilationUnit;
1467 } 1481 }
1482
1468 CompilationUnit get anyResolvedCompilationUnit { 1483 CompilationUnit get anyResolvedCompilationUnit {
1469 DartEntryImpl_ResolutionState state = _resolutionState; 1484 DartEntryImpl_ResolutionState state = _resolutionState;
1470 while (state != null) { 1485 while (state != null) {
1471 if (identical(state._resolvedUnitState, CacheState.VALID)) { 1486 if (identical(state._resolvedUnitState, CacheState.VALID)) {
1472 return state._resolvedUnit; 1487 return state._resolvedUnit;
1473 } 1488 }
1474 state = state._nextState; 1489 state = state._nextState;
1475 } 1490 }
1476 ; 1491 ;
1477 return null; 1492 return null;
1478 } 1493 }
1494
1479 SourceKind get kind => _sourceKind; 1495 SourceKind get kind => _sourceKind;
1480 1496
1481 /** 1497 /**
1482 * Answer an array of library sources containing the receiver's source. 1498 * Answer an array of library sources containing the receiver's source.
1483 */ 1499 */
1484 List<Source> get librariesContaining { 1500 List<Source> get librariesContaining {
1485 DartEntryImpl_ResolutionState state = _resolutionState; 1501 DartEntryImpl_ResolutionState state = _resolutionState;
1486 List<Source> result = new List<Source>(); 1502 List<Source> result = new List<Source>();
1487 while (state != null) { 1503 while (state != null) {
1488 if (state._librarySource != null) { 1504 if (state._librarySource != null) {
(...skipping 24 matching lines...) Expand all
1513 DartEntryImpl_ResolutionState state = _resolutionState; 1529 DartEntryImpl_ResolutionState state = _resolutionState;
1514 while (state != null) { 1530 while (state != null) {
1515 if (identical(state._resolvedUnitState, CacheState.VALID)) { 1531 if (identical(state._resolvedUnitState, CacheState.VALID)) {
1516 return state._resolvedUnit.accept(new ASTCloner()) as CompilationUnit; 1532 return state._resolvedUnit.accept(new ASTCloner()) as CompilationUnit;
1517 } 1533 }
1518 state = state._nextState; 1534 state = state._nextState;
1519 } 1535 }
1520 ; 1536 ;
1521 return null; 1537 return null;
1522 } 1538 }
1539
1523 CacheState getState(DataDescriptor descriptor) { 1540 CacheState getState(DataDescriptor descriptor) {
1524 if (identical(descriptor, DartEntry.ELEMENT)) { 1541 if (identical(descriptor, DartEntry.ELEMENT)) {
1525 return _elementState; 1542 return _elementState;
1526 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 1543 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
1527 return _exportedLibrariesState; 1544 return _exportedLibrariesState;
1528 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 1545 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
1529 return _importedLibrariesState; 1546 return _importedLibrariesState;
1530 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 1547 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
1531 return _includedPartsState; 1548 return _includedPartsState;
1532 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 1549 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
1533 return _clientServerState; 1550 return _clientServerState;
1534 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 1551 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
1535 return _launchableState; 1552 return _launchableState;
1536 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 1553 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
1537 return _parseErrorsState; 1554 return _parseErrorsState;
1538 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 1555 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
1539 return _parsedUnitState; 1556 return _parsedUnitState;
1540 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 1557 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
1541 return _publicNamespaceState; 1558 return _publicNamespaceState;
1542 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1559 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1543 return _sourceKindState; 1560 return _sourceKindState;
1544 } else { 1561 } else {
1545 return super.getState(descriptor); 1562 return super.getState(descriptor);
1546 } 1563 }
1547 } 1564 }
1565
1548 CacheState getState2(DataDescriptor descriptor, Source librarySource) { 1566 CacheState getState2(DataDescriptor descriptor, Source librarySource) {
1549 DartEntryImpl_ResolutionState state = _resolutionState; 1567 DartEntryImpl_ResolutionState state = _resolutionState;
1550 while (state != null) { 1568 while (state != null) {
1551 if (librarySource == state._librarySource) { 1569 if (librarySource == state._librarySource) {
1552 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1570 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
1553 return state._resolutionErrorsState; 1571 return state._resolutionErrorsState;
1554 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1572 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1555 return state._resolvedUnitState; 1573 return state._resolvedUnitState;
1556 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 1574 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
1557 return state._verificationErrorsState; 1575 return state._verificationErrorsState;
1558 } else if (identical(descriptor, DartEntry.HINTS)) { 1576 } else if (identical(descriptor, DartEntry.HINTS)) {
1559 return state._hintsState; 1577 return state._hintsState;
1560 } else { 1578 } else {
1561 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 1579 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
1562 } 1580 }
1563 } 1581 }
1564 state = state._nextState; 1582 state = state._nextState;
1565 } 1583 }
1566 ; 1584 ;
1567 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) { 1585 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) {
1568 return CacheState.INVALID; 1586 return CacheState.INVALID;
1569 } else { 1587 } else {
1570 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1588 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1571 } 1589 }
1572 } 1590 }
1591
1573 Object getValue(DataDescriptor descriptor) { 1592 Object getValue(DataDescriptor descriptor) {
1574 if (identical(descriptor, DartEntry.ELEMENT)) { 1593 if (identical(descriptor, DartEntry.ELEMENT)) {
1575 return _element as Object; 1594 return _element as Object;
1576 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 1595 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
1577 return _exportedLibraries as Object; 1596 return _exportedLibraries as Object;
1578 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 1597 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
1579 return _importedLibraries as Object; 1598 return _importedLibraries as Object;
1580 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 1599 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
1581 return _includedParts as Object; 1600 return _includedParts as Object;
1582 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 1601 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
1583 return (BooleanArray.get2(_bitmask, _CLIENT_CODE_INDEX) as bool) as Object ; 1602 return (BooleanArray.get2(_bitmask, _CLIENT_CODE_INDEX) as bool) as Object ;
1584 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 1603 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
1585 return (BooleanArray.get2(_bitmask, _LAUNCHABLE_INDEX) as bool) as Object; 1604 return (BooleanArray.get2(_bitmask, _LAUNCHABLE_INDEX) as bool) as Object;
1586 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 1605 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
1587 return _parseErrors as Object; 1606 return _parseErrors as Object;
1588 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 1607 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
1589 _parsedUnitAccessed = true; 1608 _parsedUnitAccessed = true;
1590 return _parsedUnit as Object; 1609 return _parsedUnit as Object;
1591 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 1610 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
1592 return _publicNamespace as Object; 1611 return _publicNamespace as Object;
1593 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 1612 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1594 return _sourceKind as Object; 1613 return _sourceKind as Object;
1595 } 1614 }
1596 return super.getValue(descriptor); 1615 return super.getValue(descriptor);
1597 } 1616 }
1617
1598 Object getValue2(DataDescriptor descriptor, Source librarySource) { 1618 Object getValue2(DataDescriptor descriptor, Source librarySource) {
1599 DartEntryImpl_ResolutionState state = _resolutionState; 1619 DartEntryImpl_ResolutionState state = _resolutionState;
1600 while (state != null) { 1620 while (state != null) {
1601 if (librarySource == state._librarySource) { 1621 if (librarySource == state._librarySource) {
1602 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1622 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
1603 return state._resolutionErrors as Object; 1623 return state._resolutionErrors as Object;
1604 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1624 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1605 return state._resolvedUnit as Object; 1625 return state._resolvedUnit as Object;
1606 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 1626 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
1607 return state._verificationErrors as Object; 1627 return state._verificationErrors as Object;
1608 } else if (identical(descriptor, DartEntry.HINTS)) { 1628 } else if (identical(descriptor, DartEntry.HINTS)) {
1609 return state._hints as Object; 1629 return state._hints as Object;
1610 } else { 1630 } else {
1611 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 1631 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
1612 } 1632 }
1613 } 1633 }
1614 state = state._nextState; 1634 state = state._nextState;
1615 } 1635 }
1616 ; 1636 ;
1617 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 1637 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) {
1618 return AnalysisError.NO_ERRORS as Object; 1638 return AnalysisError.NO_ERRORS as Object;
1619 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1639 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1620 return null; 1640 return null;
1621 } else { 1641 } else {
1622 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1642 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1623 } 1643 }
1624 } 1644 }
1645
1625 DartEntryImpl get writableCopy { 1646 DartEntryImpl get writableCopy {
1626 DartEntryImpl copy = new DartEntryImpl(); 1647 DartEntryImpl copy = new DartEntryImpl();
1627 copy.copyFrom(this); 1648 copy.copyFrom(this);
1628 return copy; 1649 return copy;
1629 } 1650 }
1651
1630 bool hasInvalidData(DataDescriptor descriptor) { 1652 bool hasInvalidData(DataDescriptor descriptor) {
1631 if (identical(descriptor, DartEntry.ELEMENT)) { 1653 if (identical(descriptor, DartEntry.ELEMENT)) {
1632 return identical(_elementState, CacheState.INVALID); 1654 return identical(_elementState, CacheState.INVALID);
1633 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 1655 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
1634 return identical(_exportedLibrariesState, CacheState.INVALID); 1656 return identical(_exportedLibrariesState, CacheState.INVALID);
1635 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 1657 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
1636 return identical(_importedLibrariesState, CacheState.INVALID); 1658 return identical(_importedLibrariesState, CacheState.INVALID);
1637 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 1659 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
1638 return identical(_includedPartsState, CacheState.INVALID); 1660 return identical(_includedPartsState, CacheState.INVALID);
1639 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 1661 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 _parsedUnit = state._resolvedUnit; 1715 _parsedUnit = state._resolvedUnit;
1694 _parsedUnitAccessed = true; 1716 _parsedUnitAccessed = true;
1695 _parsedUnitState = CacheState.VALID; 1717 _parsedUnitState = CacheState.VALID;
1696 break; 1718 break;
1697 } 1719 }
1698 state = state._nextState; 1720 state = state._nextState;
1699 } 1721 }
1700 } 1722 }
1701 discardCachedResolutionInformation(); 1723 discardCachedResolutionInformation();
1702 } 1724 }
1725
1703 bool get isRefactoringSafe { 1726 bool get isRefactoringSafe {
1704 DartEntryImpl_ResolutionState state = _resolutionState; 1727 DartEntryImpl_ResolutionState state = _resolutionState;
1705 while (state != null) { 1728 while (state != null) {
1706 CacheState resolvedState = state._resolvedUnitState; 1729 CacheState resolvedState = state._resolvedUnitState;
1707 if (resolvedState != CacheState.VALID && resolvedState != CacheState.FLUSH ED) { 1730 if (resolvedState != CacheState.VALID && resolvedState != CacheState.FLUSH ED) {
1708 return false; 1731 return false;
1709 } 1732 }
1710 state = state._nextState; 1733 state = state._nextState;
1711 } 1734 }
1712 return true; 1735 return true;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 if (_parsedUnitState != CacheState.VALID) { 1896 if (_parsedUnitState != CacheState.VALID) {
1874 _parsedUnit = unit; 1897 _parsedUnit = unit;
1875 _parsedUnitAccessed = false; 1898 _parsedUnitAccessed = false;
1876 _parsedUnitState = CacheState.VALID; 1899 _parsedUnitState = CacheState.VALID;
1877 } 1900 }
1878 if (_parseErrorsState != CacheState.VALID) { 1901 if (_parseErrorsState != CacheState.VALID) {
1879 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors; 1902 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors;
1880 _parseErrorsState = CacheState.VALID; 1903 _parseErrorsState = CacheState.VALID;
1881 } 1904 }
1882 } 1905 }
1906
1883 void setState(DataDescriptor descriptor, CacheState state) { 1907 void setState(DataDescriptor descriptor, CacheState state) {
1884 if (identical(descriptor, DartEntry.ELEMENT)) { 1908 if (identical(descriptor, DartEntry.ELEMENT)) {
1885 _element = updatedValue(state, _element, null); 1909 _element = updatedValue(state, _element, null);
1886 _elementState = state; 1910 _elementState = state;
1887 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 1911 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
1888 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_ ARRAY); 1912 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_ ARRAY);
1889 _exportedLibrariesState = state; 1913 _exportedLibrariesState = state;
1890 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 1914 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
1891 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_ ARRAY); 1915 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_ ARRAY);
1892 _importedLibrariesState = state; 1916 _importedLibrariesState = state;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 1964 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
1941 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS); 1965 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS);
1942 state._verificationErrorsState = cacheState; 1966 state._verificationErrorsState = cacheState;
1943 } else if (identical(descriptor, DartEntry.HINTS)) { 1967 } else if (identical(descriptor, DartEntry.HINTS)) {
1944 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS); 1968 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS);
1945 state._hintsState = cacheState; 1969 state._hintsState = cacheState;
1946 } else { 1970 } else {
1947 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1971 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1948 } 1972 }
1949 } 1973 }
1974
1950 void setValue(DataDescriptor descriptor, Object value) { 1975 void setValue(DataDescriptor descriptor, Object value) {
1951 if (identical(descriptor, DartEntry.ELEMENT)) { 1976 if (identical(descriptor, DartEntry.ELEMENT)) {
1952 _element = value as LibraryElement; 1977 _element = value as LibraryElement;
1953 _elementState = CacheState.VALID; 1978 _elementState = CacheState.VALID;
1954 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 1979 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
1955 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>); 1980 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>);
1956 _exportedLibrariesState = CacheState.VALID; 1981 _exportedLibrariesState = CacheState.VALID;
1957 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 1982 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
1958 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>); 1983 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S ource>);
1959 _importedLibrariesState = CacheState.VALID; 1984 _importedLibrariesState = CacheState.VALID;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 state._resolvedUnit = value as CompilationUnit; 2027 state._resolvedUnit = value as CompilationUnit;
2003 state._resolvedUnitState = CacheState.VALID; 2028 state._resolvedUnitState = CacheState.VALID;
2004 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 2029 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
2005 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>); 2030 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
2006 state._verificationErrorsState = CacheState.VALID; 2031 state._verificationErrorsState = CacheState.VALID;
2007 } else if (identical(descriptor, DartEntry.HINTS)) { 2032 } else if (identical(descriptor, DartEntry.HINTS)) {
2008 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 2033 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
2009 state._hintsState = CacheState.VALID; 2034 state._hintsState = CacheState.VALID;
2010 } 2035 }
2011 } 2036 }
2037
2012 void copyFrom(SourceEntryImpl entry) { 2038 void copyFrom(SourceEntryImpl entry) {
2013 super.copyFrom(entry); 2039 super.copyFrom(entry);
2014 DartEntryImpl other = entry as DartEntryImpl; 2040 DartEntryImpl other = entry as DartEntryImpl;
2015 _sourceKindState = other._sourceKindState; 2041 _sourceKindState = other._sourceKindState;
2016 _sourceKind = other._sourceKind; 2042 _sourceKind = other._sourceKind;
2017 _parsedUnitState = other._parsedUnitState; 2043 _parsedUnitState = other._parsedUnitState;
2018 _parsedUnit = other._parsedUnit; 2044 _parsedUnit = other._parsedUnit;
2019 _parsedUnitAccessed = other._parsedUnitAccessed; 2045 _parsedUnitAccessed = other._parsedUnitAccessed;
2020 _parseErrorsState = other._parseErrorsState; 2046 _parseErrorsState = other._parseErrorsState;
2021 _parseErrors = other._parseErrors; 2047 _parseErrors = other._parseErrors;
2022 _includedPartsState = other._includedPartsState; 2048 _includedPartsState = other._includedPartsState;
2023 _includedParts = other._includedParts; 2049 _includedParts = other._includedParts;
2024 _exportedLibrariesState = other._exportedLibrariesState; 2050 _exportedLibrariesState = other._exportedLibrariesState;
2025 _exportedLibraries = other._exportedLibraries; 2051 _exportedLibraries = other._exportedLibraries;
2026 _importedLibrariesState = other._importedLibrariesState; 2052 _importedLibrariesState = other._importedLibrariesState;
2027 _importedLibraries = other._importedLibraries; 2053 _importedLibraries = other._importedLibraries;
2028 _resolutionState.copyFrom(other._resolutionState); 2054 _resolutionState.copyFrom(other._resolutionState);
2029 _elementState = other._elementState; 2055 _elementState = other._elementState;
2030 _element = other._element; 2056 _element = other._element;
2031 _publicNamespaceState = other._publicNamespaceState; 2057 _publicNamespaceState = other._publicNamespaceState;
2032 _publicNamespace = other._publicNamespace; 2058 _publicNamespace = other._publicNamespace;
2033 _clientServerState = other._clientServerState; 2059 _clientServerState = other._clientServerState;
2034 _launchableState = other._launchableState; 2060 _launchableState = other._launchableState;
2035 _bitmask = other._bitmask; 2061 _bitmask = other._bitmask;
2036 } 2062 }
2063
2037 void writeOn(JavaStringBuilder builder) { 2064 void writeOn(JavaStringBuilder builder) {
2038 builder.append("Dart: "); 2065 builder.append("Dart: ");
2039 super.writeOn(builder); 2066 super.writeOn(builder);
2040 builder.append("; sourceKind = "); 2067 builder.append("; sourceKind = ");
2041 builder.append(_sourceKindState); 2068 builder.append(_sourceKindState);
2042 builder.append("; parsedUnit = "); 2069 builder.append("; parsedUnit = ");
2043 builder.append(_parsedUnitState); 2070 builder.append(_parsedUnitState);
2044 builder.append(" ("); 2071 builder.append(" (");
2045 builder.append(_parsedUnitAccessed ? "T" : "F"); 2072 builder.append(_parsedUnitAccessed ? "T" : "F");
2046 builder.append("); parseErrors = "); 2073 builder.append("); parseErrors = ");
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 */ 2144 */
2118 int updatedValue2(CacheState state, int currentValue, int bitIndex) { 2145 int updatedValue2(CacheState state, int currentValue, int bitIndex) {
2119 if (identical(state, CacheState.VALID)) { 2146 if (identical(state, CacheState.VALID)) {
2120 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID"); 2147 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID");
2121 } else if (identical(state, CacheState.IN_PROCESS)) { 2148 } else if (identical(state, CacheState.IN_PROCESS)) {
2122 return currentValue; 2149 return currentValue;
2123 } 2150 }
2124 return BooleanArray.set2(currentValue, bitIndex, false); 2151 return BooleanArray.set2(currentValue, bitIndex, false);
2125 } 2152 }
2126 } 2153 }
2154
2127 /** 2155 /**
2128 * Instances of the class `ResolutionState` represent the information produced b y resolving 2156 * Instances of the class `ResolutionState` represent the information produced b y resolving
2129 * a compilation unit as part of a specific library. 2157 * a compilation unit as part of a specific library.
2130 */ 2158 */
2131 class DartEntryImpl_ResolutionState { 2159 class DartEntryImpl_ResolutionState {
2132
2133 /** 2160 /**
2134 * The next resolution state or `null` if none. 2161 * The next resolution state or `null` if none.
2135 */ 2162 */
2136 DartEntryImpl_ResolutionState _nextState; 2163 DartEntryImpl_ResolutionState _nextState;
2137 2164
2138 /** 2165 /**
2139 * The source for the defining compilation unit of the library that contains t his unit. If this 2166 * The source for the defining compilation unit of the library that contains t his unit. If this
2140 * unit is the defining compilation unit for it's library, then this will be t he source for this 2167 * unit is the defining compilation unit for it's library, then this will be t he source for this
2141 * unit. 2168 * unit.
2142 */ 2169 */
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 builder.append("; verificationErrors = "); 2320 builder.append("; verificationErrors = ");
2294 builder.append(_verificationErrorsState); 2321 builder.append(_verificationErrorsState);
2295 builder.append("; hints = "); 2322 builder.append("; hints = ");
2296 builder.append(_hintsState); 2323 builder.append(_hintsState);
2297 if (_nextState != null) { 2324 if (_nextState != null) {
2298 _nextState.writeOn(builder); 2325 _nextState.writeOn(builder);
2299 } 2326 }
2300 } 2327 }
2301 } 2328 }
2302 } 2329 }
2330
2303 /** 2331 /**
2304 * Instances of the class `DataDescriptor` are immutable constants representing data that can 2332 * Instances of the class `DataDescriptor` are immutable constants representing data that can
2305 * be stored in the cache. 2333 * be stored in the cache.
2306 */ 2334 */
2307 class DataDescriptor<E> { 2335 class DataDescriptor<E> {
2308
2309 /** 2336 /**
2310 * The name of the descriptor, used for debugging purposes. 2337 * The name of the descriptor, used for debugging purposes.
2311 */ 2338 */
2312 String _name; 2339 String _name;
2313 2340
2314 /** 2341 /**
2315 * Initialize a newly created descriptor to have the given name. 2342 * Initialize a newly created descriptor to have the given name.
2316 * 2343 *
2317 * @param name the name of the descriptor 2344 * @param name the name of the descriptor
2318 */ 2345 */
2319 DataDescriptor(String name) { 2346 DataDescriptor(String name) {
2320 this._name = name; 2347 this._name = name;
2321 } 2348 }
2349
2322 String toString() => _name; 2350 String toString() => _name;
2323 } 2351 }
2352
2324 /** 2353 /**
2325 * The interface `HtmlEntry` defines the behavior of objects that maintain the i nformation 2354 * The interface `HtmlEntry` defines the behavior of objects that maintain the i nformation
2326 * cached by an analysis context about an individual HTML file. 2355 * cached by an analysis context about an individual HTML file.
2327 * 2356 *
2328 * @coverage dart.engine 2357 * @coverage dart.engine
2329 */ 2358 */
2330 abstract class HtmlEntry implements SourceEntry { 2359 abstract class HtmlEntry implements SourceEntry {
2331
2332 /** 2360 /**
2333 * The data descriptor representing the HTML element. 2361 * The data descriptor representing the HTML element.
2334 */ 2362 */
2335 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem ent>("HtmlEntry.ELEMENT"); 2363 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem ent>("HtmlEntry.ELEMENT");
2336 2364
2337 /** 2365 /**
2338 * The data descriptor representing the hints resulting from auditing the sour ce. 2366 * The data descriptor representing the hints resulting from auditing the sour ce.
2339 */ 2367 */
2340 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li st<AnalysisError>>("DartEntry.HINTS"); 2368 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li st<AnalysisError>>("DartEntry.HINTS");
2341 2369
(...skipping 11 matching lines...) Expand all
2353 * The data descriptor representing the errors resulting from resolving the so urce. 2381 * The data descriptor representing the errors resulting from resolving the so urce.
2354 */ 2382 */
2355 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); 2383 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS");
2356 2384
2357 /** 2385 /**
2358 * Return all of the errors associated with the compilation unit that are curr ently cached. 2386 * Return all of the errors associated with the compilation unit that are curr ently cached.
2359 * 2387 *
2360 * @return all of the errors associated with the compilation unit 2388 * @return all of the errors associated with the compilation unit
2361 */ 2389 */
2362 List<AnalysisError> get allErrors; 2390 List<AnalysisError> get allErrors;
2391
2363 HtmlEntryImpl get writableCopy; 2392 HtmlEntryImpl get writableCopy;
2364 } 2393 }
2394
2365 /** 2395 /**
2366 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. 2396 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry].
2367 * 2397 *
2368 * @coverage dart.engine 2398 * @coverage dart.engine
2369 */ 2399 */
2370 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { 2400 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry {
2371
2372 /** 2401 /**
2373 * The state of the cached parsed (but not resolved) HTML unit. 2402 * The state of the cached parsed (but not resolved) HTML unit.
2374 */ 2403 */
2375 CacheState _parsedUnitState = CacheState.INVALID; 2404 CacheState _parsedUnitState = CacheState.INVALID;
2376 2405
2377 /** 2406 /**
2378 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca ched. 2407 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca ched.
2379 */ 2408 */
2380 HtmlUnit _parsedUnit; 2409 HtmlUnit _parsedUnit;
2381 2410
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 /** 2443 /**
2415 * The state of the cached hints. 2444 * The state of the cached hints.
2416 */ 2445 */
2417 CacheState _hintsState = CacheState.INVALID; 2446 CacheState _hintsState = CacheState.INVALID;
2418 2447
2419 /** 2448 /**
2420 * The hints produced while auditing the compilation unit, or an empty array i f the hints are not 2449 * The hints produced while auditing the compilation unit, or an empty array i f the hints are not
2421 * currently cached. 2450 * currently cached.
2422 */ 2451 */
2423 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; 2452 List<AnalysisError> _hints = AnalysisError.NO_ERRORS;
2453
2424 List<AnalysisError> get allErrors { 2454 List<AnalysisError> get allErrors {
2425 List<AnalysisError> errors = new List<AnalysisError>(); 2455 List<AnalysisError> errors = new List<AnalysisError>();
2426 for (AnalysisError error in _resolutionErrors) { 2456 for (AnalysisError error in _resolutionErrors) {
2427 errors.add(error); 2457 errors.add(error);
2428 } 2458 }
2429 for (AnalysisError error in _hints) { 2459 for (AnalysisError error in _hints) {
2430 errors.add(error); 2460 errors.add(error);
2431 } 2461 }
2432 if (errors.length == 0) { 2462 if (errors.length == 0) {
2433 return AnalysisError.NO_ERRORS; 2463 return AnalysisError.NO_ERRORS;
2434 } 2464 }
2435 return new List.from(errors); 2465 return new List.from(errors);
2436 } 2466 }
2467
2437 SourceKind get kind => SourceKind.HTML; 2468 SourceKind get kind => SourceKind.HTML;
2469
2438 CacheState getState(DataDescriptor descriptor) { 2470 CacheState getState(DataDescriptor descriptor) {
2439 if (identical(descriptor, HtmlEntry.ELEMENT)) { 2471 if (identical(descriptor, HtmlEntry.ELEMENT)) {
2440 return _elementState; 2472 return _elementState;
2441 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { 2473 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
2442 return _parsedUnitState; 2474 return _parsedUnitState;
2443 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 2475 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
2444 return _referencedLibrariesState; 2476 return _referencedLibrariesState;
2445 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 2477 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
2446 return _resolutionErrorsState; 2478 return _resolutionErrorsState;
2447 } else if (identical(descriptor, HtmlEntry.HINTS)) { 2479 } else if (identical(descriptor, HtmlEntry.HINTS)) {
2448 return _hintsState; 2480 return _hintsState;
2449 } 2481 }
2450 return super.getState(descriptor); 2482 return super.getState(descriptor);
2451 } 2483 }
2484
2452 Object getValue(DataDescriptor descriptor) { 2485 Object getValue(DataDescriptor descriptor) {
2453 if (identical(descriptor, HtmlEntry.ELEMENT)) { 2486 if (identical(descriptor, HtmlEntry.ELEMENT)) {
2454 return _element as Object; 2487 return _element as Object;
2455 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { 2488 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
2456 return _parsedUnit as Object; 2489 return _parsedUnit as Object;
2457 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 2490 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
2458 return _referencedLibraries as Object; 2491 return _referencedLibraries as Object;
2459 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 2492 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
2460 return _resolutionErrors as Object; 2493 return _resolutionErrors as Object;
2461 } else if (identical(descriptor, HtmlEntry.HINTS)) { 2494 } else if (identical(descriptor, HtmlEntry.HINTS)) {
2462 return _hints as Object; 2495 return _hints as Object;
2463 } 2496 }
2464 return super.getValue(descriptor); 2497 return super.getValue(descriptor);
2465 } 2498 }
2499
2466 HtmlEntryImpl get writableCopy { 2500 HtmlEntryImpl get writableCopy {
2467 HtmlEntryImpl copy = new HtmlEntryImpl(); 2501 HtmlEntryImpl copy = new HtmlEntryImpl();
2468 copy.copyFrom(this); 2502 copy.copyFrom(this);
2469 return copy; 2503 return copy;
2470 } 2504 }
2471 2505
2472 /** 2506 /**
2473 * Invalidate all of the information associated with the HTML file. 2507 * Invalidate all of the information associated with the HTML file.
2474 */ 2508 */
2475 void invalidateAllInformation() { 2509 void invalidateAllInformation() {
(...skipping 11 matching lines...) Expand all
2487 void invalidateAllResolutionInformation() { 2521 void invalidateAllResolutionInformation() {
2488 _element = null; 2522 _element = null;
2489 _elementState = CacheState.INVALID; 2523 _elementState = CacheState.INVALID;
2490 _resolutionErrors = AnalysisError.NO_ERRORS; 2524 _resolutionErrors = AnalysisError.NO_ERRORS;
2491 _resolutionErrorsState = CacheState.INVALID; 2525 _resolutionErrorsState = CacheState.INVALID;
2492 _hints = AnalysisError.NO_ERRORS; 2526 _hints = AnalysisError.NO_ERRORS;
2493 _hintsState = CacheState.INVALID; 2527 _hintsState = CacheState.INVALID;
2494 } 2528 }
2495 2529
2496 /** 2530 /**
2531 * Record that an error was encountered while attempting to parse the source a ssociated with this
2532 * entry.
2533 */
2534 void recordParseError() {
2535 setState(SourceEntry.LINE_INFO, CacheState.ERROR);
2536 setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR);
2537 setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR);
2538 recordResolutionError();
2539 }
2540
2541 /**
2497 * Record that an error was encountered while attempting to resolve the source associated with 2542 * Record that an error was encountered while attempting to resolve the source associated with
2498 * this entry. 2543 * this entry.
2499 */ 2544 */
2500 void recordResolutionError() { 2545 void recordResolutionError() {
2501 setState(HtmlEntry.ELEMENT, CacheState.ERROR); 2546 setState(HtmlEntry.ELEMENT, CacheState.ERROR);
2502 setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR); 2547 setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR);
2548 setState(HtmlEntry.HINTS, CacheState.ERROR);
2503 } 2549 }
2550
2504 void setState(DataDescriptor descriptor, CacheState state) { 2551 void setState(DataDescriptor descriptor, CacheState state) {
2505 if (identical(descriptor, HtmlEntry.ELEMENT)) { 2552 if (identical(descriptor, HtmlEntry.ELEMENT)) {
2506 _element = updatedValue(state, _element, null); 2553 _element = updatedValue(state, _element, null);
2507 _elementState = state; 2554 _elementState = state;
2508 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { 2555 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
2509 _parsedUnit = updatedValue(state, _parsedUnit, null); 2556 _parsedUnit = updatedValue(state, _parsedUnit, null);
2510 _parsedUnitState = state; 2557 _parsedUnitState = state;
2511 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 2558 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
2512 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM PTY_ARRAY); 2559 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM PTY_ARRAY);
2513 _referencedLibrariesState = state; 2560 _referencedLibrariesState = state;
2514 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 2561 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
2515 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N O_ERRORS); 2562 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N O_ERRORS);
2516 _resolutionErrorsState = state; 2563 _resolutionErrorsState = state;
2517 } else if (identical(descriptor, HtmlEntry.HINTS)) { 2564 } else if (identical(descriptor, HtmlEntry.HINTS)) {
2518 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS); 2565 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS);
2519 _hintsState = state; 2566 _hintsState = state;
2520 } else { 2567 } else {
2521 super.setState(descriptor, state); 2568 super.setState(descriptor, state);
2522 } 2569 }
2523 } 2570 }
2571
2524 void setValue(DataDescriptor descriptor, Object value) { 2572 void setValue(DataDescriptor descriptor, Object value) {
2525 if (identical(descriptor, HtmlEntry.ELEMENT)) { 2573 if (identical(descriptor, HtmlEntry.ELEMENT)) {
2526 _element = value as HtmlElement; 2574 _element = value as HtmlElement;
2527 _elementState = CacheState.VALID; 2575 _elementState = CacheState.VALID;
2528 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { 2576 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
2529 _parsedUnit = value as HtmlUnit; 2577 _parsedUnit = value as HtmlUnit;
2530 _parsedUnitState = CacheState.VALID; 2578 _parsedUnitState = CacheState.VALID;
2531 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 2579 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
2532 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List <Source>); 2580 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List <Source>);
2533 _referencedLibrariesState = CacheState.VALID; 2581 _referencedLibrariesState = CacheState.VALID;
2534 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 2582 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
2535 _resolutionErrors = value as List<AnalysisError>; 2583 _resolutionErrors = value as List<AnalysisError>;
2536 _resolutionErrorsState = CacheState.VALID; 2584 _resolutionErrorsState = CacheState.VALID;
2537 } else if (identical(descriptor, HtmlEntry.HINTS)) { 2585 } else if (identical(descriptor, HtmlEntry.HINTS)) {
2538 _hints = value as List<AnalysisError>; 2586 _hints = value as List<AnalysisError>;
2539 _hintsState = CacheState.VALID; 2587 _hintsState = CacheState.VALID;
2540 } else { 2588 } else {
2541 super.setValue(descriptor, value); 2589 super.setValue(descriptor, value);
2542 } 2590 }
2543 } 2591 }
2592
2544 void copyFrom(SourceEntryImpl entry) { 2593 void copyFrom(SourceEntryImpl entry) {
2545 super.copyFrom(entry); 2594 super.copyFrom(entry);
2546 HtmlEntryImpl other = entry as HtmlEntryImpl; 2595 HtmlEntryImpl other = entry as HtmlEntryImpl;
2547 _parsedUnitState = other._parsedUnitState; 2596 _parsedUnitState = other._parsedUnitState;
2548 _parsedUnit = other._parsedUnit; 2597 _parsedUnit = other._parsedUnit;
2549 _referencedLibrariesState = other._referencedLibrariesState; 2598 _referencedLibrariesState = other._referencedLibrariesState;
2550 _referencedLibraries = other._referencedLibraries; 2599 _referencedLibraries = other._referencedLibraries;
2551 _resolutionErrors = other._resolutionErrors; 2600 _resolutionErrors = other._resolutionErrors;
2552 _resolutionErrorsState = other._resolutionErrorsState; 2601 _resolutionErrorsState = other._resolutionErrorsState;
2553 _elementState = other._elementState; 2602 _elementState = other._elementState;
2554 _element = other._element; 2603 _element = other._element;
2555 _hints = other._hints; 2604 _hints = other._hints;
2556 _hintsState = other._hintsState; 2605 _hintsState = other._hintsState;
2557 } 2606 }
2607
2558 void writeOn(JavaStringBuilder builder) { 2608 void writeOn(JavaStringBuilder builder) {
2559 builder.append("Html: "); 2609 builder.append("Html: ");
2560 super.writeOn(builder); 2610 super.writeOn(builder);
2561 builder.append("; parsedUnit = "); 2611 builder.append("; parsedUnit = ");
2562 builder.append(_parsedUnitState); 2612 builder.append(_parsedUnitState);
2563 builder.append("; resolutionErrors = "); 2613 builder.append("; resolutionErrors = ");
2564 builder.append(_resolutionErrorsState); 2614 builder.append(_resolutionErrorsState);
2565 builder.append("; referencedLibraries = "); 2615 builder.append("; referencedLibraries = ");
2566 builder.append(_referencedLibrariesState); 2616 builder.append(_referencedLibrariesState);
2567 builder.append("; element = "); 2617 builder.append("; element = ");
2568 builder.append(_elementState); 2618 builder.append(_elementState);
2569 } 2619 }
2570 } 2620 }
2621
2571 /** 2622 /**
2572 * The enumerated type `RetentionPriority` represents the priority of data in th e cache in 2623 * The enumerated type `RetentionPriority` represents the priority of data in th e cache in
2573 * terms of the desirability of retaining some specified data about a specified source. 2624 * terms of the desirability of retaining some specified data about a specified source.
2574 */ 2625 */
2575 class RetentionPriority extends Enum<RetentionPriority> { 2626 class RetentionPriority extends Enum<RetentionPriority> {
2576
2577 /** 2627 /**
2578 * A priority indicating that a given piece of data can be removed from the ca che without 2628 * A priority indicating that a given piece of data can be removed from the ca che without
2579 * reservation. 2629 * reservation.
2580 */ 2630 */
2581 static final RetentionPriority LOW = new RetentionPriority('LOW', 0); 2631 static final RetentionPriority LOW = new RetentionPriority('LOW', 0);
2582 2632
2583 /** 2633 /**
2584 * A priority indicating that a given piece of data should not be removed from the cache unless 2634 * A priority indicating that a given piece of data should not be removed from the cache unless
2585 * there are no sources for which the corresponding data has a lower priority. Currently used for 2635 * there are no sources for which the corresponding data has a lower priority. Currently used for
2586 * data that is needed in order to finish some outstanding analysis task. 2636 * data that is needed in order to finish some outstanding analysis task.
2587 */ 2637 */
2588 static final RetentionPriority MEDIUM = new RetentionPriority('MEDIUM', 1); 2638 static final RetentionPriority MEDIUM = new RetentionPriority('MEDIUM', 1);
2589 2639
2590 /** 2640 /**
2591 * A priority indicating that a given piece of data should not be removed from the cache. 2641 * A priority indicating that a given piece of data should not be removed from the cache.
2592 * Currently used for data related to a priority source. 2642 * Currently used for data related to a priority source.
2593 */ 2643 */
2594 static final RetentionPriority HIGH = new RetentionPriority('HIGH', 2); 2644 static final RetentionPriority HIGH = new RetentionPriority('HIGH', 2);
2645
2595 static final List<RetentionPriority> values = [LOW, MEDIUM, HIGH]; 2646 static final List<RetentionPriority> values = [LOW, MEDIUM, HIGH];
2647
2596 RetentionPriority(String name, int ordinal) : super(name, ordinal); 2648 RetentionPriority(String name, int ordinal) : super(name, ordinal);
2597 } 2649 }
2650
2598 /** 2651 /**
2599 * The interface `SourceEntry` defines the behavior of objects that maintain the information 2652 * The interface `SourceEntry` defines the behavior of objects that maintain the information
2600 * cached by an analysis context about an individual source, no matter what kind of source it is. 2653 * cached by an analysis context about an individual source, no matter what kind of source it is.
2601 * 2654 *
2602 * Source entries should be treated as if they were immutable unless a writable copy of the entry 2655 * Source entries should be treated as if they were immutable unless a writable copy of the entry
2603 * has been obtained and has not yet been made visible to other threads. 2656 * has been obtained and has not yet been made visible to other threads.
2604 * 2657 *
2605 * @coverage dart.engine 2658 * @coverage dart.engine
2606 */ 2659 */
2607 abstract class SourceEntry { 2660 abstract class SourceEntry {
2608
2609 /** 2661 /**
2610 * The data descriptor representing the line information. 2662 * The data descriptor representing the line information.
2611 */ 2663 */
2612 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo> ("SourceEntry.LINE_INFO"); 2664 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo> ("SourceEntry.LINE_INFO");
2613 2665
2614 /** 2666 /**
2615 * Return the exception that caused one or more values to have a state of [Cac heState#ERROR] 2667 * Return the exception that caused one or more values to have a state of [Cac heState#ERROR]
2616 * . 2668 * .
2617 * 2669 *
2618 * @return the exception that caused one or more values to be uncomputable 2670 * @return the exception that caused one or more values to be uncomputable
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 Object getValue(DataDescriptor descriptor); 2704 Object getValue(DataDescriptor descriptor);
2653 2705
2654 /** 2706 /**
2655 * Return a new entry that is initialized to the same state as this entry but that can be 2707 * Return a new entry that is initialized to the same state as this entry but that can be
2656 * modified. 2708 * modified.
2657 * 2709 *
2658 * @return a writable copy of this entry 2710 * @return a writable copy of this entry
2659 */ 2711 */
2660 SourceEntryImpl get writableCopy; 2712 SourceEntryImpl get writableCopy;
2661 } 2713 }
2714
2662 /** 2715 /**
2663 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm on to all 2716 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm on to all
2664 * [SourceEntry]. 2717 * [SourceEntry].
2665 * 2718 *
2666 * @coverage dart.engine 2719 * @coverage dart.engine
2667 */ 2720 */
2668 abstract class SourceEntryImpl implements SourceEntry { 2721 abstract class SourceEntryImpl implements SourceEntry {
2669
2670 /** 2722 /**
2671 * The most recent time at which the state of the source matched the state rep resented by this 2723 * The most recent time at which the state of the source matched the state rep resented by this
2672 * entry. 2724 * entry.
2673 */ 2725 */
2674 int _modificationTime = 0; 2726 int _modificationTime = 0;
2675 2727
2676 /** 2728 /**
2677 * The exception that caused one or more values to have a state of [CacheState #ERROR]. 2729 * The exception that caused one or more values to have a state of [CacheState #ERROR].
2678 */ 2730 */
2679 AnalysisException _exception; 2731 AnalysisException _exception;
2680 2732
2681 /** 2733 /**
2682 * The state of the cached line information. 2734 * The state of the cached line information.
2683 */ 2735 */
2684 CacheState _lineInfoState = CacheState.INVALID; 2736 CacheState _lineInfoState = CacheState.INVALID;
2685 2737
2686 /** 2738 /**
2687 * The line information computed for the source, or `null` if the line informa tion is not 2739 * The line information computed for the source, or `null` if the line informa tion is not
2688 * currently cached. 2740 * currently cached.
2689 */ 2741 */
2690 LineInfo _lineInfo; 2742 LineInfo _lineInfo;
2691 2743
2692 /** 2744 /**
2693 * Return the exception that caused one or more values to have a state of [Cac heState#ERROR] 2745 * Return the exception that caused one or more values to have a state of [Cac heState#ERROR]
2694 * . 2746 * .
2695 * 2747 *
2696 * @return the exception that caused one or more values to be uncomputable 2748 * @return the exception that caused one or more values to be uncomputable
2697 */ 2749 */
2698 AnalysisException get exception => _exception; 2750 AnalysisException get exception => _exception;
2751
2699 int get modificationTime => _modificationTime; 2752 int get modificationTime => _modificationTime;
2753
2700 CacheState getState(DataDescriptor descriptor) { 2754 CacheState getState(DataDescriptor descriptor) {
2701 if (identical(descriptor, SourceEntry.LINE_INFO)) { 2755 if (identical(descriptor, SourceEntry.LINE_INFO)) {
2702 return _lineInfoState; 2756 return _lineInfoState;
2703 } else { 2757 } else {
2704 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 2758 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
2705 } 2759 }
2706 } 2760 }
2761
2707 Object getValue(DataDescriptor descriptor) { 2762 Object getValue(DataDescriptor descriptor) {
2708 if (identical(descriptor, SourceEntry.LINE_INFO)) { 2763 if (identical(descriptor, SourceEntry.LINE_INFO)) {
2709 return _lineInfo as Object; 2764 return _lineInfo as Object;
2710 } else { 2765 } else {
2711 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 2766 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
2712 } 2767 }
2713 } 2768 }
2714 2769
2715 /** 2770 /**
2716 * Set the exception that caused one or more values to have a state of [CacheS tate#ERROR] to 2771 * Set the exception that caused one or more values to have a state of [CacheS tate#ERROR] to
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 * @param value the new value of the data represented by the given descriptor 2809 * @param value the new value of the data represented by the given descriptor
2755 */ 2810 */
2756 void setValue(DataDescriptor descriptor, Object value) { 2811 void setValue(DataDescriptor descriptor, Object value) {
2757 if (identical(descriptor, SourceEntry.LINE_INFO)) { 2812 if (identical(descriptor, SourceEntry.LINE_INFO)) {
2758 _lineInfo = value as LineInfo; 2813 _lineInfo = value as LineInfo;
2759 _lineInfoState = CacheState.VALID; 2814 _lineInfoState = CacheState.VALID;
2760 } else { 2815 } else {
2761 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 2816 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
2762 } 2817 }
2763 } 2818 }
2819
2764 String toString() { 2820 String toString() {
2765 JavaStringBuilder builder = new JavaStringBuilder(); 2821 JavaStringBuilder builder = new JavaStringBuilder();
2766 writeOn(builder); 2822 writeOn(builder);
2767 return builder.toString(); 2823 return builder.toString();
2768 } 2824 }
2769 2825
2770 /** 2826 /**
2771 * Copy the information from the given cache entry. 2827 * Copy the information from the given cache entry.
2772 * 2828 *
2773 * @param entry the cache entry from which information will be copied 2829 * @param entry the cache entry from which information will be copied
(...skipping 28 matching lines...) Expand all
2802 * 2858 *
2803 * @param builder the builder to which the text should be written 2859 * @param builder the builder to which the text should be written
2804 */ 2860 */
2805 void writeOn(JavaStringBuilder builder) { 2861 void writeOn(JavaStringBuilder builder) {
2806 builder.append("time = "); 2862 builder.append("time = ");
2807 builder.append(_modificationTime.toRadixString(16)); 2863 builder.append(_modificationTime.toRadixString(16));
2808 builder.append("; lineInfo = "); 2864 builder.append("; lineInfo = ");
2809 builder.append(_lineInfoState); 2865 builder.append(_lineInfoState);
2810 } 2866 }
2811 } 2867 }
2868
2812 /** 2869 /**
2813 * Implementation of the [AnalysisContentStatistics]. 2870 * Implementation of the [AnalysisContentStatistics].
2814 */ 2871 */
2815 class AnalysisContentStatisticsImpl implements AnalysisContentStatistics { 2872 class AnalysisContentStatisticsImpl implements AnalysisContentStatistics {
2816 Map<String, AnalysisContentStatistics_CacheRow> _dataMap = new Map<String, Ana lysisContentStatistics_CacheRow>(); 2873 Map<String, AnalysisContentStatistics_CacheRow> _dataMap = new Map<String, Ana lysisContentStatistics_CacheRow>();
2874
2817 Set<AnalysisException> _exceptions = new Set<AnalysisException>(); 2875 Set<AnalysisException> _exceptions = new Set<AnalysisException>();
2876
2818 List<AnalysisContentStatistics_CacheRow> get cacheRows { 2877 List<AnalysisContentStatistics_CacheRow> get cacheRows {
2819 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values; 2878 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values;
2820 return new List.from(items); 2879 return new List.from(items);
2821 } 2880 }
2881
2822 List<AnalysisException> get exceptions => new List.from(_exceptions); 2882 List<AnalysisException> get exceptions => new List.from(_exceptions);
2883
2823 void putCacheItem(DartEntry dartEntry, DataDescriptor descriptor) { 2884 void putCacheItem(DartEntry dartEntry, DataDescriptor descriptor) {
2824 putCacheItem3(dartEntry, descriptor, dartEntry.getState(descriptor)); 2885 putCacheItem3(dartEntry, descriptor, dartEntry.getState(descriptor));
2825 } 2886 }
2887
2826 void putCacheItem2(DartEntry dartEntry, Source librarySource, DataDescriptor d escriptor) { 2888 void putCacheItem2(DartEntry dartEntry, Source librarySource, DataDescriptor d escriptor) {
2827 putCacheItem3(dartEntry, descriptor, dartEntry.getState2(descriptor, library Source)); 2889 putCacheItem3(dartEntry, descriptor, dartEntry.getState2(descriptor, library Source));
2828 } 2890 }
2891
2829 void putCacheItem3(SourceEntry dartEntry, DataDescriptor rowDesc, CacheState s tate) { 2892 void putCacheItem3(SourceEntry dartEntry, DataDescriptor rowDesc, CacheState s tate) {
2830 String rowName = rowDesc.toString(); 2893 String rowName = rowDesc.toString();
2831 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContentStatisticsImpl_CacheRowImpl; 2894 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContentStatisticsImpl_CacheRowImpl;
2832 if (row == null) { 2895 if (row == null) {
2833 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName); 2896 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName);
2834 _dataMap[rowName] = row; 2897 _dataMap[rowName] = row;
2835 } 2898 }
2836 row.incState(state); 2899 row.incState(state);
2837 if (identical(state, CacheState.ERROR)) { 2900 if (identical(state, CacheState.ERROR)) {
2838 AnalysisException exception = dartEntry.exception; 2901 AnalysisException exception = dartEntry.exception;
2839 if (exception != null) { 2902 if (exception != null) {
2840 javaSetAdd(_exceptions, exception); 2903 javaSetAdd(_exceptions, exception);
2841 } 2904 }
2842 } 2905 }
2843 } 2906 }
2844 } 2907 }
2908
2845 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati stics_CacheRow { 2909 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati stics_CacheRow {
2846 String _name; 2910 String _name;
2911
2847 int _errorCount = 0; 2912 int _errorCount = 0;
2913
2848 int _flushedCount = 0; 2914 int _flushedCount = 0;
2915
2849 int _inProcessCount = 0; 2916 int _inProcessCount = 0;
2917
2850 int _invalidCount = 0; 2918 int _invalidCount = 0;
2919
2851 int _validCount = 0; 2920 int _validCount = 0;
2921
2852 AnalysisContentStatisticsImpl_CacheRowImpl(String name) { 2922 AnalysisContentStatisticsImpl_CacheRowImpl(String name) {
2853 this._name = name; 2923 this._name = name;
2854 } 2924 }
2855 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI mpl && ((obj as AnalysisContentStatisticsImpl_CacheRowImpl))._name == _name; 2925
2926 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI mpl && (obj as AnalysisContentStatisticsImpl_CacheRowImpl)._name == _name;
2927
2856 int get errorCount => _errorCount; 2928 int get errorCount => _errorCount;
2929
2857 int get flushedCount => _flushedCount; 2930 int get flushedCount => _flushedCount;
2931
2858 int get inProcessCount => _inProcessCount; 2932 int get inProcessCount => _inProcessCount;
2933
2859 int get invalidCount => _invalidCount; 2934 int get invalidCount => _invalidCount;
2935
2860 String get name => _name; 2936 String get name => _name;
2937
2861 int get validCount => _validCount; 2938 int get validCount => _validCount;
2939
2862 int get hashCode => _name.hashCode; 2940 int get hashCode => _name.hashCode;
2941
2863 void incState(CacheState state) { 2942 void incState(CacheState state) {
2864 if (identical(state, CacheState.ERROR)) { 2943 if (identical(state, CacheState.ERROR)) {
2865 _errorCount++; 2944 _errorCount++;
2866 } 2945 }
2867 if (identical(state, CacheState.FLUSHED)) { 2946 if (identical(state, CacheState.FLUSHED)) {
2868 _flushedCount++; 2947 _flushedCount++;
2869 } 2948 }
2870 if (identical(state, CacheState.IN_PROCESS)) { 2949 if (identical(state, CacheState.IN_PROCESS)) {
2871 _inProcessCount++; 2950 _inProcessCount++;
2872 } 2951 }
2873 if (identical(state, CacheState.INVALID)) { 2952 if (identical(state, CacheState.INVALID)) {
2874 _invalidCount++; 2953 _invalidCount++;
2875 } 2954 }
2876 if (identical(state, CacheState.VALID)) { 2955 if (identical(state, CacheState.VALID)) {
2877 _validCount++; 2956 _validCount++;
2878 } 2957 }
2879 } 2958 }
2880 } 2959 }
2960
2881 /** 2961 /**
2882 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext]. 2962 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext].
2883 * 2963 *
2884 * @coverage dart.engine 2964 * @coverage dart.engine
2885 */ 2965 */
2886 class AnalysisContextImpl implements InternalAnalysisContext { 2966 class AnalysisContextImpl implements InternalAnalysisContext {
2887
2888 /** 2967 /**
2889 * The difference between the maximum cache size and the maximum priority orde r size. The priority 2968 * The difference between the maximum cache size and the maximum priority orde r size. The priority
2890 * list must be capped so that it is less than the cache size. Failure to do s o can result in an 2969 * list must be capped so that it is less than the cache size. Failure to do s o can result in an
2891 * infinite loop in performAnalysisTask() because re-caching one AST structure can cause another 2970 * infinite loop in performAnalysisTask() because re-caching one AST structure can cause another
2892 * priority source's AST structure to be flushed. 2971 * priority source's AST structure to be flushed.
2893 */ 2972 */
2894 static int _PRIORITY_ORDER_SIZE_DELTA = 4; 2973 static int _PRIORITY_ORDER_SIZE_DELTA = 4;
2895 2974
2896 /** 2975 /**
2897 * The set of analysis options controlling the behavior of this context. 2976 * The set of analysis options controlling the behavior of this context.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 */ 3021 */
2943 IncrementalAnalysisCache _incrementalAnalysisCache; 3022 IncrementalAnalysisCache _incrementalAnalysisCache;
2944 3023
2945 /** 3024 /**
2946 * Initialize a newly created analysis context. 3025 * Initialize a newly created analysis context.
2947 */ 3026 */
2948 AnalysisContextImpl() : super() { 3027 AnalysisContextImpl() : super() {
2949 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); 3028 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this);
2950 _cache = new AnalysisCache(AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, new Analy sisContextImpl_ContextRetentionPolicy(this)); 3029 _cache = new AnalysisCache(AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, new Analy sisContextImpl_ContextRetentionPolicy(this));
2951 } 3030 }
3031
2952 void addSourceInfo(Source source, SourceEntry info) { 3032 void addSourceInfo(Source source, SourceEntry info) {
2953 _cache.put(source, info); 3033 _cache.put(source, info);
2954 } 3034 }
3035
2955 void applyChanges(ChangeSet changeSet) { 3036 void applyChanges(ChangeSet changeSet) {
2956 if (changeSet.isEmpty) { 3037 if (changeSet.isEmpty) {
2957 return; 3038 return;
2958 } 3039 }
2959 { 3040 {
2960 List<Source> removedSources = new List<Source>.from(changeSet.removed3); 3041 List<Source> removedSources = new List<Source>.from(changeSet.removed3);
2961 for (SourceContainer container in changeSet.removedContainers) { 3042 for (SourceContainer container in changeSet.removedContainers) {
2962 addSourcesInContainer(removedSources, container); 3043 addSourcesInContainer(removedSources, container);
2963 } 3044 }
2964 bool addedDartSource = false; 3045 bool addedDartSource = false;
2965 for (Source source in changeSet.added3) { 3046 for (Source source in changeSet.added3) {
2966 if (sourceAvailable(source)) { 3047 if (sourceAvailable(source)) {
2967 addedDartSource = true; 3048 addedDartSource = true;
2968 } 3049 }
2969 } 3050 }
2970 for (Source source in changeSet.changed3) { 3051 for (Source source in changeSet.changed3) {
2971 sourceChanged(source); 3052 sourceChanged(source);
2972 } 3053 }
2973 for (Source source in removedSources) { 3054 for (Source source in removedSources) {
2974 sourceRemoved(source); 3055 sourceRemoved(source);
2975 } 3056 }
2976 if (addedDartSource) { 3057 if (addedDartSource) {
2977 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 3058 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) {
2978 SourceEntry sourceEntry = mapEntry.getValue(); 3059 SourceEntry sourceEntry = mapEntry.getValue();
2979 if (!mapEntry.getKey().isInSystemLibrary && sourceEntry is DartEntry) { 3060 if (!mapEntry.getKey().isInSystemLibrary && sourceEntry is DartEntry) {
2980 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 3061 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
2981 dartCopy.invalidateAllResolutionInformation(); 3062 dartCopy.invalidateAllResolutionInformation();
2982 mapEntry.setValue(dartCopy); 3063 mapEntry.setValue(dartCopy);
2983 } 3064 }
2984 } 3065 }
2985 } 3066 }
2986 } 3067 }
2987 } 3068 }
3069
2988 String computeDocumentationComment(Element element) { 3070 String computeDocumentationComment(Element element) {
2989 if (element == null) { 3071 if (element == null) {
2990 return null; 3072 return null;
2991 } 3073 }
2992 Source source = element.source; 3074 Source source = element.source;
2993 if (source == null) { 3075 if (source == null) {
2994 return null; 3076 return null;
2995 } 3077 }
2996 CompilationUnit unit = parseCompilationUnit(source); 3078 CompilationUnit unit = parseCompilationUnit(source);
2997 if (unit == null) { 3079 if (unit == null) {
2998 return null; 3080 return null;
2999 } 3081 }
3000 NodeLocator locator = new NodeLocator.con1(element.nameOffset); 3082 NodeLocator locator = new NodeLocator.con1(element.nameOffset);
3001 ASTNode nameNode = locator.searchWithin(unit); 3083 ASTNode nameNode = locator.searchWithin(unit);
3002 while (nameNode != null) { 3084 while (nameNode != null) {
3003 if (nameNode is AnnotatedNode) { 3085 if (nameNode is AnnotatedNode) {
3004 Comment comment = ((nameNode as AnnotatedNode)).documentationComment; 3086 Comment comment = (nameNode as AnnotatedNode).documentationComment;
3005 if (comment == null) { 3087 if (comment == null) {
3006 return null; 3088 return null;
3007 } 3089 }
3008 JavaStringBuilder builder = new JavaStringBuilder(); 3090 JavaStringBuilder builder = new JavaStringBuilder();
3009 List<Token> tokens = comment.tokens; 3091 List<Token> tokens = comment.tokens;
3010 for (int i = 0; i < tokens.length; i++) { 3092 for (int i = 0; i < tokens.length; i++) {
3011 if (i > 0) { 3093 if (i > 0) {
3012 builder.append('\n'); 3094 builder.append('\n');
3013 } 3095 }
3014 builder.append(tokens[i].lexeme); 3096 builder.append(tokens[i].lexeme);
3015 } 3097 }
3016 return builder.toString(); 3098 return builder.toString();
3017 } 3099 }
3018 nameNode = nameNode.parent; 3100 nameNode = nameNode.parent;
3019 } 3101 }
3020 return null; 3102 return null;
3021 } 3103 }
3104
3022 List<AnalysisError> computeErrors(Source source) { 3105 List<AnalysisError> computeErrors(Source source) {
3023 bool enableHints = _options.hint; 3106 bool enableHints = _options.hint;
3024 SourceEntry sourceEntry = getReadableSourceEntry(source); 3107 SourceEntry sourceEntry = getReadableSourceEntry(source);
3025 if (sourceEntry is DartEntry) { 3108 if (sourceEntry is DartEntry) {
3026 List<AnalysisError> errors = new List<AnalysisError>(); 3109 List<AnalysisError> errors = new List<AnalysisError>();
3027 DartEntry dartEntry = sourceEntry as DartEntry; 3110 DartEntry dartEntry = sourceEntry as DartEntry;
3028 ListUtilities.addAll(errors, getDartParseData(source, dartEntry, DartEntry .PARSE_ERRORS)); 3111 ListUtilities.addAll(errors, getDartParseData(source, dartEntry, DartEntry .PARSE_ERRORS));
3029 dartEntry = getReadableDartEntry(source); 3112 dartEntry = getReadableDartEntry(source);
3030 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBRAR Y)) { 3113 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBRAR Y)) {
3031 ListUtilities.addAll(errors, getDartResolutionData(source, source, dartE ntry, DartEntry.RESOLUTION_ERRORS)); 3114 ListUtilities.addAll(errors, getDartResolutionData(source, source, dartE ntry, DartEntry.RESOLUTION_ERRORS));
(...skipping 14 matching lines...) Expand all
3046 if (errors.isEmpty) { 3129 if (errors.isEmpty) {
3047 return AnalysisError.NO_ERRORS; 3130 return AnalysisError.NO_ERRORS;
3048 } 3131 }
3049 return new List.from(errors); 3132 return new List.from(errors);
3050 } else if (sourceEntry is HtmlEntry) { 3133 } else if (sourceEntry is HtmlEntry) {
3051 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 3134 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
3052 return getHtmlResolutionData2(source, htmlEntry, HtmlEntry.RESOLUTION_ERRO RS); 3135 return getHtmlResolutionData2(source, htmlEntry, HtmlEntry.RESOLUTION_ERRO RS);
3053 } 3136 }
3054 return AnalysisError.NO_ERRORS; 3137 return AnalysisError.NO_ERRORS;
3055 } 3138 }
3139
3056 List<Source> computeExportedLibraries(Source source) => getDartParseData2(sour ce, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); 3140 List<Source> computeExportedLibraries(Source source) => getDartParseData2(sour ce, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
3141
3057 HtmlElement computeHtmlElement(Source source) => getHtmlResolutionData(source, HtmlEntry.ELEMENT, null); 3142 HtmlElement computeHtmlElement(Source source) => getHtmlResolutionData(source, HtmlEntry.ELEMENT, null);
3143
3058 List<Source> computeImportedLibraries(Source source) => getDartParseData2(sour ce, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); 3144 List<Source> computeImportedLibraries(Source source) => getDartParseData2(sour ce, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
3145
3059 SourceKind computeKindOf(Source source) { 3146 SourceKind computeKindOf(Source source) {
3060 SourceEntry sourceEntry = getReadableSourceEntry(source); 3147 SourceEntry sourceEntry = getReadableSourceEntry(source);
3061 if (sourceEntry == null) { 3148 if (sourceEntry == null) {
3062 return SourceKind.UNKNOWN; 3149 return SourceKind.UNKNOWN;
3063 } else if (sourceEntry is DartEntry) { 3150 } else if (sourceEntry is DartEntry) {
3064 try { 3151 try {
3065 return getDartParseData(source, sourceEntry as DartEntry, DartEntry.SOUR CE_KIND); 3152 return getDartParseData(source, sourceEntry as DartEntry, DartEntry.SOUR CE_KIND);
3066 } on AnalysisException catch (exception) { 3153 } on AnalysisException catch (exception) {
3067 return SourceKind.UNKNOWN; 3154 return SourceKind.UNKNOWN;
3068 } 3155 }
3069 } 3156 }
3070 return sourceEntry.kind; 3157 return sourceEntry.kind;
3071 } 3158 }
3159
3072 LibraryElement computeLibraryElement(Source source) => getDartResolutionData2( source, source, DartEntry.ELEMENT, null); 3160 LibraryElement computeLibraryElement(Source source) => getDartResolutionData2( source, source, DartEntry.ELEMENT, null);
3161
3073 LineInfo computeLineInfo(Source source) { 3162 LineInfo computeLineInfo(Source source) {
3074 SourceEntry sourceEntry = getReadableSourceEntry(source); 3163 SourceEntry sourceEntry = getReadableSourceEntry(source);
3075 if (sourceEntry is HtmlEntry) { 3164 if (sourceEntry is HtmlEntry) {
3076 return getHtmlParseData(source, SourceEntry.LINE_INFO, null); 3165 return getHtmlParseData(source, SourceEntry.LINE_INFO, null);
3077 } else if (sourceEntry is DartEntry) { 3166 } else if (sourceEntry is DartEntry) {
3078 return getDartParseData2(source, SourceEntry.LINE_INFO, null); 3167 return getDartParseData2(source, SourceEntry.LINE_INFO, null);
3079 } 3168 }
3080 return null; 3169 return null;
3081 } 3170 }
3171
3082 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { 3172 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) {
3083 while (true) { 3173 while (true) {
3084 { 3174 {
3085 DartEntry dartEntry = getReadableDartEntry(source); 3175 DartEntry dartEntry = getReadableDartEntry(source);
3086 if (dartEntry == null) { 3176 if (dartEntry == null) {
3087 throw new AnalysisException.con1("computeResolvableCompilationUnit for non-Dart: ${source.fullName}"); 3177 throw new AnalysisException.con1("computeResolvableCompilationUnit for non-Dart: ${source.fullName}");
3088 } 3178 }
3089 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.ERRO R)) { 3179 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.ERRO R)) {
3090 AnalysisException cause = dartEntry.exception; 3180 AnalysisException cause = dartEntry.exception;
3091 if (cause == null) { 3181 if (cause == null) {
3092 throw new AnalysisException.con1("Internal error: computeResolvableC ompilationUnit could not parse ${source.fullName}"); 3182 throw new AnalysisException.con1("Internal error: computeResolvableC ompilationUnit could not parse ${source.fullName}");
3093 } else { 3183 } else {
3094 throw new AnalysisException.con2("Internal error: computeResolvableC ompilationUnit could not parse ${source.fullName}", cause); 3184 throw new AnalysisException.con2("Internal error: computeResolvableC ompilationUnit could not parse ${source.fullName}", cause);
3095 } 3185 }
3096 } 3186 }
3097 DartEntryImpl dartCopy = dartEntry.writableCopy; 3187 DartEntryImpl dartCopy = dartEntry.writableCopy;
3098 CompilationUnit unit = dartCopy.resolvableCompilationUnit; 3188 CompilationUnit unit = dartCopy.resolvableCompilationUnit;
3099 if (unit != null) { 3189 if (unit != null) {
3100 _cache.put(source, dartCopy); 3190 _cache.put(source, dartCopy);
3101 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); 3191 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit);
3102 } 3192 }
3103 } 3193 }
3104 cacheDartParseData(source, getReadableDartEntry(source), DartEntry.PARSED_ UNIT); 3194 cacheDartParseData(source, getReadableDartEntry(source), DartEntry.PARSED_ UNIT);
3105 } 3195 }
3106 } 3196 }
3197
3107 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) { 3198 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) {
3108 HtmlEntry htmlEntry = getReadableHtmlEntry(source); 3199 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
3109 if (htmlEntry == null) { 3200 if (htmlEntry == null) {
3110 throw new AnalysisException.con1("computeResolvableHtmlUnit invoked for no n-HTML file: ${source.fullName}"); 3201 throw new AnalysisException.con1("computeResolvableHtmlUnit invoked for no n-HTML file: ${source.fullName}");
3111 } 3202 }
3112 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); 3203 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT);
3113 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); 3204 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
3114 if (unit == null) { 3205 if (unit == null) {
3115 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t could not parse ${source.fullName}"); 3206 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t could not parse ${source.fullName}");
3116 } 3207 }
3117 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); 3208 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit);
3118 } 3209 }
3210
3119 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context); 3211 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context);
3212
3120 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) { 3213 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) {
3121 List<Source> sourcesToRemove = new List<Source>(); 3214 List<Source> sourcesToRemove = new List<Source>();
3122 { 3215 {
3123 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3216 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3124 Source source = entry.getKey(); 3217 Source source = entry.getKey();
3125 if (container.contains(source)) { 3218 if (container.contains(source)) {
3126 sourcesToRemove.add(source); 3219 sourcesToRemove.add(source);
3127 newContext.addSourceInfo(source, entry.getValue().writableCopy); 3220 newContext.addSourceInfo(source, entry.getValue().writableCopy);
3128 } 3221 }
3129 } 3222 }
3130 } 3223 }
3131 return newContext; 3224 return newContext;
3132 } 3225 }
3226
3133 AnalysisOptions get analysisOptions => _options; 3227 AnalysisOptions get analysisOptions => _options;
3228
3134 Element getElement(ElementLocation location) { 3229 Element getElement(ElementLocation location) {
3135 try { 3230 try {
3136 List<String> components = ((location as ElementLocationImpl)).components; 3231 List<String> components = (location as ElementLocationImpl).components;
3137 Source librarySource = computeSourceFromEncoding(components[0]); 3232 Source librarySource = computeSourceFromEncoding(components[0]);
3138 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; 3233 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl;
3139 for (int i = 1; i < components.length; i++) { 3234 for (int i = 1; i < components.length; i++) {
3140 if (element == null) { 3235 if (element == null) {
3141 return null; 3236 return null;
3142 } 3237 }
3143 element = element.getChild(components[i]); 3238 element = element.getChild(components[i]);
3144 } 3239 }
3145 return element; 3240 return element;
3146 } on AnalysisException catch (exception) { 3241 } on AnalysisException catch (exception) {
3147 return null; 3242 return null;
3148 } 3243 }
3149 } 3244 }
3245
3150 AnalysisErrorInfo getErrors(Source source) { 3246 AnalysisErrorInfo getErrors(Source source) {
3151 SourceEntry sourceEntry = getReadableSourceEntry(source); 3247 SourceEntry sourceEntry = getReadableSourceEntry(source);
3152 if (sourceEntry is DartEntry) { 3248 if (sourceEntry is DartEntry) {
3153 DartEntry dartEntry = sourceEntry as DartEntry; 3249 DartEntry dartEntry = sourceEntry as DartEntry;
3154 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S ourceEntry.LINE_INFO)); 3250 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S ourceEntry.LINE_INFO));
3155 } else if (sourceEntry is HtmlEntry) { 3251 } else if (sourceEntry is HtmlEntry) {
3156 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 3252 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
3157 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S ourceEntry.LINE_INFO)); 3253 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S ourceEntry.LINE_INFO));
3158 } 3254 }
3159 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); 3255 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null);
3160 } 3256 }
3257
3161 HtmlElement getHtmlElement(Source source) { 3258 HtmlElement getHtmlElement(Source source) {
3162 SourceEntry sourceEntry = getReadableSourceEntry(source); 3259 SourceEntry sourceEntry = getReadableSourceEntry(source);
3163 if (sourceEntry is HtmlEntry) { 3260 if (sourceEntry is HtmlEntry) {
3164 return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT); 3261 return (sourceEntry as HtmlEntry).getValue(HtmlEntry.ELEMENT);
3165 } 3262 }
3166 return null; 3263 return null;
3167 } 3264 }
3265
3168 List<Source> getHtmlFilesReferencing(Source source) { 3266 List<Source> getHtmlFilesReferencing(Source source) {
3169 SourceKind sourceKind = getKindOf(source); 3267 SourceKind sourceKind = getKindOf(source);
3170 if (sourceKind == null) { 3268 if (sourceKind == null) {
3171 return Source.EMPTY_ARRAY; 3269 return Source.EMPTY_ARRAY;
3172 } 3270 }
3173 { 3271 {
3174 List<Source> htmlSources = new List<Source>(); 3272 List<Source> htmlSources = new List<Source>();
3175 while (true) { 3273 while (true) {
3176 if (sourceKind == SourceKind.LIBRARY) { 3274 if (sourceKind == SourceKind.LIBRARY) {
3177 } else if (sourceKind == SourceKind.PART) { 3275 } else if (sourceKind == SourceKind.PART) {
3178 List<Source> librarySources = getLibrariesContaining(source); 3276 List<Source> librarySources = getLibrariesContaining(source);
3179 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3277 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3180 SourceEntry sourceEntry = entry.getValue(); 3278 SourceEntry sourceEntry = entry.getValue();
3181 if (identical(sourceEntry.kind, SourceKind.HTML)) { 3279 if (identical(sourceEntry.kind, SourceKind.HTML)) {
3182 List<Source> referencedLibraries = ((sourceEntry as HtmlEntry)).ge tValue(HtmlEntry.REFERENCED_LIBRARIES); 3280 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getV alue(HtmlEntry.REFERENCED_LIBRARIES);
3183 if (containsAny(referencedLibraries, librarySources)) { 3281 if (containsAny(referencedLibraries, librarySources)) {
3184 htmlSources.add(entry.getKey()); 3282 htmlSources.add(entry.getKey());
3185 } 3283 }
3186 } 3284 }
3187 } 3285 }
3188 } 3286 }
3189 break; 3287 break;
3190 } 3288 }
3191 if (htmlSources.isEmpty) { 3289 if (htmlSources.isEmpty) {
3192 return Source.EMPTY_ARRAY; 3290 return Source.EMPTY_ARRAY;
3193 } 3291 }
3194 return new List.from(htmlSources); 3292 return new List.from(htmlSources);
3195 } 3293 }
3196 } 3294 }
3295
3197 List<Source> get htmlSources => getSources(SourceKind.HTML); 3296 List<Source> get htmlSources => getSources(SourceKind.HTML);
3297
3198 SourceKind getKindOf(Source source) { 3298 SourceKind getKindOf(Source source) {
3199 SourceEntry sourceEntry = getReadableSourceEntry(source); 3299 SourceEntry sourceEntry = getReadableSourceEntry(source);
3200 if (sourceEntry == null) { 3300 if (sourceEntry == null) {
3201 return SourceKind.UNKNOWN; 3301 return SourceKind.UNKNOWN;
3202 } 3302 }
3203 return sourceEntry.kind; 3303 return sourceEntry.kind;
3204 } 3304 }
3305
3205 List<Source> get launchableClientLibrarySources { 3306 List<Source> get launchableClientLibrarySources {
3206 List<Source> sources = new List<Source>(); 3307 List<Source> sources = new List<Source>();
3207 { 3308 {
3208 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3309 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3209 Source source = entry.getKey(); 3310 Source source = entry.getKey();
3210 SourceEntry sourceEntry = entry.getValue(); 3311 SourceEntry sourceEntry = entry.getValue();
3211 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste mLibrary) { 3312 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste mLibrary) {
3212 sources.add(source); 3313 sources.add(source);
3213 } 3314 }
3214 } 3315 }
3215 } 3316 }
3216 return new List.from(sources); 3317 return new List.from(sources);
3217 } 3318 }
3319
3218 List<Source> get launchableServerLibrarySources { 3320 List<Source> get launchableServerLibrarySources {
3219 List<Source> sources = new List<Source>(); 3321 List<Source> sources = new List<Source>();
3220 { 3322 {
3221 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3323 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3222 Source source = entry.getKey(); 3324 Source source = entry.getKey();
3223 SourceEntry sourceEntry = entry.getValue(); 3325 SourceEntry sourceEntry = entry.getValue();
3224 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste mLibrary) { 3326 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste mLibrary) {
3225 sources.add(source); 3327 sources.add(source);
3226 } 3328 }
3227 } 3329 }
3228 } 3330 }
3229 return new List.from(sources); 3331 return new List.from(sources);
3230 } 3332 }
3333
3231 List<Source> getLibrariesContaining(Source source) { 3334 List<Source> getLibrariesContaining(Source source) {
3232 { 3335 {
3233 SourceEntry sourceEntry = _cache.get(source); 3336 SourceEntry sourceEntry = _cache.get(source);
3234 if (sourceEntry == null || sourceEntry.kind != SourceKind.PART) { 3337 if (sourceEntry == null || sourceEntry.kind != SourceKind.PART) {
3235 return <Source> [source]; 3338 return <Source> [source];
3236 } 3339 }
3237 List<Source> librarySources = new List<Source>(); 3340 List<Source> librarySources = new List<Source>();
3238 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3341 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3239 sourceEntry = entry.getValue(); 3342 sourceEntry = entry.getValue();
3240 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { 3343 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) {
3241 if (contains(((sourceEntry as DartEntry)).getValue(DartEntry.INCLUDED_ PARTS), source)) { 3344 if (contains((sourceEntry as DartEntry).getValue(DartEntry.INCLUDED_PA RTS), source)) {
3242 librarySources.add(entry.getKey()); 3345 librarySources.add(entry.getKey());
3243 } 3346 }
3244 } 3347 }
3245 } 3348 }
3246 if (librarySources.isEmpty) { 3349 if (librarySources.isEmpty) {
3247 return Source.EMPTY_ARRAY; 3350 return Source.EMPTY_ARRAY;
3248 } 3351 }
3249 return new List.from(librarySources); 3352 return new List.from(librarySources);
3250 } 3353 }
3251 } 3354 }
3355
3252 List<Source> getLibrariesDependingOn(Source librarySource) { 3356 List<Source> getLibrariesDependingOn(Source librarySource) {
3253 { 3357 {
3254 List<Source> dependentLibraries = new List<Source>(); 3358 List<Source> dependentLibraries = new List<Source>();
3255 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3359 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3256 SourceEntry sourceEntry = entry.getValue(); 3360 SourceEntry sourceEntry = entry.getValue();
3257 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { 3361 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) {
3258 if (contains(((sourceEntry as DartEntry)).getValue(DartEntry.EXPORTED_ LIBRARIES), librarySource)) { 3362 if (contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LI BRARIES), librarySource)) {
3259 dependentLibraries.add(entry.getKey()); 3363 dependentLibraries.add(entry.getKey());
3260 } 3364 }
3261 if (contains(((sourceEntry as DartEntry)).getValue(DartEntry.IMPORTED_ LIBRARIES), librarySource)) { 3365 if (contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LI BRARIES), librarySource)) {
3262 dependentLibraries.add(entry.getKey()); 3366 dependentLibraries.add(entry.getKey());
3263 } 3367 }
3264 } 3368 }
3265 } 3369 }
3266 if (dependentLibraries.isEmpty) { 3370 if (dependentLibraries.isEmpty) {
3267 return Source.EMPTY_ARRAY; 3371 return Source.EMPTY_ARRAY;
3268 } 3372 }
3269 return new List.from(dependentLibraries); 3373 return new List.from(dependentLibraries);
3270 } 3374 }
3271 } 3375 }
3376
3272 LibraryElement getLibraryElement(Source source) { 3377 LibraryElement getLibraryElement(Source source) {
3273 SourceEntry sourceEntry = getReadableSourceEntry(source); 3378 SourceEntry sourceEntry = getReadableSourceEntry(source);
3274 if (sourceEntry is DartEntry) { 3379 if (sourceEntry is DartEntry) {
3275 return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT); 3380 return (sourceEntry as DartEntry).getValue(DartEntry.ELEMENT);
3276 } 3381 }
3277 return null; 3382 return null;
3278 } 3383 }
3384
3279 List<Source> get librarySources => getSources(SourceKind.LIBRARY); 3385 List<Source> get librarySources => getSources(SourceKind.LIBRARY);
3386
3280 LineInfo getLineInfo(Source source) { 3387 LineInfo getLineInfo(Source source) {
3281 SourceEntry sourceEntry = getReadableSourceEntry(source); 3388 SourceEntry sourceEntry = getReadableSourceEntry(source);
3282 if (sourceEntry != null) { 3389 if (sourceEntry != null) {
3283 return sourceEntry.getValue(SourceEntry.LINE_INFO); 3390 return sourceEntry.getValue(SourceEntry.LINE_INFO);
3284 } 3391 }
3285 return null; 3392 return null;
3286 } 3393 }
3394
3287 Namespace getPublicNamespace(LibraryElement library) { 3395 Namespace getPublicNamespace(LibraryElement library) {
3288 Source source = library.definingCompilationUnit.source; 3396 Source source = library.definingCompilationUnit.source;
3289 DartEntry dartEntry = getReadableDartEntry(source); 3397 DartEntry dartEntry = getReadableDartEntry(source);
3290 if (dartEntry == null) { 3398 if (dartEntry == null) {
3291 return null; 3399 return null;
3292 } 3400 }
3293 Namespace namespace = null; 3401 Namespace namespace = null;
3294 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 3402 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
3295 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); 3403 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
3296 } 3404 }
3297 if (namespace == null) { 3405 if (namespace == null) {
3298 NamespaceBuilder builder = new NamespaceBuilder(); 3406 NamespaceBuilder builder = new NamespaceBuilder();
3299 namespace = builder.createPublicNamespace(library); 3407 namespace = builder.createPublicNamespace(library);
3300 { 3408 {
3301 dartEntry = getReadableDartEntry(source); 3409 dartEntry = getReadableDartEntry(source);
3302 if (dartEntry == null) { 3410 if (dartEntry == null) {
3303 AnalysisEngine.instance.logger.logError3(new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}")); 3411 AnalysisEngine.instance.logger.logError3(new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}"));
3304 return null; 3412 return null;
3305 } 3413 }
3306 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 3414 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
3307 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; 3415 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy;
3308 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); 3416 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
3309 _cache.put(source, dartCopy); 3417 _cache.put(source, dartCopy);
3310 } 3418 }
3311 } 3419 }
3312 } 3420 }
3313 return namespace; 3421 return namespace;
3314 } 3422 }
3423
3315 Namespace getPublicNamespace2(Source source) { 3424 Namespace getPublicNamespace2(Source source) {
3316 DartEntry dartEntry = getReadableDartEntry(source); 3425 DartEntry dartEntry = getReadableDartEntry(source);
3317 if (dartEntry == null) { 3426 if (dartEntry == null) {
3318 return null; 3427 return null;
3319 } 3428 }
3320 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); 3429 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
3321 if (namespace == null) { 3430 if (namespace == null) {
3322 LibraryElement library = computeLibraryElement(source); 3431 LibraryElement library = computeLibraryElement(source);
3323 if (library == null) { 3432 if (library == null) {
3324 return null; 3433 return null;
3325 } 3434 }
3326 NamespaceBuilder builder = new NamespaceBuilder(); 3435 NamespaceBuilder builder = new NamespaceBuilder();
3327 namespace = builder.createPublicNamespace(library); 3436 namespace = builder.createPublicNamespace(library);
3328 { 3437 {
3329 dartEntry = getReadableDartEntry(source); 3438 dartEntry = getReadableDartEntry(source);
3330 if (dartEntry == null) { 3439 if (dartEntry == null) {
3331 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}"); 3440 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}");
3332 } 3441 }
3333 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 3442 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
3334 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; 3443 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy;
3335 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); 3444 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
3336 _cache.put(source, dartCopy); 3445 _cache.put(source, dartCopy);
3337 } 3446 }
3338 } 3447 }
3339 } 3448 }
3340 return namespace; 3449 return namespace;
3341 } 3450 }
3451
3342 List<Source> get refactoringUnsafeSources { 3452 List<Source> get refactoringUnsafeSources {
3343 List<Source> sources = new List<Source>(); 3453 List<Source> sources = new List<Source>();
3344 { 3454 {
3345 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3455 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3346 SourceEntry sourceEntry = entry.getValue(); 3456 SourceEntry sourceEntry = entry.getValue();
3347 if (sourceEntry is DartEntry) { 3457 if (sourceEntry is DartEntry) {
3348 if (!((sourceEntry as DartEntry)).isRefactoringSafe) { 3458 if (!(sourceEntry as DartEntry).isRefactoringSafe) {
3349 sources.add(entry.getKey()); 3459 sources.add(entry.getKey());
3350 } 3460 }
3351 } 3461 }
3352 } 3462 }
3353 } 3463 }
3354 return new List.from(sources); 3464 return new List.from(sources);
3355 } 3465 }
3466
3356 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) { 3467 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) {
3357 if (library == null) { 3468 if (library == null) {
3358 return null; 3469 return null;
3359 } 3470 }
3360 return getResolvedCompilationUnit2(unitSource, library.source); 3471 return getResolvedCompilationUnit2(unitSource, library.source);
3361 } 3472 }
3473
3362 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) { 3474 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) {
3363 SourceEntry sourceEntry = getReadableSourceEntry(unitSource); 3475 SourceEntry sourceEntry = getReadableSourceEntry(unitSource);
3364 if (sourceEntry is DartEntry) { 3476 if (sourceEntry is DartEntry) {
3365 return ((sourceEntry as DartEntry)).getValue2(DartEntry.RESOLVED_UNIT, lib rarySource); 3477 return (sourceEntry as DartEntry).getValue2(DartEntry.RESOLVED_UNIT, libra rySource);
3366 } 3478 }
3367 return null; 3479 return null;
3368 } 3480 }
3481
3369 SourceFactory get sourceFactory => _sourceFactory; 3482 SourceFactory get sourceFactory => _sourceFactory;
3370 3483
3371 /** 3484 /**
3372 * Return a list of the sources that would be processed by [performAnalysisTas k]. This 3485 * Return a list of the sources that would be processed by [performAnalysisTas k]. This
3373 * method duplicates, and must therefore be kept in sync with, [getNextTaskAna lysisTask]. 3486 * method duplicates, and must therefore be kept in sync with, [getNextTaskAna lysisTask].
3374 * This method is intended to be used for testing purposes only. 3487 * This method is intended to be used for testing purposes only.
3375 * 3488 *
3376 * @return a list of the sources that would be processed by [performAnalysisTa sk] 3489 * @return a list of the sources that would be processed by [performAnalysisTa sk]
3377 */ 3490 */
3378 List<Source> get sourcesNeedingProcessing { 3491 List<Source> get sourcesNeedingProcessing {
3379 Set<Source> sources = new Set<Source>(); 3492 Set<Source> sources = new Set<Source>();
3380 { 3493 {
3381 bool hintsEnabled = _options.hint; 3494 bool hintsEnabled = _options.hint;
3382 for (Source source in _priorityOrder) { 3495 for (Source source in _priorityOrder) {
3383 getSourcesNeedingProcessing2(source, _cache.get(source), true, hintsEnab led, sources); 3496 getSourcesNeedingProcessing2(source, _cache.get(source), true, hintsEnab led, sources);
3384 } 3497 }
3385 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 3498 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
3386 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hi ntsEnabled, sources); 3499 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hi ntsEnabled, sources);
3387 } 3500 }
3388 } 3501 }
3389 return new List<Source>.from(sources); 3502 return new List<Source>.from(sources);
3390 } 3503 }
3504
3391 AnalysisContentStatistics get statistics { 3505 AnalysisContentStatistics get statistics {
3392 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl (); 3506 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl ();
3393 { 3507 {
3394 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 3508 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) {
3395 SourceEntry entry = mapEntry.getValue(); 3509 SourceEntry entry = mapEntry.getValue();
3396 if (entry is DartEntry) { 3510 if (entry is DartEntry) {
3397 Source source = mapEntry.getKey(); 3511 Source source = mapEntry.getKey();
3398 DartEntry dartEntry = entry as DartEntry; 3512 DartEntry dartEntry = entry as DartEntry;
3399 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 3513 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
3400 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); 3514 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS);
(...skipping 13 matching lines...) Expand all
3414 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.HINTS); 3528 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.HINTS);
3415 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLUT ION_ERRORS); 3529 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLUT ION_ERRORS);
3416 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLVE D_UNIT); 3530 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLVE D_UNIT);
3417 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.VERIFIC ATION_ERRORS); 3531 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.VERIFIC ATION_ERRORS);
3418 } 3532 }
3419 } 3533 }
3420 } 3534 }
3421 } 3535 }
3422 return statistics; 3536 return statistics;
3423 } 3537 }
3538
3424 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) { 3539 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) {
3425 DartEntry dartEntry = getReadableDartEntry(unitSource); 3540 DartEntry dartEntry = getReadableDartEntry(unitSource);
3426 if (dartEntry == null) { 3541 if (dartEntry == null) {
3427 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f or non-Dart file: ${unitSource.fullName}"); 3542 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f or non-Dart file: ${unitSource.fullName}");
3428 } 3543 }
3429 Source librarySource = libraryElement.source; 3544 Source librarySource = libraryElement.source;
3430 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da rtEntry.RESOLVED_UNIT); 3545 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da rtEntry.RESOLVED_UNIT);
3431 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart Entry.getValue2(DartEntry.RESOLVED_UNIT, librarySource)); 3546 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart Entry.getValue2(DartEntry.RESOLVED_UNIT, librarySource));
3432 } 3547 }
3548
3433 bool isClientLibrary(Source librarySource) { 3549 bool isClientLibrary(Source librarySource) {
3434 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); 3550 SourceEntry sourceEntry = getReadableSourceEntry(librarySource);
3435 if (sourceEntry is DartEntry) { 3551 if (sourceEntry is DartEntry) {
3436 DartEntry dartEntry = sourceEntry as DartEntry; 3552 DartEntry dartEntry = sourceEntry as DartEntry;
3437 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE ntry.IS_LAUNCHABLE); 3553 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE ntry.IS_LAUNCHABLE);
3438 } 3554 }
3439 return false; 3555 return false;
3440 } 3556 }
3557
3441 bool isServerLibrary(Source librarySource) { 3558 bool isServerLibrary(Source librarySource) {
3442 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); 3559 SourceEntry sourceEntry = getReadableSourceEntry(librarySource);
3443 if (sourceEntry is DartEntry) { 3560 if (sourceEntry is DartEntry) {
3444 DartEntry dartEntry = sourceEntry as DartEntry; 3561 DartEntry dartEntry = sourceEntry as DartEntry;
3445 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart Entry.IS_LAUNCHABLE); 3562 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart Entry.IS_LAUNCHABLE);
3446 } 3563 }
3447 return false; 3564 return false;
3448 } 3565 }
3566
3449 void mergeContext(AnalysisContext context) { 3567 void mergeContext(AnalysisContext context) {
3450 if (context is InstrumentedAnalysisContextImpl) { 3568 if (context is InstrumentedAnalysisContextImpl) {
3451 context = ((context as InstrumentedAnalysisContextImpl)).basis; 3569 context = (context as InstrumentedAnalysisContextImpl).basis;
3452 } 3570 }
3453 if (context is! AnalysisContextImpl) { 3571 if (context is! AnalysisContextImpl) {
3454 return; 3572 return;
3455 } 3573 }
3456 { 3574 {
3457 for (MapEntry<Source, SourceEntry> entry in ((context as AnalysisContextIm pl))._cache.entrySet()) { 3575 for (MapEntry<Source, SourceEntry> entry in (context as AnalysisContextImp l)._cache.entrySet()) {
3458 Source newSource = entry.getKey(); 3576 Source newSource = entry.getKey();
3459 SourceEntry existingEntry = getReadableSourceEntry(newSource); 3577 SourceEntry existingEntry = getReadableSourceEntry(newSource);
3460 if (existingEntry == null) { 3578 if (existingEntry == null) {
3461 _cache.put(newSource, entry.getValue().writableCopy); 3579 _cache.put(newSource, entry.getValue().writableCopy);
3462 } else { 3580 } else {
3463 } 3581 }
3464 } 3582 }
3465 } 3583 }
3466 } 3584 }
3585
3467 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc e, DartEntry.PARSED_UNIT, null); 3586 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc e, DartEntry.PARSED_UNIT, null);
3587
3468 HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry.PA RSED_UNIT, null); 3588 HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry.PA RSED_UNIT, null);
3589
3469 AnalysisResult performAnalysisTask() { 3590 AnalysisResult performAnalysisTask() {
3470 int getStart = JavaSystem.currentTimeMillis(); 3591 int getStart = JavaSystem.currentTimeMillis();
3471 AnalysisTask task = nextTaskAnalysisTask; 3592 AnalysisTask task = nextTaskAnalysisTask;
3472 int getEnd = JavaSystem.currentTimeMillis(); 3593 int getEnd = JavaSystem.currentTimeMillis();
3473 if (task == null) { 3594 if (task == null) {
3474 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null, -1); 3595 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null, -1);
3475 } 3596 }
3476 int performStart = JavaSystem.currentTimeMillis(); 3597 int performStart = JavaSystem.currentTimeMillis();
3477 try { 3598 try {
3478 task.perform(_resultRecorder); 3599 task.perform(_resultRecorder);
3479 } on AnalysisException catch (exception) { 3600 } on AnalysisException catch (exception) {
3480 if (exception.cause is! JavaIOException) { 3601 if (exception.cause is! JavaIOException) {
3481 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception); 3602 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception);
3482 } 3603 }
3483 } 3604 }
3484 int performEnd = JavaSystem.currentTimeMillis(); 3605 int performEnd = JavaSystem.currentTimeMillis();
3485 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r untimeType.toString(), performEnd - performStart); 3606 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r untimeType.toString(), performEnd - performStart);
3486 } 3607 }
3608
3487 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 3609 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
3488 { 3610 {
3489 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 3611 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
3490 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { 3612 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) {
3491 Source librarySource = entry.getKey(); 3613 Source librarySource = entry.getKey();
3492 LibraryElement library = entry.getValue(); 3614 LibraryElement library = entry.getValue();
3493 DartEntry dartEntry = getReadableDartEntry(librarySource); 3615 DartEntry dartEntry = getReadableDartEntry(librarySource);
3494 if (dartEntry != null) { 3616 if (dartEntry != null) {
3495 DartEntryImpl dartCopy = dartEntry.writableCopy; 3617 DartEntryImpl dartCopy = dartEntry.writableCopy;
3496 recordElementData(dartCopy, library, htmlSource); 3618 recordElementData(dartCopy, library, htmlSource);
3497 _cache.put(librarySource, dartCopy); 3619 _cache.put(librarySource, dartCopy);
3498 } 3620 }
3499 } 3621 }
3500 } 3622 }
3501 } 3623 }
3624
3502 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) { 3625 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) {
3503 if (library == null) { 3626 if (library == null) {
3504 return null; 3627 return null;
3505 } 3628 }
3506 return resolveCompilationUnit2(unitSource, library.source); 3629 return resolveCompilationUnit2(unitSource, library.source);
3507 } 3630 }
3631
3508 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e) => getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT, null); 3632 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e) => getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT, null);
3633
3509 HtmlUnit resolveHtmlUnit(Source htmlSource) => parseHtmlUnit(htmlSource); 3634 HtmlUnit resolveHtmlUnit(Source htmlSource) => parseHtmlUnit(htmlSource);
3635
3510 void set analysisOptions(AnalysisOptions options) { 3636 void set analysisOptions(AnalysisOptions options) {
3511 { 3637 {
3512 bool needsRecompute = this._options.dart2jsHint != options.dart2jsHint || (this._options.hint && !options.hint); 3638 bool needsRecompute = this._options.dart2jsHint != options.dart2jsHint || (this._options.hint && !options.hint);
3513 int cacheSize = options.cacheSize; 3639 int cacheSize = options.cacheSize;
3514 if (this._options.cacheSize != cacheSize) { 3640 if (this._options.cacheSize != cacheSize) {
3515 this._options.cacheSize = cacheSize; 3641 this._options.cacheSize = cacheSize;
3516 _cache.maxCacheSize = cacheSize; 3642 _cache.maxCacheSize = cacheSize;
3517 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; 3643 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA;
3518 if (_priorityOrder.length > maxPriorityOrderSize) { 3644 if (_priorityOrder.length > maxPriorityOrderSize) {
3519 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize) ; 3645 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize) ;
3520 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriori tyOrderSize); 3646 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriori tyOrderSize);
3521 _priorityOrder = newPriorityOrder; 3647 _priorityOrder = newPriorityOrder;
3522 } 3648 }
3523 } 3649 }
3524 this._options.dart2jsHint = options.dart2jsHint; 3650 this._options.dart2jsHint = options.dart2jsHint;
3525 this._options.hint = options.hint; 3651 this._options.hint = options.hint;
3526 this._options.strictMode = options.strictMode; 3652 this._options.strictMode = options.strictMode;
3527 if (needsRecompute) { 3653 if (needsRecompute) {
3528 invalidateAllResolutionInformation(); 3654 invalidateAllResolutionInformation();
3529 } 3655 }
3530 } 3656 }
3531 } 3657 }
3658
3532 void set analysisPriorityOrder(List<Source> sources) { 3659 void set analysisPriorityOrder(List<Source> sources) {
3533 { 3660 {
3534 if (sources == null || sources.isEmpty) { 3661 if (sources == null || sources.isEmpty) {
3535 _priorityOrder = Source.EMPTY_ARRAY; 3662 _priorityOrder = Source.EMPTY_ARRAY;
3536 } else { 3663 } else {
3537 while (sources.remove(null)) { 3664 while (sources.remove(null)) {
3538 } 3665 }
3539 if (sources.isEmpty) { 3666 if (sources.isEmpty) {
3540 _priorityOrder = Source.EMPTY_ARRAY; 3667 _priorityOrder = Source.EMPTY_ARRAY;
3541 } 3668 }
3542 int count = Math.min(sources.length, _options.cacheSize - _PRIORITY_ORDE R_SIZE_DELTA); 3669 int count = Math.min(sources.length, _options.cacheSize - _PRIORITY_ORDE R_SIZE_DELTA);
3543 _priorityOrder = new List<Source>(count); 3670 _priorityOrder = new List<Source>(count);
3544 for (int i = 0; i < count; i++) { 3671 for (int i = 0; i < count; i++) {
3545 _priorityOrder[i] = sources[i]; 3672 _priorityOrder[i] = sources[i];
3546 } 3673 }
3547 } 3674 }
3548 } 3675 }
3549 } 3676 }
3677
3550 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 3678 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
3551 { 3679 {
3552 String originalContents = _sourceFactory.setContents(source, contents); 3680 String originalContents = _sourceFactory.setContents(source, contents);
3553 if (originalContents == null) { 3681 if (originalContents == null) {
3554 if (contents != null) { 3682 if (contents != null) {
3555 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, getReadableSourceEntry(source)); 3683 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, getReadableSourceEntry(source));
3556 sourceChanged(source); 3684 sourceChanged(source);
3557 } 3685 }
3558 } else if (originalContents != contents) { 3686 } else if (originalContents != contents) {
3559 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_incremental AnalysisCache, source, originalContents, contents, offset, oldLength, newLength, getReadableSourceEntry(source)); 3687 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_incremental AnalysisCache, source, originalContents, contents, offset, oldLength, newLength, getReadableSourceEntry(source));
3560 sourceChanged(source); 3688 sourceChanged(source);
3561 } else if (contents == null) { 3689 } else if (contents == null) {
3562 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 3690 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
3563 } 3691 }
3564 } 3692 }
3565 } 3693 }
3694
3566 void setContents(Source source, String contents) { 3695 void setContents(Source source, String contents) {
3567 { 3696 {
3568 String originalContents = _sourceFactory.setContents(source, contents); 3697 String originalContents = _sourceFactory.setContents(source, contents);
3569 if (originalContents == null) { 3698 if (originalContents == null) {
3570 if (contents != null) { 3699 if (contents != null) {
3571 sourceChanged(source); 3700 sourceChanged(source);
3572 } 3701 }
3573 } else if (originalContents != contents) { 3702 } else if (originalContents != contents) {
3574 sourceChanged(source); 3703 sourceChanged(source);
3575 } 3704 }
3576 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source); 3705 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
3577 } 3706 }
3578 } 3707 }
3708
3579 void set sourceFactory(SourceFactory factory) { 3709 void set sourceFactory(SourceFactory factory) {
3580 { 3710 {
3581 if (identical(_sourceFactory, factory)) { 3711 if (identical(_sourceFactory, factory)) {
3582 return; 3712 return;
3583 } else if (factory.context != null) { 3713 } else if (factory.context != null) {
3584 throw new IllegalStateException("Source factories cannot be shared betwe en contexts"); 3714 throw new IllegalStateException("Source factories cannot be shared betwe en contexts");
3585 } 3715 }
3586 if (_sourceFactory != null) { 3716 if (_sourceFactory != null) {
3587 _sourceFactory.context = null; 3717 _sourceFactory.context = null;
3588 } 3718 }
3589 factory.context = this; 3719 factory.context = this;
3590 _sourceFactory = factory; 3720 _sourceFactory = factory;
3591 invalidateAllResolutionInformation(); 3721 invalidateAllResolutionInformation();
3592 } 3722 }
3593 } 3723 }
3724
3594 Iterable<Source> sourcesToResolve(List<Source> changedSources) { 3725 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
3595 List<Source> librarySources = new List<Source>(); 3726 List<Source> librarySources = new List<Source>();
3596 for (Source source in changedSources) { 3727 for (Source source in changedSources) {
3597 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { 3728 if (identical(computeKindOf(source), SourceKind.LIBRARY)) {
3598 librarySources.add(source); 3729 librarySources.add(source);
3599 } 3730 }
3600 } 3731 }
3601 return librarySources; 3732 return librarySources;
3602 } 3733 }
3603 3734
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4083 * 4214 *
4084 * @param source the source to be checked 4215 * @param source the source to be checked
4085 * @param sourceEntry the cache entry associated with the source 4216 * @param sourceEntry the cache entry associated with the source
4086 * @param isPriority `true` if the source is a priority source 4217 * @param isPriority `true` if the source is a priority source
4087 * @param hintsEnabled `true` if hints are currently enabled 4218 * @param hintsEnabled `true` if hints are currently enabled
4088 * @return the next task that needs to be performed for the given source 4219 * @return the next task that needs to be performed for the given source
4089 */ 4220 */
4090 AnalysisTask getNextTaskAnalysisTask2(Source source, SourceEntry sourceEntry, bool isPriority, bool hintsEnabled) { 4221 AnalysisTask getNextTaskAnalysisTask2(Source source, SourceEntry sourceEntry, bool isPriority, bool hintsEnabled) {
4091 if (sourceEntry is DartEntry) { 4222 if (sourceEntry is DartEntry) {
4092 DartEntry dartEntry = sourceEntry as DartEntry; 4223 DartEntry dartEntry = sourceEntry as DartEntry;
4224 if (!source.exists()) {
4225 DartEntryImpl dartCopy = dartEntry.writableCopy;
4226 dartCopy.recordParseError();
4227 dartCopy.exception = new AnalysisException.con1("Source does not exist") ;
4228 _cache.put(source, dartCopy);
4229 return null;
4230 }
4093 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); 4231 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
4094 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) { 4232 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden tical(parseErrorsState, CacheState.FLUSHED))) {
4095 DartEntryImpl dartCopy = dartEntry.writableCopy; 4233 DartEntryImpl dartCopy = dartEntry.writableCopy;
4096 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 4234 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
4097 _cache.put(source, dartCopy); 4235 _cache.put(source, dartCopy);
4098 return new ParseDartTask(this, source); 4236 return new ParseDartTask(this, source);
4099 } 4237 }
4100 if (isPriority && parseErrorsState != CacheState.ERROR) { 4238 if (isPriority && parseErrorsState != CacheState.ERROR) {
4101 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; 4239 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit;
4102 if (parseUnit == null) { 4240 if (parseUnit == null) {
4103 DartEntryImpl dartCopy = dartEntry.writableCopy; 4241 DartEntryImpl dartCopy = dartEntry.writableCopy;
4104 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.IN_PROCESS); 4242 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.IN_PROCESS);
4105 _cache.put(source, dartCopy); 4243 _cache.put(source, dartCopy);
4106 return new ParseDartTask(this, source); 4244 return new ParseDartTask(this, source);
4107 } 4245 }
4108 } 4246 }
4109 for (Source librarySource in getLibrariesContaining(source)) { 4247 for (Source librarySource in getLibrariesContaining(source)) {
4110 SourceEntry libraryEntry = _cache.get(librarySource); 4248 SourceEntry libraryEntry = _cache.get(librarySource);
4111 if (libraryEntry is DartEntry) { 4249 if (libraryEntry is DartEntry) {
4112 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); 4250 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT);
4113 if (identical(elementState, CacheState.INVALID) || (isPriority && iden tical(elementState, CacheState.FLUSHED))) { 4251 if (identical(elementState, CacheState.INVALID) || (isPriority && iden tical(elementState, CacheState.FLUSHED))) {
4114 DartEntryImpl libraryCopy = ((libraryEntry as DartEntry)).writableCo py; 4252 DartEntryImpl libraryCopy = (libraryEntry as DartEntry).writableCopy ;
4115 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); 4253 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
4116 _cache.put(librarySource, libraryCopy); 4254 _cache.put(librarySource, libraryCopy);
4117 return new ResolveDartLibraryTask(this, source, librarySource); 4255 return new ResolveDartLibraryTask(this, source, librarySource);
4118 } 4256 }
4119 CacheState resolvedUnitState = dartEntry.getState2(DartEntry.RESOLVED_ UNIT, librarySource); 4257 CacheState resolvedUnitState = dartEntry.getState2(DartEntry.RESOLVED_ UNIT, librarySource);
4120 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && identical(resolvedUnitState, CacheState.FLUSHED))) { 4258 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && identical(resolvedUnitState, CacheState.FLUSHED))) {
4121 DartEntryImpl dartCopy = dartEntry.writableCopy; 4259 DartEntryImpl dartCopy = dartEntry.writableCopy;
4122 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.IN_PROCESS); 4260 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.IN_PROCESS);
4123 _cache.put(source, dartCopy); 4261 _cache.put(source, dartCopy);
4124 return new ResolveDartLibraryTask(this, source, librarySource); 4262 return new ResolveDartLibraryTask(this, source, librarySource);
(...skipping 17 matching lines...) Expand all
4142 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.IN _PROCESS); 4280 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.IN _PROCESS);
4143 _cache.put(source, dartCopy); 4281 _cache.put(source, dartCopy);
4144 return new GenerateDartHintsTask(this, libraryElement); 4282 return new GenerateDartHintsTask(this, libraryElement);
4145 } 4283 }
4146 } 4284 }
4147 } 4285 }
4148 } 4286 }
4149 } 4287 }
4150 } else if (sourceEntry is HtmlEntry) { 4288 } else if (sourceEntry is HtmlEntry) {
4151 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 4289 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
4290 if (!source.exists()) {
4291 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4292 htmlCopy.recordParseError();
4293 htmlCopy.exception = new AnalysisException.con1("Source does not exist") ;
4294 _cache.put(source, htmlCopy);
4295 return null;
4296 }
4152 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); 4297 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT);
4153 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident ical(parsedUnitState, CacheState.FLUSHED))) { 4298 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident ical(parsedUnitState, CacheState.FLUSHED))) {
4154 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 4299 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4155 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.IN_PROCESS); 4300 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.IN_PROCESS);
4156 _cache.put(source, htmlCopy); 4301 _cache.put(source, htmlCopy);
4157 return new ParseHtmlTask(this, source); 4302 return new ParseHtmlTask(this, source);
4158 } 4303 }
4159 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT); 4304 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT);
4160 if (identical(elementState, CacheState.INVALID) || (isPriority && identica l(elementState, CacheState.FLUSHED))) { 4305 if (identical(elementState, CacheState.INVALID) || (isPriority && identica l(elementState, CacheState.FLUSHED))) {
4161 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 4306 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
4345 4490
4346 /** 4491 /**
4347 * Invalidate all of the resolution results computed by this context. 4492 * Invalidate all of the resolution results computed by this context.
4348 * 4493 *
4349 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4494 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4350 */ 4495 */
4351 void invalidateAllResolutionInformation() { 4496 void invalidateAllResolutionInformation() {
4352 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 4497 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) {
4353 SourceEntry sourceEntry = mapEntry.getValue(); 4498 SourceEntry sourceEntry = mapEntry.getValue();
4354 if (sourceEntry is HtmlEntry) { 4499 if (sourceEntry is HtmlEntry) {
4355 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 4500 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
4356 htmlCopy.invalidateAllResolutionInformation(); 4501 htmlCopy.invalidateAllResolutionInformation();
4357 mapEntry.setValue(htmlCopy); 4502 mapEntry.setValue(htmlCopy);
4358 } else if (sourceEntry is DartEntry) { 4503 } else if (sourceEntry is DartEntry) {
4359 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 4504 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
4360 dartCopy.invalidateAllResolutionInformation(); 4505 dartCopy.invalidateAllResolutionInformation();
4361 mapEntry.setValue(dartCopy); 4506 mapEntry.setValue(dartCopy);
4362 } 4507 }
4363 } 4508 }
4364 } 4509 }
4365 4510
4366 /** 4511 /**
4367 * In response to a change to at least one of the compilation units in the giv en library, 4512 * In response to a change to at least one of the compilation units in the giv en library,
4368 * invalidate any results that are dependent on the result of resolving that l ibrary. 4513 * invalidate any results that are dependent on the result of resolving that l ibrary.
4369 * 4514 *
4370 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4515 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4371 * 4516 *
4372 * @param librarySource the source of the library being invalidated 4517 * @param librarySource the source of the library being invalidated
4373 */ 4518 */
4374 void invalidateLibraryResolution(Source librarySource) { 4519 void invalidateLibraryResolution(Source librarySource) {
4375 DartEntry libraryEntry = getReadableDartEntry(librarySource); 4520 DartEntry libraryEntry = getReadableDartEntry(librarySource);
4376 if (libraryEntry != null) { 4521 if (libraryEntry != null) {
4377 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S); 4522 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S);
4378 DartEntryImpl libraryCopy = libraryEntry.writableCopy; 4523 DartEntryImpl libraryCopy = libraryEntry.writableCopy;
4379 libraryCopy.invalidateAllResolutionInformation(); 4524 libraryCopy.invalidateAllResolutionInformation();
4380 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); 4525 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID);
4381 _cache.put(librarySource, libraryCopy); 4526 _cache.put(librarySource, libraryCopy);
4382 for (Source partSource in includedParts) { 4527 for (Source partSource in includedParts) {
4383 SourceEntry partEntry = _cache.get(partSource); 4528 SourceEntry partEntry = _cache.get(partSource);
4384 if (partEntry is DartEntry) { 4529 if (partEntry is DartEntry) {
4385 DartEntryImpl partCopy = ((partEntry as DartEntry)).writableCopy; 4530 DartEntryImpl partCopy = (partEntry as DartEntry).writableCopy;
4386 partCopy.invalidateAllResolutionInformation(); 4531 partCopy.invalidateAllResolutionInformation();
4387 _cache.put(partSource, partCopy); 4532 _cache.put(partSource, partCopy);
4388 } 4533 }
4389 } 4534 }
4390 } 4535 }
4391 } 4536 }
4392 4537
4393 /** 4538 /**
4394 * Return `true` if this library is, or depends on, dart:html. 4539 * Return `true` if this library is, or depends on, dart:html.
4395 * 4540 *
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4514 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; 4659 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap;
4515 if (hintMap == null) { 4660 if (hintMap == null) {
4516 { 4661 {
4517 SourceEntry sourceEntry = _cache.get(librarySource); 4662 SourceEntry sourceEntry = _cache.get(librarySource);
4518 if (sourceEntry is! DartEntry) { 4663 if (sourceEntry is! DartEntry) {
4519 throw new AnalysisException.con1("Internal error: attempting to genera te hints for non-Dart file as a Dart file: ${librarySource.fullName}"); 4664 throw new AnalysisException.con1("Internal error: attempting to genera te hints for non-Dart file as a Dart file: ${librarySource.fullName}");
4520 } 4665 }
4521 if (thrownException == null) { 4666 if (thrownException == null) {
4522 thrownException = new AnalysisException.con1("GenerateDartHintsTask re turned a null hint map without throwing an exception: ${librarySource.fullName}" ); 4667 thrownException = new AnalysisException.con1("GenerateDartHintsTask re turned a null hint map without throwing an exception: ${librarySource.fullName}" );
4523 } 4668 }
4524 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 4669 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
4525 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR); 4670 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR);
4526 dartCopy.exception = thrownException; 4671 dartCopy.exception = thrownException;
4527 _cache.put(librarySource, dartCopy); 4672 _cache.put(librarySource, dartCopy);
4528 } 4673 }
4529 throw thrownException; 4674 throw thrownException;
4530 } 4675 }
4531 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 4676 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) {
4532 Source unitSource = entry.getKey(); 4677 Source unitSource = entry.getKey();
4533 TimestampedData<List<AnalysisError>> results = entry.getValue(); 4678 TimestampedData<List<AnalysisError>> results = entry.getValue();
4534 { 4679 {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 int sourceTime = source.modificationStamp; 4839 int sourceTime = source.modificationStamp;
4695 int resultTime = task.modificationTime; 4840 int resultTime = task.modificationTime;
4696 if (sourceTime == resultTime) { 4841 if (sourceTime == resultTime) {
4697 if (htmlEntry.modificationTime != sourceTime) { 4842 if (htmlEntry.modificationTime != sourceTime) {
4698 sourceChanged(source); 4843 sourceChanged(source);
4699 htmlEntry = getReadableHtmlEntry(source); 4844 htmlEntry = getReadableHtmlEntry(source);
4700 if (htmlEntry == null) { 4845 if (htmlEntry == null) {
4701 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}"); 4846 throw new AnalysisException.con1("An HTML file became a non-HTML fil e: ${source.fullName}");
4702 } 4847 }
4703 } 4848 }
4704 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 4849 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
4705 if (thrownException == null) { 4850 if (thrownException == null) {
4706 LineInfo lineInfo = task.lineInfo; 4851 LineInfo lineInfo = task.lineInfo;
4707 HtmlUnit unit = task.htmlUnit; 4852 HtmlUnit unit = task.htmlUnit;
4708 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 4853 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
4709 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); 4854 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit);
4710 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra ries); 4855 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra ries);
4711 ChangeNoticeImpl notice = getNotice(source); 4856 ChangeNoticeImpl notice = getNotice(source);
4712 notice.setErrors(htmlEntry.allErrors, lineInfo); 4857 notice.setErrors(htmlEntry.allErrors, lineInfo);
4713 } else { 4858 } else {
4714 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); 4859 htmlCopy.recordParseError();
4715 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR);
4716 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR);
4717 } 4860 }
4718 htmlCopy.exception = thrownException; 4861 htmlCopy.exception = thrownException;
4719 _cache.put(source, htmlCopy); 4862 _cache.put(source, htmlCopy);
4720 htmlEntry = htmlCopy; 4863 htmlEntry = htmlCopy;
4721 } else { 4864 } else {
4722 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 4865 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
4723 if (thrownException == null || resultTime >= 0) { 4866 if (thrownException == null || resultTime >= 0) {
4724 if (identical(htmlCopy.getState(SourceEntry.LINE_INFO), CacheState.IN_ PROCESS)) { 4867 if (identical(htmlCopy.getState(SourceEntry.LINE_INFO), CacheState.IN_ PROCESS)) {
4725 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); 4868 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID);
4726 } 4869 }
4727 if (identical(htmlCopy.getState(HtmlEntry.PARSED_UNIT), CacheState.IN_ PROCESS)) { 4870 if (identical(htmlCopy.getState(HtmlEntry.PARSED_UNIT), CacheState.IN_ PROCESS)) {
4728 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); 4871 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID);
4729 } 4872 }
4730 if (identical(htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES), Cache State.IN_PROCESS)) { 4873 if (identical(htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES), Cache State.IN_PROCESS)) {
4731 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID ); 4874 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID );
4732 } 4875 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
4996 } 5139 }
4997 5140
4998 /** 5141 /**
4999 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5142 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5000 * 5143 *
5001 * @param source the source that has been changed 5144 * @param source the source that has been changed
5002 */ 5145 */
5003 void sourceChanged(Source source) { 5146 void sourceChanged(Source source) {
5004 SourceEntry sourceEntry = _cache.get(source); 5147 SourceEntry sourceEntry = _cache.get(source);
5005 if (sourceEntry is HtmlEntry) { 5148 if (sourceEntry is HtmlEntry) {
5006 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 5149 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
5007 htmlCopy.modificationTime = source.modificationStamp; 5150 htmlCopy.modificationTime = source.modificationStamp;
5008 htmlCopy.invalidateAllInformation(); 5151 htmlCopy.invalidateAllInformation();
5009 _cache.put(source, htmlCopy); 5152 _cache.put(source, htmlCopy);
5010 } else if (sourceEntry is DartEntry) { 5153 } else if (sourceEntry is DartEntry) {
5011 List<Source> containingLibraries = getLibrariesContaining(source); 5154 List<Source> containingLibraries = getLibrariesContaining(source);
5012 Set<Source> librariesToInvalidate = new Set<Source>(); 5155 Set<Source> librariesToInvalidate = new Set<Source>();
5013 for (Source containingLibrary in containingLibraries) { 5156 for (Source containingLibrary in containingLibraries) {
5014 javaSetAdd(librariesToInvalidate, containingLibrary); 5157 javaSetAdd(librariesToInvalidate, containingLibrary);
5015 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar y)) { 5158 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar y)) {
5016 javaSetAdd(librariesToInvalidate, dependentLibrary); 5159 javaSetAdd(librariesToInvalidate, dependentLibrary);
5017 } 5160 }
5018 } 5161 }
5019 for (Source library in librariesToInvalidate) { 5162 for (Source library in librariesToInvalidate) {
5020 invalidateLibraryResolution(library); 5163 invalidateLibraryResolution(library);
5021 } 5164 }
5022 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 5165 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
5023 dartCopy.modificationTime = source.modificationStamp; 5166 dartCopy.modificationTime = source.modificationStamp;
5024 dartCopy.invalidateAllInformation(); 5167 dartCopy.invalidateAllInformation();
5025 _cache.put(source, dartCopy); 5168 _cache.put(source, dartCopy);
5026 } 5169 }
5027 } 5170 }
5028 5171
5029 /** 5172 /**
5030 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5173 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5031 * 5174 *
5032 * @param source the source that has been deleted 5175 * @param source the source that has been deleted
5033 */ 5176 */
5034 void sourceRemoved(Source source) { 5177 void sourceRemoved(Source source) {
5035 SourceEntry sourceEntry = _cache.get(source); 5178 SourceEntry sourceEntry = _cache.get(source);
5036 if (sourceEntry is DartEntry) { 5179 if (sourceEntry is DartEntry) {
5037 Set<Source> libraries = new Set<Source>(); 5180 Set<Source> libraries = new Set<Source>();
5038 for (Source librarySource in getLibrariesContaining(source)) { 5181 for (Source librarySource in getLibrariesContaining(source)) {
5039 javaSetAdd(libraries, librarySource); 5182 javaSetAdd(libraries, librarySource);
5040 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 5183 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
5041 javaSetAdd(libraries, dependentLibrary); 5184 javaSetAdd(libraries, dependentLibrary);
5042 } 5185 }
5043 } 5186 }
5044 for (Source librarySource in libraries) { 5187 for (Source librarySource in libraries) {
5045 invalidateLibraryResolution(librarySource); 5188 invalidateLibraryResolution(librarySource);
5046 } 5189 }
5047 } 5190 }
5048 _cache.remove(source); 5191 _cache.remove(source);
5049 } 5192 }
5050 } 5193 }
5194
5051 /** 5195 /**
5052 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to 5196 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to
5053 * record the results of a task. 5197 * record the results of a task.
5054 */ 5198 */
5055 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> { 5199 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> {
5056 final AnalysisContextImpl AnalysisContextImpl_this; 5200 final AnalysisContextImpl AnalysisContextImpl_this;
5201
5057 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); 5202 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this);
5203
5058 SourceEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analys isContextImpl_this.recordGenerateDartErrorsTask(task); 5204 SourceEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analys isContextImpl_this.recordGenerateDartErrorsTask(task);
5205
5059 SourceEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => Analysis ContextImpl_this.recordGenerateDartHintsTask(task); 5206 SourceEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => Analysis ContextImpl_this.recordGenerateDartHintsTask(task);
5207
5060 SourceEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Anal ysisContextImpl_this.recordIncrementalAnalysisTaskResults(task); 5208 SourceEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Anal ysisContextImpl_this.recordIncrementalAnalysisTaskResults(task);
5209
5061 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this.r ecordParseDartTaskResults(task); 5210 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this.r ecordParseDartTaskResults(task);
5211
5062 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this.r ecordParseHtmlTaskResults(task); 5212 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this.r ecordParseHtmlTaskResults(task);
5213
5063 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis ContextImpl_this.recordResolveDartLibraryTaskResults(task); 5214 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis ContextImpl_this.recordResolveDartLibraryTaskResults(task);
5215
5064 SourceEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisCont extImpl_this.recordResolveDartUnitTaskResults(task); 5216 SourceEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisCont extImpl_this.recordResolveDartUnitTaskResults(task);
5217
5065 SourceEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_ this.recordResolveHtmlTaskResults(task); 5218 SourceEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_ this.recordResolveHtmlTaskResults(task);
5066 } 5219 }
5220
5067 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy { 5221 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy {
5068 final AnalysisContextImpl AnalysisContextImpl_this; 5222 final AnalysisContextImpl AnalysisContextImpl_this;
5223
5069 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); 5224 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this);
5225
5070 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { 5226 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) {
5071 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) { 5227 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) {
5072 if (source == prioritySource) { 5228 if (source == prioritySource) {
5073 return RetentionPriority.HIGH; 5229 return RetentionPriority.HIGH;
5074 } 5230 }
5075 } 5231 }
5076 if (sourceEntry is DartEntry) { 5232 if (sourceEntry is DartEntry) {
5077 DartEntry dartEntry = sourceEntry as DartEntry; 5233 DartEntry dartEntry = sourceEntry as DartEntry;
5078 if (astIsNeeded(dartEntry)) { 5234 if (astIsNeeded(dartEntry)) {
5079 return RetentionPriority.MEDIUM; 5235 return RetentionPriority.MEDIUM;
5080 } 5236 }
5081 } 5237 }
5082 return RetentionPriority.LOW; 5238 return RetentionPriority.LOW;
5083 } 5239 }
5240
5084 bool astIsNeeded(DartEntry dartEntry) => dartEntry.hasInvalidData(DartEntry.HI NTS) || dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || dartEntry.has InvalidData(DartEntry.RESOLUTION_ERRORS); 5241 bool astIsNeeded(DartEntry dartEntry) => dartEntry.hasInvalidData(DartEntry.HI NTS) || dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || dartEntry.has InvalidData(DartEntry.RESOLUTION_ERRORS);
5085 } 5242 }
5243
5086 /** 5244 /**
5087 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors and line info 5245 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors and line info
5088 * associated with a source. 5246 * associated with a source.
5089 */ 5247 */
5090 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { 5248 class AnalysisErrorInfoImpl implements AnalysisErrorInfo {
5091
5092 /** 5249 /**
5093 * The analysis errors associated with a source, or `null` if there are no err ors. 5250 * The analysis errors associated with a source, or `null` if there are no err ors.
5094 */ 5251 */
5095 List<AnalysisError> _errors; 5252 List<AnalysisError> _errors;
5096 5253
5097 /** 5254 /**
5098 * The line information associated with the errors, or `null` if there are no errors. 5255 * The line information associated with the errors, or `null` if there are no errors.
5099 */ 5256 */
5100 LineInfo _lineInfo; 5257 LineInfo _lineInfo;
5101 5258
(...skipping 16 matching lines...) Expand all
5118 List<AnalysisError> get errors => _errors; 5275 List<AnalysisError> get errors => _errors;
5119 5276
5120 /** 5277 /**
5121 * Return the line information associated with the errors, or `null` if there were no 5278 * Return the line information associated with the errors, or `null` if there were no
5122 * errors. 5279 * errors.
5123 * 5280 *
5124 * @return the line information associated with the errors 5281 * @return the line information associated with the errors
5125 */ 5282 */
5126 LineInfo get lineInfo => _lineInfo; 5283 LineInfo get lineInfo => _lineInfo;
5127 } 5284 }
5285
5128 /** 5286 /**
5129 * Instances of the class `AnalysisOptions` represent a set of analysis options used to 5287 * Instances of the class `AnalysisOptions` represent a set of analysis options used to
5130 * control the behavior of an analysis context. 5288 * control the behavior of an analysis context.
5131 */ 5289 */
5132 class AnalysisOptionsImpl implements AnalysisOptions { 5290 class AnalysisOptionsImpl implements AnalysisOptions {
5133
5134 /** 5291 /**
5135 * The maximum number of sources for which data should be kept in the cache. 5292 * The maximum number of sources for which data should be kept in the cache.
5136 */ 5293 */
5137 static int DEFAULT_CACHE_SIZE = 64; 5294 static int DEFAULT_CACHE_SIZE = 64;
5138 5295
5139 /** 5296 /**
5140 * The maximum number of sources for which AST structures should be kept in th e cache. 5297 * The maximum number of sources for which AST structures should be kept in th e cache.
5141 */ 5298 */
5142 int _cacheSize = DEFAULT_CACHE_SIZE; 5299 int _cacheSize = DEFAULT_CACHE_SIZE;
5143 5300
(...skipping 24 matching lines...) Expand all
5168 * given set of analysis options. 5325 * given set of analysis options.
5169 * 5326 *
5170 * @param options the analysis options whose values are being copied 5327 * @param options the analysis options whose values are being copied
5171 */ 5328 */
5172 AnalysisOptionsImpl.con1(AnalysisOptions options) { 5329 AnalysisOptionsImpl.con1(AnalysisOptions options) {
5173 _cacheSize = options.cacheSize; 5330 _cacheSize = options.cacheSize;
5174 _dart2jsHint = options.dart2jsHint; 5331 _dart2jsHint = options.dart2jsHint;
5175 _hint = options.hint; 5332 _hint = options.hint;
5176 _strictMode = options.strictMode; 5333 _strictMode = options.strictMode;
5177 } 5334 }
5335
5178 int get cacheSize => _cacheSize; 5336 int get cacheSize => _cacheSize;
5337
5179 bool get dart2jsHint => _dart2jsHint; 5338 bool get dart2jsHint => _dart2jsHint;
5339
5180 bool get hint => _hint; 5340 bool get hint => _hint;
5181 5341
5182 /** 5342 /**
5183 * Return `true` if analysis is to use strict mode. In strict mode, error repo rting is based 5343 * Return `true` if analysis is to use strict mode. In strict mode, error repo rting is based
5184 * exclusively on the static type information. 5344 * exclusively on the static type information.
5185 * 5345 *
5186 * @return `true` if analysis is to use strict mode 5346 * @return `true` if analysis is to use strict mode
5187 */ 5347 */
5188 bool get strictMode => _strictMode; 5348 bool get strictMode => _strictMode;
5189 5349
(...skipping 30 matching lines...) Expand all
5220 /** 5380 /**
5221 * Set whether analysis is to use strict mode to the given value. In strict mo de, error reporting 5381 * Set whether analysis is to use strict mode to the given value. In strict mo de, error reporting
5222 * is based exclusively on the static type information. 5382 * is based exclusively on the static type information.
5223 * 5383 *
5224 * @param isStrict `true` if analysis is to use strict mode 5384 * @param isStrict `true` if analysis is to use strict mode
5225 */ 5385 */
5226 void set strictMode(bool isStrict) { 5386 void set strictMode(bool isStrict) {
5227 _strictMode = isStrict; 5387 _strictMode = isStrict;
5228 } 5388 }
5229 } 5389 }
5390
5230 /** 5391 /**
5231 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis results 5392 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis results
5232 * associated with a given source. 5393 * associated with a given source.
5233 * 5394 *
5234 * @coverage dart.engine 5395 * @coverage dart.engine
5235 */ 5396 */
5236 class ChangeNoticeImpl implements ChangeNotice { 5397 class ChangeNoticeImpl implements ChangeNotice {
5237
5238 /** 5398 /**
5239 * The source for which the result is being reported. 5399 * The source for which the result is being reported.
5240 */ 5400 */
5241 Source _source; 5401 Source _source;
5242 5402
5243 /** 5403 /**
5244 * The fully resolved AST that changed as a result of the analysis, or `null` if the AST was 5404 * The fully resolved AST that changed as a result of the analysis, or `null` if the AST was
5245 * not changed. 5405 * not changed.
5246 */ 5406 */
5247 CompilationUnit _compilationUnit; 5407 CompilationUnit _compilationUnit;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5318 * @param errors the errors that changed as a result of the analysis 5478 * @param errors the errors that changed as a result of the analysis
5319 * @param lineInfo the line information associated with the source 5479 * @param lineInfo the line information associated with the source
5320 */ 5480 */
5321 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { 5481 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) {
5322 this._errors = errors; 5482 this._errors = errors;
5323 this._lineInfo = lineInfo; 5483 this._lineInfo = lineInfo;
5324 if (lineInfo == null) { 5484 if (lineInfo == null) {
5325 AnalysisEngine.instance.logger.logError2("No line info: ${_source}", new J avaException()); 5485 AnalysisEngine.instance.logger.logError2("No line info: ${_source}", new J avaException());
5326 } 5486 }
5327 } 5487 }
5488
5328 String toString() => "Changes for ${_source.fullName}"; 5489 String toString() => "Changes for ${_source.fullName}";
5329 } 5490 }
5491
5330 /** 5492 /**
5331 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex tImpl 5493 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex tImpl
5332 ] to delegate sources to the appropriate analysis context. For instance, if the 5494 ] to delegate sources to the appropriate analysis context. For instance, if the
5333 * source is in a system library then the analysis context from the [DartSdk] is used. 5495 * source is in a system library then the analysis context from the [DartSdk] is used.
5334 * 5496 *
5335 * @coverage dart.engine 5497 * @coverage dart.engine
5336 */ 5498 */
5337 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { 5499 class DelegatingAnalysisContextImpl extends AnalysisContextImpl {
5338
5339 /** 5500 /**
5340 * This references the [InternalAnalysisContext] held onto by the [DartSdk] wh ich is 5501 * This references the [InternalAnalysisContext] held onto by the [DartSdk] wh ich is
5341 * used (instead of this [AnalysisContext]) for SDK sources. This field is set when 5502 * used (instead of this [AnalysisContext]) for SDK sources. This field is set when
5342 * #setSourceFactory(SourceFactory) is called, and references the analysis con text in the 5503 * #setSourceFactory(SourceFactory) is called, and references the analysis con text in the
5343 * [DartUriResolver] in the [SourceFactory], this analysis context assumes tha t there 5504 * [DartUriResolver] in the [SourceFactory], this analysis context assumes tha t there
5344 * will be such a resolver. 5505 * will be such a resolver.
5345 */ 5506 */
5346 InternalAnalysisContext _sdkAnalysisContext; 5507 InternalAnalysisContext _sdkAnalysisContext;
5508
5347 void addSourceInfo(Source source, SourceEntry info) { 5509 void addSourceInfo(Source source, SourceEntry info) {
5348 if (source.isInSystemLibrary) { 5510 if (source.isInSystemLibrary) {
5349 _sdkAnalysisContext.addSourceInfo(source, info); 5511 _sdkAnalysisContext.addSourceInfo(source, info);
5350 } else { 5512 } else {
5351 super.addSourceInfo(source, info); 5513 super.addSourceInfo(source, info);
5352 } 5514 }
5353 } 5515 }
5516
5354 List<AnalysisError> computeErrors(Source source) { 5517 List<AnalysisError> computeErrors(Source source) {
5355 if (source.isInSystemLibrary) { 5518 if (source.isInSystemLibrary) {
5356 return _sdkAnalysisContext.computeErrors(source); 5519 return _sdkAnalysisContext.computeErrors(source);
5357 } else { 5520 } else {
5358 return super.computeErrors(source); 5521 return super.computeErrors(source);
5359 } 5522 }
5360 } 5523 }
5524
5361 List<Source> computeExportedLibraries(Source source) { 5525 List<Source> computeExportedLibraries(Source source) {
5362 if (source.isInSystemLibrary) { 5526 if (source.isInSystemLibrary) {
5363 return _sdkAnalysisContext.computeExportedLibraries(source); 5527 return _sdkAnalysisContext.computeExportedLibraries(source);
5364 } else { 5528 } else {
5365 return super.computeExportedLibraries(source); 5529 return super.computeExportedLibraries(source);
5366 } 5530 }
5367 } 5531 }
5532
5368 HtmlElement computeHtmlElement(Source source) { 5533 HtmlElement computeHtmlElement(Source source) {
5369 if (source.isInSystemLibrary) { 5534 if (source.isInSystemLibrary) {
5370 return _sdkAnalysisContext.computeHtmlElement(source); 5535 return _sdkAnalysisContext.computeHtmlElement(source);
5371 } else { 5536 } else {
5372 return super.computeHtmlElement(source); 5537 return super.computeHtmlElement(source);
5373 } 5538 }
5374 } 5539 }
5540
5375 List<Source> computeImportedLibraries(Source source) { 5541 List<Source> computeImportedLibraries(Source source) {
5376 if (source.isInSystemLibrary) { 5542 if (source.isInSystemLibrary) {
5377 return _sdkAnalysisContext.computeImportedLibraries(source); 5543 return _sdkAnalysisContext.computeImportedLibraries(source);
5378 } else { 5544 } else {
5379 return super.computeImportedLibraries(source); 5545 return super.computeImportedLibraries(source);
5380 } 5546 }
5381 } 5547 }
5548
5382 SourceKind computeKindOf(Source source) { 5549 SourceKind computeKindOf(Source source) {
5383 if (source.isInSystemLibrary) { 5550 if (source.isInSystemLibrary) {
5384 return _sdkAnalysisContext.computeKindOf(source); 5551 return _sdkAnalysisContext.computeKindOf(source);
5385 } else { 5552 } else {
5386 return super.computeKindOf(source); 5553 return super.computeKindOf(source);
5387 } 5554 }
5388 } 5555 }
5556
5389 LibraryElement computeLibraryElement(Source source) { 5557 LibraryElement computeLibraryElement(Source source) {
5390 if (source.isInSystemLibrary) { 5558 if (source.isInSystemLibrary) {
5391 return _sdkAnalysisContext.computeLibraryElement(source); 5559 return _sdkAnalysisContext.computeLibraryElement(source);
5392 } else { 5560 } else {
5393 return super.computeLibraryElement(source); 5561 return super.computeLibraryElement(source);
5394 } 5562 }
5395 } 5563 }
5564
5396 LineInfo computeLineInfo(Source source) { 5565 LineInfo computeLineInfo(Source source) {
5397 if (source.isInSystemLibrary) { 5566 if (source.isInSystemLibrary) {
5398 return _sdkAnalysisContext.computeLineInfo(source); 5567 return _sdkAnalysisContext.computeLineInfo(source);
5399 } else { 5568 } else {
5400 return super.computeLineInfo(source); 5569 return super.computeLineInfo(source);
5401 } 5570 }
5402 } 5571 }
5572
5403 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { 5573 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) {
5404 if (source.isInSystemLibrary) { 5574 if (source.isInSystemLibrary) {
5405 return _sdkAnalysisContext.computeResolvableCompilationUnit(source); 5575 return _sdkAnalysisContext.computeResolvableCompilationUnit(source);
5406 } else { 5576 } else {
5407 return super.computeResolvableCompilationUnit(source); 5577 return super.computeResolvableCompilationUnit(source);
5408 } 5578 }
5409 } 5579 }
5580
5410 AnalysisErrorInfo getErrors(Source source) { 5581 AnalysisErrorInfo getErrors(Source source) {
5411 if (source.isInSystemLibrary) { 5582 if (source.isInSystemLibrary) {
5412 return _sdkAnalysisContext.getErrors(source); 5583 return _sdkAnalysisContext.getErrors(source);
5413 } else { 5584 } else {
5414 return super.getErrors(source); 5585 return super.getErrors(source);
5415 } 5586 }
5416 } 5587 }
5588
5417 HtmlElement getHtmlElement(Source source) { 5589 HtmlElement getHtmlElement(Source source) {
5418 if (source.isInSystemLibrary) { 5590 if (source.isInSystemLibrary) {
5419 return _sdkAnalysisContext.getHtmlElement(source); 5591 return _sdkAnalysisContext.getHtmlElement(source);
5420 } else { 5592 } else {
5421 return super.getHtmlElement(source); 5593 return super.getHtmlElement(source);
5422 } 5594 }
5423 } 5595 }
5596
5424 List<Source> getHtmlFilesReferencing(Source source) { 5597 List<Source> getHtmlFilesReferencing(Source source) {
5425 if (source.isInSystemLibrary) { 5598 if (source.isInSystemLibrary) {
5426 return _sdkAnalysisContext.getHtmlFilesReferencing(source); 5599 return _sdkAnalysisContext.getHtmlFilesReferencing(source);
5427 } else { 5600 } else {
5428 return super.getHtmlFilesReferencing(source); 5601 return super.getHtmlFilesReferencing(source);
5429 } 5602 }
5430 } 5603 }
5604
5431 SourceKind getKindOf(Source source) { 5605 SourceKind getKindOf(Source source) {
5432 if (source.isInSystemLibrary) { 5606 if (source.isInSystemLibrary) {
5433 return _sdkAnalysisContext.getKindOf(source); 5607 return _sdkAnalysisContext.getKindOf(source);
5434 } else { 5608 } else {
5435 return super.getKindOf(source); 5609 return super.getKindOf(source);
5436 } 5610 }
5437 } 5611 }
5612
5438 List<Source> getLibrariesContaining(Source source) { 5613 List<Source> getLibrariesContaining(Source source) {
5439 if (source.isInSystemLibrary) { 5614 if (source.isInSystemLibrary) {
5440 return _sdkAnalysisContext.getLibrariesContaining(source); 5615 return _sdkAnalysisContext.getLibrariesContaining(source);
5441 } else { 5616 } else {
5442 return super.getLibrariesContaining(source); 5617 return super.getLibrariesContaining(source);
5443 } 5618 }
5444 } 5619 }
5620
5445 List<Source> getLibrariesDependingOn(Source librarySource) { 5621 List<Source> getLibrariesDependingOn(Source librarySource) {
5446 if (librarySource.isInSystemLibrary) { 5622 if (librarySource.isInSystemLibrary) {
5447 return _sdkAnalysisContext.getLibrariesDependingOn(librarySource); 5623 return _sdkAnalysisContext.getLibrariesDependingOn(librarySource);
5448 } else { 5624 } else {
5449 return super.getLibrariesDependingOn(librarySource); 5625 return super.getLibrariesDependingOn(librarySource);
5450 } 5626 }
5451 } 5627 }
5628
5452 LibraryElement getLibraryElement(Source source) { 5629 LibraryElement getLibraryElement(Source source) {
5453 if (source.isInSystemLibrary) { 5630 if (source.isInSystemLibrary) {
5454 return _sdkAnalysisContext.getLibraryElement(source); 5631 return _sdkAnalysisContext.getLibraryElement(source);
5455 } else { 5632 } else {
5456 return super.getLibraryElement(source); 5633 return super.getLibraryElement(source);
5457 } 5634 }
5458 } 5635 }
5636
5459 List<Source> get librarySources => ArrayUtils.addAll(super.librarySources, _sd kAnalysisContext.librarySources); 5637 List<Source> get librarySources => ArrayUtils.addAll(super.librarySources, _sd kAnalysisContext.librarySources);
5638
5460 LineInfo getLineInfo(Source source) { 5639 LineInfo getLineInfo(Source source) {
5461 if (source.isInSystemLibrary) { 5640 if (source.isInSystemLibrary) {
5462 return _sdkAnalysisContext.getLineInfo(source); 5641 return _sdkAnalysisContext.getLineInfo(source);
5463 } else { 5642 } else {
5464 return super.getLineInfo(source); 5643 return super.getLineInfo(source);
5465 } 5644 }
5466 } 5645 }
5646
5467 Namespace getPublicNamespace(LibraryElement library) { 5647 Namespace getPublicNamespace(LibraryElement library) {
5468 Source source = library.source; 5648 Source source = library.source;
5469 if (source.isInSystemLibrary) { 5649 if (source.isInSystemLibrary) {
5470 return _sdkAnalysisContext.getPublicNamespace(library); 5650 return _sdkAnalysisContext.getPublicNamespace(library);
5471 } else { 5651 } else {
5472 return super.getPublicNamespace(library); 5652 return super.getPublicNamespace(library);
5473 } 5653 }
5474 } 5654 }
5655
5475 Namespace getPublicNamespace2(Source source) { 5656 Namespace getPublicNamespace2(Source source) {
5476 if (source.isInSystemLibrary) { 5657 if (source.isInSystemLibrary) {
5477 return _sdkAnalysisContext.getPublicNamespace2(source); 5658 return _sdkAnalysisContext.getPublicNamespace2(source);
5478 } else { 5659 } else {
5479 return super.getPublicNamespace2(source); 5660 return super.getPublicNamespace2(source);
5480 } 5661 }
5481 } 5662 }
5663
5482 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) { 5664 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) {
5483 if (unitSource.isInSystemLibrary) { 5665 if (unitSource.isInSystemLibrary) {
5484 return _sdkAnalysisContext.getResolvedCompilationUnit(unitSource, library) ; 5666 return _sdkAnalysisContext.getResolvedCompilationUnit(unitSource, library) ;
5485 } else { 5667 } else {
5486 return super.getResolvedCompilationUnit(unitSource, library); 5668 return super.getResolvedCompilationUnit(unitSource, library);
5487 } 5669 }
5488 } 5670 }
5671
5489 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) { 5672 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) {
5490 if (unitSource.isInSystemLibrary) { 5673 if (unitSource.isInSystemLibrary) {
5491 return _sdkAnalysisContext.getResolvedCompilationUnit2(unitSource, library Source); 5674 return _sdkAnalysisContext.getResolvedCompilationUnit2(unitSource, library Source);
5492 } else { 5675 } else {
5493 return super.getResolvedCompilationUnit2(unitSource, librarySource); 5676 return super.getResolvedCompilationUnit2(unitSource, librarySource);
5494 } 5677 }
5495 } 5678 }
5679
5496 bool isClientLibrary(Source librarySource) { 5680 bool isClientLibrary(Source librarySource) {
5497 if (librarySource.isInSystemLibrary) { 5681 if (librarySource.isInSystemLibrary) {
5498 return _sdkAnalysisContext.isClientLibrary(librarySource); 5682 return _sdkAnalysisContext.isClientLibrary(librarySource);
5499 } else { 5683 } else {
5500 return super.isClientLibrary(librarySource); 5684 return super.isClientLibrary(librarySource);
5501 } 5685 }
5502 } 5686 }
5687
5503 bool isServerLibrary(Source librarySource) { 5688 bool isServerLibrary(Source librarySource) {
5504 if (librarySource.isInSystemLibrary) { 5689 if (librarySource.isInSystemLibrary) {
5505 return _sdkAnalysisContext.isServerLibrary(librarySource); 5690 return _sdkAnalysisContext.isServerLibrary(librarySource);
5506 } else { 5691 } else {
5507 return super.isServerLibrary(librarySource); 5692 return super.isServerLibrary(librarySource);
5508 } 5693 }
5509 } 5694 }
5695
5510 CompilationUnit parseCompilationUnit(Source source) { 5696 CompilationUnit parseCompilationUnit(Source source) {
5511 if (source.isInSystemLibrary) { 5697 if (source.isInSystemLibrary) {
5512 return _sdkAnalysisContext.parseCompilationUnit(source); 5698 return _sdkAnalysisContext.parseCompilationUnit(source);
5513 } else { 5699 } else {
5514 return super.parseCompilationUnit(source); 5700 return super.parseCompilationUnit(source);
5515 } 5701 }
5516 } 5702 }
5703
5517 HtmlUnit parseHtmlUnit(Source source) { 5704 HtmlUnit parseHtmlUnit(Source source) {
5518 if (source.isInSystemLibrary) { 5705 if (source.isInSystemLibrary) {
5519 return _sdkAnalysisContext.parseHtmlUnit(source); 5706 return _sdkAnalysisContext.parseHtmlUnit(source);
5520 } else { 5707 } else {
5521 return super.parseHtmlUnit(source); 5708 return super.parseHtmlUnit(source);
5522 } 5709 }
5523 } 5710 }
5711
5524 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 5712 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
5525 if (elementMap.isEmpty) { 5713 if (elementMap.isEmpty) {
5526 return; 5714 return;
5527 } 5715 }
5528 Source source = new JavaIterator(elementMap.keys.toSet()).next(); 5716 Source source = new JavaIterator(elementMap.keys.toSet()).next();
5529 if (source.isInSystemLibrary) { 5717 if (source.isInSystemLibrary) {
5530 _sdkAnalysisContext.recordLibraryElements(elementMap); 5718 _sdkAnalysisContext.recordLibraryElements(elementMap);
5531 } else { 5719 } else {
5532 super.recordLibraryElements(elementMap); 5720 super.recordLibraryElements(elementMap);
5533 } 5721 }
5534 } 5722 }
5723
5535 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) { 5724 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) {
5536 if (source.isInSystemLibrary) { 5725 if (source.isInSystemLibrary) {
5537 return _sdkAnalysisContext.resolveCompilationUnit(source, library); 5726 return _sdkAnalysisContext.resolveCompilationUnit(source, library);
5538 } else { 5727 } else {
5539 return super.resolveCompilationUnit(source, library); 5728 return super.resolveCompilationUnit(source, library);
5540 } 5729 }
5541 } 5730 }
5731
5542 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e) { 5732 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e) {
5543 if (unitSource.isInSystemLibrary) { 5733 if (unitSource.isInSystemLibrary) {
5544 return _sdkAnalysisContext.resolveCompilationUnit2(unitSource, librarySour ce); 5734 return _sdkAnalysisContext.resolveCompilationUnit2(unitSource, librarySour ce);
5545 } else { 5735 } else {
5546 return super.resolveCompilationUnit2(unitSource, librarySource); 5736 return super.resolveCompilationUnit2(unitSource, librarySource);
5547 } 5737 }
5548 } 5738 }
5739
5549 HtmlUnit resolveHtmlUnit(Source unitSource) { 5740 HtmlUnit resolveHtmlUnit(Source unitSource) {
5550 if (unitSource.isInSystemLibrary) { 5741 if (unitSource.isInSystemLibrary) {
5551 return _sdkAnalysisContext.resolveHtmlUnit(unitSource); 5742 return _sdkAnalysisContext.resolveHtmlUnit(unitSource);
5552 } else { 5743 } else {
5553 return super.resolveHtmlUnit(unitSource); 5744 return super.resolveHtmlUnit(unitSource);
5554 } 5745 }
5555 } 5746 }
5747
5556 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 5748 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
5557 if (source.isInSystemLibrary) { 5749 if (source.isInSystemLibrary) {
5558 _sdkAnalysisContext.setChangedContents(source, contents, offset, oldLength , newLength); 5750 _sdkAnalysisContext.setChangedContents(source, contents, offset, oldLength , newLength);
5559 } else { 5751 } else {
5560 super.setChangedContents(source, contents, offset, oldLength, newLength); 5752 super.setChangedContents(source, contents, offset, oldLength, newLength);
5561 } 5753 }
5562 } 5754 }
5755
5563 void setContents(Source source, String contents) { 5756 void setContents(Source source, String contents) {
5564 if (source.isInSystemLibrary) { 5757 if (source.isInSystemLibrary) {
5565 _sdkAnalysisContext.setContents(source, contents); 5758 _sdkAnalysisContext.setContents(source, contents);
5566 } else { 5759 } else {
5567 super.setContents(source, contents); 5760 super.setContents(source, contents);
5568 } 5761 }
5569 } 5762 }
5763
5570 void set sourceFactory(SourceFactory factory) { 5764 void set sourceFactory(SourceFactory factory) {
5571 super.sourceFactory = factory; 5765 super.sourceFactory = factory;
5572 DartSdk sdk = factory.dartSdk; 5766 DartSdk sdk = factory.dartSdk;
5573 if (sdk != null) { 5767 if (sdk != null) {
5574 _sdkAnalysisContext = sdk.context as InternalAnalysisContext; 5768 _sdkAnalysisContext = sdk.context as InternalAnalysisContext;
5575 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { 5769 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) {
5576 _sdkAnalysisContext = null; 5770 _sdkAnalysisContext = null;
5577 throw new IllegalStateException("The context provided by an SDK cannot i tself be a delegating analysis context"); 5771 throw new IllegalStateException("The context provided by an SDK cannot i tself be a delegating analysis context");
5578 } 5772 }
5579 } else { 5773 } else {
5580 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal ysisContextImpls must have a DartSdk associated with the provided SourceFactory. "); 5774 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal ysisContextImpls must have a DartSdk associated with the provided SourceFactory. ");
5581 } 5775 }
5582 } 5776 }
5583 } 5777 }
5778
5584 /** 5779 /**
5585 * Instances of the class `IncrementalAnalysisCache` hold information used to pe rform 5780 * Instances of the class `IncrementalAnalysisCache` hold information used to pe rform
5586 * incremental analysis. 5781 * incremental analysis.
5587 * 5782 *
5588 * @see AnalysisContextImpl#setChangedContents(Source, String, int, int, int) 5783 * @see AnalysisContextImpl#setChangedContents(Source, String, int, int, int)
5589 */ 5784 */
5590 class IncrementalAnalysisCache { 5785 class IncrementalAnalysisCache {
5591
5592 /** 5786 /**
5593 * Determine if the incremental analysis result can be cached for the next inc remental analysis. 5787 * Determine if the incremental analysis result can be cached for the next inc remental analysis.
5594 * 5788 *
5595 * @param cache the prior incremental analysis cache 5789 * @param cache the prior incremental analysis cache
5596 * @param unit the incrementally updated compilation unit 5790 * @param unit the incrementally updated compilation unit
5597 * @return the cache used for incremental analysis or `null` if incremental an alysis results 5791 * @return the cache used for incremental analysis or `null` if incremental an alysis results
5598 * cannot be cached for the next incremental analysis 5792 * cannot be cached for the next incremental analysis
5599 */ 5793 */
5600 static IncrementalAnalysisCache cacheResult(IncrementalAnalysisCache cache, Co mpilationUnit unit) { 5794 static IncrementalAnalysisCache cacheResult(IncrementalAnalysisCache cache, Co mpilationUnit unit) {
5601 if (cache != null && unit != null) { 5795 if (cache != null && unit != null) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
5683 * cannot be cached for the next incremental analysis 5877 * cannot be cached for the next incremental analysis
5684 */ 5878 */
5685 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache , Source source, CompilationUnit unit) { 5879 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache , Source source, CompilationUnit unit) {
5686 if (cache != null && unit != null && cache.source == source) { 5880 if (cache != null && unit != null && cache.source == source) {
5687 if (!ASTComparator.equals3(cache.resolvedUnit, unit)) { 5881 if (!ASTComparator.equals3(cache.resolvedUnit, unit)) {
5688 return null; 5882 return null;
5689 } 5883 }
5690 } 5884 }
5691 return cache; 5885 return cache;
5692 } 5886 }
5887
5693 Source librarySource; 5888 Source librarySource;
5889
5694 Source source; 5890 Source source;
5891
5695 String oldContents; 5892 String oldContents;
5893
5696 CompilationUnit resolvedUnit; 5894 CompilationUnit resolvedUnit;
5895
5697 String newContents; 5896 String newContents;
5897
5698 int offset = 0; 5898 int offset = 0;
5899
5699 int oldLength = 0; 5900 int oldLength = 0;
5901
5700 int newLength = 0; 5902 int newLength = 0;
5903
5701 IncrementalAnalysisCache(Source librarySource, Source source, CompilationUnit resolvedUnit, String oldContents, String newContents, int offset, int oldLength, int newLength) { 5904 IncrementalAnalysisCache(Source librarySource, Source source, CompilationUnit resolvedUnit, String oldContents, String newContents, int offset, int oldLength, int newLength) {
5702 this.librarySource = librarySource; 5905 this.librarySource = librarySource;
5703 this.source = source; 5906 this.source = source;
5704 this.resolvedUnit = resolvedUnit; 5907 this.resolvedUnit = resolvedUnit;
5705 this.oldContents = oldContents; 5908 this.oldContents = oldContents;
5706 this.newContents = newContents; 5909 this.newContents = newContents;
5707 this.offset = offset; 5910 this.offset = offset;
5708 this.oldLength = oldLength; 5911 this.oldLength = oldLength;
5709 this.newLength = newLength; 5912 this.newLength = newLength;
5710 } 5913 }
5711 5914
5712 /** 5915 /**
5713 * Determine if the cache contains source changes that need to be analyzed 5916 * Determine if the cache contains source changes that need to be analyzed
5714 * 5917 *
5715 * @return `true` if the cache contains changes to be analyzed, else `false` 5918 * @return `true` if the cache contains changes to be analyzed, else `false`
5716 */ 5919 */
5717 bool hasWork() => oldLength > 0 && newLength > 0; 5920 bool hasWork() => oldLength > 0 || newLength > 0;
5718 } 5921 }
5922
5719 /** 5923 /**
5720 * Instances of the class `InstrumentedAnalysisContextImpl` implement an 5924 * Instances of the class `InstrumentedAnalysisContextImpl` implement an
5721 * [AnalysisContext] by recording instrumentation data and delegating to 5925 * [AnalysisContext] by recording instrumentation data and delegating to
5722 * another analysis context to do the non-instrumentation work. 5926 * another analysis context to do the non-instrumentation work.
5723 * 5927 *
5724 * @coverage dart.engine 5928 * @coverage dart.engine
5725 */ 5929 */
5726 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { 5930 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext {
5727
5728 /** 5931 /**
5729 * Record an exception that was thrown during analysis. 5932 * Record an exception that was thrown during analysis.
5730 * 5933 *
5731 * @param instrumentation the instrumentation builder being used to record the exception 5934 * @param instrumentation the instrumentation builder being used to record the exception
5732 * @param exception the exception being reported 5935 * @param exception the exception being reported
5733 */ 5936 */
5734 static void recordAnalysisException(InstrumentationBuilder instrumentation, An alysisException exception) { 5937 static void recordAnalysisException(InstrumentationBuilder instrumentation, An alysisException exception) {
5735 instrumentation.record(exception); 5938 instrumentation.record(exception);
5736 } 5939 }
5737 5940
(...skipping 15 matching lines...) Expand all
5753 5956
5754 /** 5957 /**
5755 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte xt, aka the 5958 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte xt, aka the
5756 * context to wrap and instrument. 5959 * context to wrap and instrument.
5757 * 5960 *
5758 * @param context some [InstrumentedAnalysisContext] to wrap and instrument 5961 * @param context some [InstrumentedAnalysisContext] to wrap and instrument
5759 */ 5962 */
5760 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { 5963 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) {
5761 basis = context; 5964 basis = context;
5762 } 5965 }
5966
5763 void addSourceInfo(Source source, SourceEntry info) { 5967 void addSourceInfo(Source source, SourceEntry info) {
5764 basis.addSourceInfo(source, info); 5968 basis.addSourceInfo(source, info);
5765 } 5969 }
5970
5766 void applyChanges(ChangeSet changeSet) { 5971 void applyChanges(ChangeSet changeSet) {
5767 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- applyChanges"); 5972 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- applyChanges");
5768 try { 5973 try {
5769 instrumentation.metric3("contextId", _contextId); 5974 instrumentation.metric3("contextId", _contextId);
5770 basis.applyChanges(changeSet); 5975 basis.applyChanges(changeSet);
5771 } finally { 5976 } finally {
5772 instrumentation.log(); 5977 instrumentation.log();
5773 } 5978 }
5774 } 5979 }
5980
5775 String computeDocumentationComment(Element element) { 5981 String computeDocumentationComment(Element element) {
5776 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeDocumentationComment"); 5982 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeDocumentationComment");
5777 try { 5983 try {
5778 instrumentation.metric3("contextId", _contextId); 5984 instrumentation.metric3("contextId", _contextId);
5779 return basis.computeDocumentationComment(element); 5985 return basis.computeDocumentationComment(element);
5780 } finally { 5986 } finally {
5781 instrumentation.log(); 5987 instrumentation.log();
5782 } 5988 }
5783 } 5989 }
5990
5784 List<AnalysisError> computeErrors(Source source) { 5991 List<AnalysisError> computeErrors(Source source) {
5785 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeErrors"); 5992 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeErrors");
5786 try { 5993 try {
5787 instrumentation.metric3("contextId", _contextId); 5994 instrumentation.metric3("contextId", _contextId);
5788 List<AnalysisError> errors = basis.computeErrors(source); 5995 List<AnalysisError> errors = basis.computeErrors(source);
5789 instrumentation.metric2("Errors-count", errors.length); 5996 instrumentation.metric2("Errors-count", errors.length);
5790 return errors; 5997 return errors;
5791 } finally { 5998 } finally {
5792 instrumentation.log(); 5999 instrumentation.log();
5793 } 6000 }
5794 } 6001 }
6002
5795 List<Source> computeExportedLibraries(Source source) { 6003 List<Source> computeExportedLibraries(Source source) {
5796 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeExportedLibraries"); 6004 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeExportedLibraries");
5797 try { 6005 try {
5798 instrumentation.metric3("contextId", _contextId); 6006 instrumentation.metric3("contextId", _contextId);
5799 return basis.computeExportedLibraries(source); 6007 return basis.computeExportedLibraries(source);
5800 } finally { 6008 } finally {
5801 instrumentation.log(); 6009 instrumentation.log();
5802 } 6010 }
5803 } 6011 }
6012
5804 HtmlElement computeHtmlElement(Source source) { 6013 HtmlElement computeHtmlElement(Source source) {
5805 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeHtmlElement"); 6014 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeHtmlElement");
5806 try { 6015 try {
5807 instrumentation.metric3("contextId", _contextId); 6016 instrumentation.metric3("contextId", _contextId);
5808 return basis.computeHtmlElement(source); 6017 return basis.computeHtmlElement(source);
5809 } on AnalysisException catch (e) { 6018 } on AnalysisException catch (e) {
5810 recordAnalysisException(instrumentation, e); 6019 recordAnalysisException(instrumentation, e);
5811 throw e; 6020 throw e;
5812 } finally { 6021 } finally {
5813 instrumentation.log(); 6022 instrumentation.log();
5814 } 6023 }
5815 } 6024 }
6025
5816 List<Source> computeImportedLibraries(Source source) { 6026 List<Source> computeImportedLibraries(Source source) {
5817 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeImportedLibraries"); 6027 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeImportedLibraries");
5818 try { 6028 try {
5819 instrumentation.metric3("contextId", _contextId); 6029 instrumentation.metric3("contextId", _contextId);
5820 return basis.computeImportedLibraries(source); 6030 return basis.computeImportedLibraries(source);
5821 } finally { 6031 } finally {
5822 instrumentation.log(); 6032 instrumentation.log();
5823 } 6033 }
5824 } 6034 }
6035
5825 SourceKind computeKindOf(Source source) { 6036 SourceKind computeKindOf(Source source) {
5826 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeKindOf"); 6037 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeKindOf");
5827 try { 6038 try {
5828 instrumentation.metric3("contextId", _contextId); 6039 instrumentation.metric3("contextId", _contextId);
5829 return basis.computeKindOf(source); 6040 return basis.computeKindOf(source);
5830 } finally { 6041 } finally {
5831 instrumentation.log(); 6042 instrumentation.log();
5832 } 6043 }
5833 } 6044 }
6045
5834 LibraryElement computeLibraryElement(Source source) { 6046 LibraryElement computeLibraryElement(Source source) {
5835 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeLibraryElement"); 6047 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeLibraryElement");
5836 try { 6048 try {
5837 instrumentation.metric3("contextId", _contextId); 6049 instrumentation.metric3("contextId", _contextId);
5838 return basis.computeLibraryElement(source); 6050 return basis.computeLibraryElement(source);
5839 } on AnalysisException catch (e) { 6051 } on AnalysisException catch (e) {
5840 recordAnalysisException(instrumentation, e); 6052 recordAnalysisException(instrumentation, e);
5841 throw e; 6053 throw e;
5842 } finally { 6054 } finally {
5843 instrumentation.log(); 6055 instrumentation.log();
5844 } 6056 }
5845 } 6057 }
6058
5846 LineInfo computeLineInfo(Source source) { 6059 LineInfo computeLineInfo(Source source) {
5847 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeLineInfo"); 6060 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- computeLineInfo");
5848 try { 6061 try {
5849 instrumentation.metric3("contextId", _contextId); 6062 instrumentation.metric3("contextId", _contextId);
5850 return basis.computeLineInfo(source); 6063 return basis.computeLineInfo(source);
5851 } on AnalysisException catch (e) { 6064 } on AnalysisException catch (e) {
5852 recordAnalysisException(instrumentation, e); 6065 recordAnalysisException(instrumentation, e);
5853 throw e; 6066 throw e;
5854 } finally { 6067 } finally {
5855 instrumentation.log(); 6068 instrumentation.log();
5856 } 6069 }
5857 } 6070 }
6071
5858 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => b asis.computeResolvableCompilationUnit(source); 6072 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => b asis.computeResolvableCompilationUnit(source);
6073
5859 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => basis.computeRe solvableHtmlUnit(source); 6074 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => basis.computeRe solvableHtmlUnit(source);
6075
5860 AnalysisContext extractContext(SourceContainer container) { 6076 AnalysisContext extractContext(SourceContainer container) {
5861 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- extractContext"); 6077 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- extractContext");
5862 try { 6078 try {
5863 instrumentation.metric3("contextId", _contextId); 6079 instrumentation.metric3("contextId", _contextId);
5864 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte xtImpl(); 6080 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte xtImpl();
5865 basis.extractContextInto(container, newContext.basis); 6081 basis.extractContextInto(container, newContext.basis);
5866 return newContext; 6082 return newContext;
5867 } finally { 6083 } finally {
5868 instrumentation.log(); 6084 instrumentation.log();
5869 } 6085 }
5870 } 6086 }
6087
5871 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => basis.extractContextInto(container, newContext); 6088 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => basis.extractContextInto(container, newContext);
6089
5872 AnalysisOptions get analysisOptions { 6090 AnalysisOptions get analysisOptions {
5873 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions"); 6091 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions");
5874 try { 6092 try {
5875 instrumentation.metric3("contextId", _contextId); 6093 instrumentation.metric3("contextId", _contextId);
5876 return basis.analysisOptions; 6094 return basis.analysisOptions;
5877 } finally { 6095 } finally {
5878 instrumentation.log(); 6096 instrumentation.log();
5879 } 6097 }
5880 } 6098 }
6099
5881 Element getElement(ElementLocation location) { 6100 Element getElement(ElementLocation location) {
5882 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getElement"); 6101 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getElement");
5883 try { 6102 try {
5884 instrumentation.metric3("contextId", _contextId); 6103 instrumentation.metric3("contextId", _contextId);
5885 return basis.getElement(location); 6104 return basis.getElement(location);
5886 } finally { 6105 } finally {
5887 instrumentation.log(); 6106 instrumentation.log();
5888 } 6107 }
5889 } 6108 }
6109
5890 AnalysisErrorInfo getErrors(Source source) { 6110 AnalysisErrorInfo getErrors(Source source) {
5891 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getErrors"); 6111 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getErrors");
5892 try { 6112 try {
5893 instrumentation.metric3("contextId", _contextId); 6113 instrumentation.metric3("contextId", _contextId);
5894 AnalysisErrorInfo ret = basis.getErrors(source); 6114 AnalysisErrorInfo ret = basis.getErrors(source);
5895 if (ret != null) { 6115 if (ret != null) {
5896 instrumentation.metric2("Errors-count", ret.errors.length); 6116 instrumentation.metric2("Errors-count", ret.errors.length);
5897 } 6117 }
5898 return ret; 6118 return ret;
5899 } finally { 6119 } finally {
5900 instrumentation.log(); 6120 instrumentation.log();
5901 } 6121 }
5902 } 6122 }
6123
5903 HtmlElement getHtmlElement(Source source) { 6124 HtmlElement getHtmlElement(Source source) {
5904 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getHtmlElement"); 6125 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getHtmlElement");
5905 try { 6126 try {
5906 instrumentation.metric3("contextId", _contextId); 6127 instrumentation.metric3("contextId", _contextId);
5907 return basis.getHtmlElement(source); 6128 return basis.getHtmlElement(source);
5908 } finally { 6129 } finally {
5909 instrumentation.log(); 6130 instrumentation.log();
5910 } 6131 }
5911 } 6132 }
6133
5912 List<Source> getHtmlFilesReferencing(Source source) { 6134 List<Source> getHtmlFilesReferencing(Source source) {
5913 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getHtmlFilesReferencing"); 6135 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getHtmlFilesReferencing");
5914 try { 6136 try {
5915 instrumentation.metric3("contextId", _contextId); 6137 instrumentation.metric3("contextId", _contextId);
5916 List<Source> ret = basis.getHtmlFilesReferencing(source); 6138 List<Source> ret = basis.getHtmlFilesReferencing(source);
5917 if (ret != null) { 6139 if (ret != null) {
5918 instrumentation.metric2("Source-count", ret.length); 6140 instrumentation.metric2("Source-count", ret.length);
5919 } 6141 }
5920 return ret; 6142 return ret;
5921 } finally { 6143 } finally {
5922 instrumentation.log(); 6144 instrumentation.log();
5923 } 6145 }
5924 } 6146 }
6147
5925 List<Source> get htmlSources { 6148 List<Source> get htmlSources {
5926 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getHtmlSources"); 6149 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getHtmlSources");
5927 try { 6150 try {
5928 instrumentation.metric3("contextId", _contextId); 6151 instrumentation.metric3("contextId", _contextId);
5929 List<Source> ret = basis.htmlSources; 6152 List<Source> ret = basis.htmlSources;
5930 if (ret != null) { 6153 if (ret != null) {
5931 instrumentation.metric2("Source-count", ret.length); 6154 instrumentation.metric2("Source-count", ret.length);
5932 } 6155 }
5933 return ret; 6156 return ret;
5934 } finally { 6157 } finally {
5935 instrumentation.log(); 6158 instrumentation.log();
5936 } 6159 }
5937 } 6160 }
6161
5938 SourceKind getKindOf(Source source) { 6162 SourceKind getKindOf(Source source) {
5939 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getKindOf"); 6163 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getKindOf");
5940 try { 6164 try {
5941 instrumentation.metric3("contextId", _contextId); 6165 instrumentation.metric3("contextId", _contextId);
5942 return basis.getKindOf(source); 6166 return basis.getKindOf(source);
5943 } finally { 6167 } finally {
5944 instrumentation.log(); 6168 instrumentation.log();
5945 } 6169 }
5946 } 6170 }
6171
5947 List<Source> get launchableClientLibrarySources { 6172 List<Source> get launchableClientLibrarySources {
5948 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLaunchableClientLibrarySources"); 6173 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLaunchableClientLibrarySources");
5949 try { 6174 try {
5950 instrumentation.metric3("contextId", _contextId); 6175 instrumentation.metric3("contextId", _contextId);
5951 List<Source> ret = basis.launchableClientLibrarySources; 6176 List<Source> ret = basis.launchableClientLibrarySources;
5952 if (ret != null) { 6177 if (ret != null) {
5953 instrumentation.metric2("Source-count", ret.length); 6178 instrumentation.metric2("Source-count", ret.length);
5954 } 6179 }
5955 return ret; 6180 return ret;
5956 } finally { 6181 } finally {
5957 instrumentation.log(); 6182 instrumentation.log();
5958 } 6183 }
5959 } 6184 }
6185
5960 List<Source> get launchableServerLibrarySources { 6186 List<Source> get launchableServerLibrarySources {
5961 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLaunchableServerLibrarySources"); 6187 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLaunchableServerLibrarySources");
5962 try { 6188 try {
5963 instrumentation.metric3("contextId", _contextId); 6189 instrumentation.metric3("contextId", _contextId);
5964 List<Source> ret = basis.launchableServerLibrarySources; 6190 List<Source> ret = basis.launchableServerLibrarySources;
5965 if (ret != null) { 6191 if (ret != null) {
5966 instrumentation.metric2("Source-count", ret.length); 6192 instrumentation.metric2("Source-count", ret.length);
5967 } 6193 }
5968 return ret; 6194 return ret;
5969 } finally { 6195 } finally {
5970 instrumentation.log(); 6196 instrumentation.log();
5971 } 6197 }
5972 } 6198 }
6199
5973 List<Source> getLibrariesContaining(Source source) { 6200 List<Source> getLibrariesContaining(Source source) {
5974 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesContaining"); 6201 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesContaining");
5975 try { 6202 try {
5976 instrumentation.metric3("contextId", _contextId); 6203 instrumentation.metric3("contextId", _contextId);
5977 List<Source> ret = basis.getLibrariesContaining(source); 6204 List<Source> ret = basis.getLibrariesContaining(source);
5978 if (ret != null) { 6205 if (ret != null) {
5979 instrumentation.metric2("Source-count", ret.length); 6206 instrumentation.metric2("Source-count", ret.length);
5980 } 6207 }
5981 return ret; 6208 return ret;
5982 } finally { 6209 } finally {
5983 instrumentation.log2(2); 6210 instrumentation.log2(2);
5984 } 6211 }
5985 } 6212 }
6213
5986 List<Source> getLibrariesDependingOn(Source librarySource) { 6214 List<Source> getLibrariesDependingOn(Source librarySource) {
5987 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesDependingOn"); 6215 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesDependingOn");
5988 try { 6216 try {
5989 instrumentation.metric3("contextId", _contextId); 6217 instrumentation.metric3("contextId", _contextId);
5990 List<Source> ret = basis.getLibrariesDependingOn(librarySource); 6218 List<Source> ret = basis.getLibrariesDependingOn(librarySource);
5991 if (ret != null) { 6219 if (ret != null) {
5992 instrumentation.metric2("Source-count", ret.length); 6220 instrumentation.metric2("Source-count", ret.length);
5993 } 6221 }
5994 return ret; 6222 return ret;
5995 } finally { 6223 } finally {
5996 instrumentation.log(); 6224 instrumentation.log();
5997 } 6225 }
5998 } 6226 }
6227
5999 LibraryElement getLibraryElement(Source source) { 6228 LibraryElement getLibraryElement(Source source) {
6000 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibraryElement"); 6229 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibraryElement");
6001 try { 6230 try {
6002 instrumentation.metric3("contextId", _contextId); 6231 instrumentation.metric3("contextId", _contextId);
6003 return basis.getLibraryElement(source); 6232 return basis.getLibraryElement(source);
6004 } finally { 6233 } finally {
6005 instrumentation.log(); 6234 instrumentation.log();
6006 } 6235 }
6007 } 6236 }
6237
6008 List<Source> get librarySources { 6238 List<Source> get librarySources {
6009 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrarySources"); 6239 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrarySources");
6010 try { 6240 try {
6011 instrumentation.metric3("contextId", _contextId); 6241 instrumentation.metric3("contextId", _contextId);
6012 List<Source> ret = basis.librarySources; 6242 List<Source> ret = basis.librarySources;
6013 if (ret != null) { 6243 if (ret != null) {
6014 instrumentation.metric2("Source-count", ret.length); 6244 instrumentation.metric2("Source-count", ret.length);
6015 } 6245 }
6016 return ret; 6246 return ret;
6017 } finally { 6247 } finally {
6018 instrumentation.log(); 6248 instrumentation.log();
6019 } 6249 }
6020 } 6250 }
6251
6021 LineInfo getLineInfo(Source source) { 6252 LineInfo getLineInfo(Source source) {
6022 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLineInfo"); 6253 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLineInfo");
6023 try { 6254 try {
6024 instrumentation.metric3("contextId", _contextId); 6255 instrumentation.metric3("contextId", _contextId);
6025 return basis.getLineInfo(source); 6256 return basis.getLineInfo(source);
6026 } finally { 6257 } finally {
6027 instrumentation.log(); 6258 instrumentation.log();
6028 } 6259 }
6029 } 6260 }
6261
6030 Namespace getPublicNamespace(LibraryElement library) => basis.getPublicNamespa ce(library); 6262 Namespace getPublicNamespace(LibraryElement library) => basis.getPublicNamespa ce(library);
6263
6031 Namespace getPublicNamespace2(Source source) => basis.getPublicNamespace2(sour ce); 6264 Namespace getPublicNamespace2(Source source) => basis.getPublicNamespace2(sour ce);
6265
6032 List<Source> get refactoringUnsafeSources => basis.refactoringUnsafeSources; 6266 List<Source> get refactoringUnsafeSources => basis.refactoringUnsafeSources;
6267
6033 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) { 6268 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) {
6034 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit"); 6269 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit");
6035 try { 6270 try {
6036 instrumentation.metric3("contextId", _contextId); 6271 instrumentation.metric3("contextId", _contextId);
6037 return basis.getResolvedCompilationUnit(unitSource, library); 6272 return basis.getResolvedCompilationUnit(unitSource, library);
6038 } finally { 6273 } finally {
6039 instrumentation.log(); 6274 instrumentation.log();
6040 } 6275 }
6041 } 6276 }
6277
6042 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) { 6278 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) {
6043 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit"); 6279 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit");
6044 try { 6280 try {
6045 instrumentation.metric3("contextId", _contextId); 6281 instrumentation.metric3("contextId", _contextId);
6046 return basis.getResolvedCompilationUnit2(unitSource, librarySource); 6282 return basis.getResolvedCompilationUnit2(unitSource, librarySource);
6047 } finally { 6283 } finally {
6048 instrumentation.log2(2); 6284 instrumentation.log2(2);
6049 } 6285 }
6050 } 6286 }
6287
6051 SourceFactory get sourceFactory { 6288 SourceFactory get sourceFactory {
6052 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getSourceFactory"); 6289 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getSourceFactory");
6053 try { 6290 try {
6054 instrumentation.metric3("contextId", _contextId); 6291 instrumentation.metric3("contextId", _contextId);
6055 return basis.sourceFactory; 6292 return basis.sourceFactory;
6056 } finally { 6293 } finally {
6057 instrumentation.log2(2); 6294 instrumentation.log2(2);
6058 } 6295 }
6059 } 6296 }
6297
6060 AnalysisContentStatistics get statistics => basis.statistics; 6298 AnalysisContentStatistics get statistics => basis.statistics;
6299
6061 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) => basis.internalResolveCompilationUnit(unit Source, libraryElement); 6300 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou rce, LibraryElement libraryElement) => basis.internalResolveCompilationUnit(unit Source, libraryElement);
6301
6062 bool isClientLibrary(Source librarySource) { 6302 bool isClientLibrary(Source librarySource) {
6063 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isClientLibrary"); 6303 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isClientLibrary");
6064 try { 6304 try {
6065 instrumentation.metric3("contextId", _contextId); 6305 instrumentation.metric3("contextId", _contextId);
6066 return basis.isClientLibrary(librarySource); 6306 return basis.isClientLibrary(librarySource);
6067 } finally { 6307 } finally {
6068 instrumentation.log(); 6308 instrumentation.log();
6069 } 6309 }
6070 } 6310 }
6311
6071 bool isServerLibrary(Source librarySource) { 6312 bool isServerLibrary(Source librarySource) {
6072 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isServerLibrary"); 6313 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isServerLibrary");
6073 try { 6314 try {
6074 instrumentation.metric3("contextId", _contextId); 6315 instrumentation.metric3("contextId", _contextId);
6075 return basis.isServerLibrary(librarySource); 6316 return basis.isServerLibrary(librarySource);
6076 } finally { 6317 } finally {
6077 instrumentation.log(); 6318 instrumentation.log();
6078 } 6319 }
6079 } 6320 }
6321
6080 void mergeContext(AnalysisContext context) { 6322 void mergeContext(AnalysisContext context) {
6081 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- mergeContext"); 6323 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- mergeContext");
6082 try { 6324 try {
6083 instrumentation.metric3("contextId", _contextId); 6325 instrumentation.metric3("contextId", _contextId);
6084 if (context is InstrumentedAnalysisContextImpl) { 6326 if (context is InstrumentedAnalysisContextImpl) {
6085 context = ((context as InstrumentedAnalysisContextImpl)).basis; 6327 context = (context as InstrumentedAnalysisContextImpl).basis;
6086 } 6328 }
6087 basis.mergeContext(context); 6329 basis.mergeContext(context);
6088 } finally { 6330 } finally {
6089 instrumentation.log(); 6331 instrumentation.log();
6090 } 6332 }
6091 } 6333 }
6334
6092 CompilationUnit parseCompilationUnit(Source source) { 6335 CompilationUnit parseCompilationUnit(Source source) {
6093 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- parseCompilationUnit"); 6336 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- parseCompilationUnit");
6094 try { 6337 try {
6095 instrumentation.metric3("contextId", _contextId); 6338 instrumentation.metric3("contextId", _contextId);
6096 return basis.parseCompilationUnit(source); 6339 return basis.parseCompilationUnit(source);
6097 } on AnalysisException catch (e) { 6340 } on AnalysisException catch (e) {
6098 recordAnalysisException(instrumentation, e); 6341 recordAnalysisException(instrumentation, e);
6099 throw e; 6342 throw e;
6100 } finally { 6343 } finally {
6101 instrumentation.log(); 6344 instrumentation.log();
6102 } 6345 }
6103 } 6346 }
6347
6104 HtmlUnit parseHtmlUnit(Source source) { 6348 HtmlUnit parseHtmlUnit(Source source) {
6105 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- parseHtmlUnit"); 6349 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- parseHtmlUnit");
6106 try { 6350 try {
6107 instrumentation.metric3("contextId", _contextId); 6351 instrumentation.metric3("contextId", _contextId);
6108 return basis.parseHtmlUnit(source); 6352 return basis.parseHtmlUnit(source);
6109 } on AnalysisException catch (e) { 6353 } on AnalysisException catch (e) {
6110 recordAnalysisException(instrumentation, e); 6354 recordAnalysisException(instrumentation, e);
6111 throw e; 6355 throw e;
6112 } finally { 6356 } finally {
6113 instrumentation.log(); 6357 instrumentation.log();
6114 } 6358 }
6115 } 6359 }
6360
6116 AnalysisResult performAnalysisTask() { 6361 AnalysisResult performAnalysisTask() {
6117 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- performAnalysisTask"); 6362 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- performAnalysisTask");
6118 try { 6363 try {
6119 instrumentation.metric3("contextId", _contextId); 6364 instrumentation.metric3("contextId", _contextId);
6120 AnalysisResult result = basis.performAnalysisTask(); 6365 AnalysisResult result = basis.performAnalysisTask();
6121 if (result.changeNotices != null) { 6366 if (result.changeNotices != null) {
6122 instrumentation.metric2("ChangeNotice-count", result.changeNotices.lengt h); 6367 instrumentation.metric2("ChangeNotice-count", result.changeNotices.lengt h);
6123 } 6368 }
6124 return result; 6369 return result;
6125 } finally { 6370 } finally {
6126 instrumentation.log2(2); 6371 instrumentation.log2(2);
6127 } 6372 }
6128 } 6373 }
6374
6129 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 6375 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
6130 basis.recordLibraryElements(elementMap); 6376 basis.recordLibraryElements(elementMap);
6131 } 6377 }
6378
6132 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) { 6379 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) {
6133 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveCompilationUnit"); 6380 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveCompilationUnit");
6134 try { 6381 try {
6135 instrumentation.metric3("contextId", _contextId); 6382 instrumentation.metric3("contextId", _contextId);
6136 return basis.resolveCompilationUnit(unitSource, library); 6383 return basis.resolveCompilationUnit(unitSource, library);
6137 } on AnalysisException catch (e) { 6384 } on AnalysisException catch (e) {
6138 recordAnalysisException(instrumentation, e); 6385 recordAnalysisException(instrumentation, e);
6139 throw e; 6386 throw e;
6140 } finally { 6387 } finally {
6141 instrumentation.log(); 6388 instrumentation.log();
6142 } 6389 }
6143 } 6390 }
6391
6144 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e) { 6392 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc e) {
6145 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveCompilationUnit"); 6393 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveCompilationUnit");
6146 try { 6394 try {
6147 instrumentation.metric3("contextId", _contextId); 6395 instrumentation.metric3("contextId", _contextId);
6148 return basis.resolveCompilationUnit2(unitSource, librarySource); 6396 return basis.resolveCompilationUnit2(unitSource, librarySource);
6149 } on AnalysisException catch (e) { 6397 } on AnalysisException catch (e) {
6150 recordAnalysisException(instrumentation, e); 6398 recordAnalysisException(instrumentation, e);
6151 throw e; 6399 throw e;
6152 } finally { 6400 } finally {
6153 instrumentation.log(); 6401 instrumentation.log();
6154 } 6402 }
6155 } 6403 }
6404
6156 HtmlUnit resolveHtmlUnit(Source htmlSource) { 6405 HtmlUnit resolveHtmlUnit(Source htmlSource) {
6157 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveHtmlUnit"); 6406 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveHtmlUnit");
6158 try { 6407 try {
6159 instrumentation.metric3("contextId", _contextId); 6408 instrumentation.metric3("contextId", _contextId);
6160 return basis.resolveHtmlUnit(htmlSource); 6409 return basis.resolveHtmlUnit(htmlSource);
6161 } on AnalysisException catch (e) { 6410 } on AnalysisException catch (e) {
6162 recordAnalysisException(instrumentation, e); 6411 recordAnalysisException(instrumentation, e);
6163 throw e; 6412 throw e;
6164 } finally { 6413 } finally {
6165 instrumentation.log(); 6414 instrumentation.log();
6166 } 6415 }
6167 } 6416 }
6417
6168 void set analysisOptions(AnalysisOptions options) { 6418 void set analysisOptions(AnalysisOptions options) {
6169 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setAnalysisOptions"); 6419 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setAnalysisOptions");
6170 try { 6420 try {
6171 instrumentation.metric3("contextId", _contextId); 6421 instrumentation.metric3("contextId", _contextId);
6172 basis.analysisOptions = options; 6422 basis.analysisOptions = options;
6173 } finally { 6423 } finally {
6174 instrumentation.log(); 6424 instrumentation.log();
6175 } 6425 }
6176 } 6426 }
6427
6177 void set analysisPriorityOrder(List<Source> sources) { 6428 void set analysisPriorityOrder(List<Source> sources) {
6178 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setAnalysisPriorityOrder"); 6429 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setAnalysisPriorityOrder");
6179 try { 6430 try {
6180 instrumentation.metric3("contextId", _contextId); 6431 instrumentation.metric3("contextId", _contextId);
6181 basis.analysisPriorityOrder = sources; 6432 basis.analysisPriorityOrder = sources;
6182 } finally { 6433 } finally {
6183 instrumentation.log(); 6434 instrumentation.log();
6184 } 6435 }
6185 } 6436 }
6437
6186 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 6438 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
6187 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setChangedContents"); 6439 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setChangedContents");
6188 try { 6440 try {
6189 instrumentation.metric3("contextId", _contextId); 6441 instrumentation.metric3("contextId", _contextId);
6190 basis.setChangedContents(source, contents, offset, oldLength, newLength); 6442 basis.setChangedContents(source, contents, offset, oldLength, newLength);
6191 } finally { 6443 } finally {
6192 instrumentation.log(); 6444 instrumentation.log();
6193 } 6445 }
6194 } 6446 }
6447
6195 void setContents(Source source, String contents) { 6448 void setContents(Source source, String contents) {
6196 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setContents"); 6449 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setContents");
6197 try { 6450 try {
6198 instrumentation.metric3("contextId", _contextId); 6451 instrumentation.metric3("contextId", _contextId);
6199 basis.setContents(source, contents); 6452 basis.setContents(source, contents);
6200 } finally { 6453 } finally {
6201 instrumentation.log(); 6454 instrumentation.log();
6202 } 6455 }
6203 } 6456 }
6457
6204 void set sourceFactory(SourceFactory factory) { 6458 void set sourceFactory(SourceFactory factory) {
6205 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setSourceFactory"); 6459 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setSourceFactory");
6206 try { 6460 try {
6207 instrumentation.metric3("contextId", _contextId); 6461 instrumentation.metric3("contextId", _contextId);
6208 basis.sourceFactory = factory; 6462 basis.sourceFactory = factory;
6209 } finally { 6463 } finally {
6210 instrumentation.log(); 6464 instrumentation.log();
6211 } 6465 }
6212 } 6466 }
6467
6213 Iterable<Source> sourcesToResolve(List<Source> changedSources) { 6468 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
6214 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- sourcesToResolve"); 6469 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- sourcesToResolve");
6215 try { 6470 try {
6216 instrumentation.metric3("contextId", _contextId); 6471 instrumentation.metric3("contextId", _contextId);
6217 return basis.sourcesToResolve(changedSources); 6472 return basis.sourcesToResolve(changedSources);
6218 } finally { 6473 } finally {
6219 instrumentation.log(); 6474 instrumentation.log();
6220 } 6475 }
6221 } 6476 }
6222 } 6477 }
6478
6223 /** 6479 /**
6224 * The interface `InternalAnalysisContext` defines additional behavior for an an alysis context 6480 * The interface `InternalAnalysisContext` defines additional behavior for an an alysis context
6225 * that is required by internal users of the context. 6481 * that is required by internal users of the context.
6226 */ 6482 */
6227 abstract class InternalAnalysisContext implements AnalysisContext { 6483 abstract class InternalAnalysisContext implements AnalysisContext {
6228
6229 /** 6484 /**
6230 * Add the given source with the given information to this context. 6485 * Add the given source with the given information to this context.
6231 * 6486 *
6232 * @param source the source to be added 6487 * @param source the source to be added
6233 * @param info the information about the source 6488 * @param info the information about the source
6234 */ 6489 */
6235 void addSourceInfo(Source source, SourceEntry info); 6490 void addSourceInfo(Source source, SourceEntry info);
6236 6491
6237 /** 6492 /**
6238 * Return an array containing the sources of the libraries that are exported b y the library with 6493 * Return an array containing the sources of the libraries that are exported b y the library with
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
6327 6582
6328 /** 6583 /**
6329 * Given a table mapping the source for the libraries represented by the corre sponding elements to 6584 * Given a table mapping the source for the libraries represented by the corre sponding elements to
6330 * the elements representing the libraries, record those mappings. 6585 * the elements representing the libraries, record those mappings.
6331 * 6586 *
6332 * @param elementMap a table mapping the source for the libraries represented by the elements to 6587 * @param elementMap a table mapping the source for the libraries represented by the elements to
6333 * the elements representing the libraries 6588 * the elements representing the libraries
6334 */ 6589 */
6335 void recordLibraryElements(Map<Source, LibraryElement> elementMap); 6590 void recordLibraryElements(Map<Source, LibraryElement> elementMap);
6336 } 6591 }
6592
6337 /** 6593 /**
6338 * Container with global [AnalysisContext] performance statistics. 6594 * Container with global [AnalysisContext] performance statistics.
6339 */ 6595 */
6340 class PerformanceStatistics { 6596 class PerformanceStatistics {
6341
6342 /** 6597 /**
6343 * The [TimeCounter] for time spent in scanning. 6598 * The [TimeCounter] for time spent in scanning.
6344 */ 6599 */
6345 static TimeCounter scan = new TimeCounter(); 6600 static TimeCounter scan = new TimeCounter();
6346 6601
6347 /** 6602 /**
6348 * The [TimeCounter] for time spent in parsing. 6603 * The [TimeCounter] for time spent in parsing.
6349 */ 6604 */
6350 static TimeCounter parse = new TimeCounter(); 6605 static TimeCounter parse = new TimeCounter();
6351 6606
6352 /** 6607 /**
6353 * The [TimeCounter] for time spent in resolving. 6608 * The [TimeCounter] for time spent in resolving.
6354 */ 6609 */
6355 static TimeCounter resolve = new TimeCounter(); 6610 static TimeCounter resolve = new TimeCounter();
6356 6611
6357 /** 6612 /**
6358 * The [TimeCounter] for time spent in error verifier. 6613 * The [TimeCounter] for time spent in error verifier.
6359 */ 6614 */
6360 static TimeCounter errors = new TimeCounter(); 6615 static TimeCounter errors = new TimeCounter();
6361 6616
6362 /** 6617 /**
6363 * The [TimeCounter] for time spent in hints generator. 6618 * The [TimeCounter] for time spent in hints generator.
6364 */ 6619 */
6365 static TimeCounter hints = new TimeCounter(); 6620 static TimeCounter hints = new TimeCounter();
6366 } 6621 }
6622
6367 /** 6623 /**
6368 * Instances of the class `RecordingErrorListener` implement an error listener t hat will 6624 * Instances of the class `RecordingErrorListener` implement an error listener t hat will
6369 * record the errors that are reported to it in a way that is appropriate for ca ching those errors 6625 * record the errors that are reported to it in a way that is appropriate for ca ching those errors
6370 * within an analysis context. 6626 * within an analysis context.
6371 * 6627 *
6372 * @coverage dart.engine 6628 * @coverage dart.engine
6373 */ 6629 */
6374 class RecordingErrorListener implements AnalysisErrorListener { 6630 class RecordingErrorListener implements AnalysisErrorListener {
6375
6376 /** 6631 /**
6377 * A HashMap of lists containing the errors that were collected, keyed by each [Source]. 6632 * A HashMap of lists containing the errors that were collected, keyed by each [Source].
6378 */ 6633 */
6379 Map<Source, Set<AnalysisError>> _errors = new Map<Source, Set<AnalysisError>>( ); 6634 Map<Source, Set<AnalysisError>> _errors = new Map<Source, Set<AnalysisError>>( );
6380 6635
6381 /** 6636 /**
6382 * Add all of the errors recorded by the given listener to this listener. 6637 * Add all of the errors recorded by the given listener to this listener.
6383 * 6638 *
6384 * @param listener the listener that has recorded the errors to be added 6639 * @param listener the listener that has recorded the errors to be added
6385 */ 6640 */
(...skipping 29 matching lines...) Expand all
6415 * @return the errors collected by the listener for the passed [Source] 6670 * @return the errors collected by the listener for the passed [Source]
6416 */ 6671 */
6417 List<AnalysisError> getErrors2(Source source) { 6672 List<AnalysisError> getErrors2(Source source) {
6418 Set<AnalysisError> errorsForSource = _errors[source]; 6673 Set<AnalysisError> errorsForSource = _errors[source];
6419 if (errorsForSource == null) { 6674 if (errorsForSource == null) {
6420 return AnalysisError.NO_ERRORS; 6675 return AnalysisError.NO_ERRORS;
6421 } else { 6676 } else {
6422 return new List.from(errorsForSource); 6677 return new List.from(errorsForSource);
6423 } 6678 }
6424 } 6679 }
6680
6425 void onError(AnalysisError error) { 6681 void onError(AnalysisError error) {
6426 Source source = error.source; 6682 Source source = error.source;
6427 Set<AnalysisError> errorsForSource = _errors[source]; 6683 Set<AnalysisError> errorsForSource = _errors[source];
6428 if (_errors[source] == null) { 6684 if (_errors[source] == null) {
6429 errorsForSource = new Set<AnalysisError>(); 6685 errorsForSource = new Set<AnalysisError>();
6430 _errors[source] = errorsForSource; 6686 _errors[source] = errorsForSource;
6431 } 6687 }
6432 javaSetAdd(errorsForSource, error); 6688 javaSetAdd(errorsForSource, error);
6433 } 6689 }
6434 } 6690 }
6691
6435 /** 6692 /**
6436 * Instances of the class `ResolutionEraser` remove any resolution information f rom an AST 6693 * Instances of the class `ResolutionEraser` remove any resolution information f rom an AST
6437 * structure when used to visit that structure. 6694 * structure when used to visit that structure.
6438 */ 6695 */
6439 class ResolutionEraser extends GeneralizingASTVisitor<Object> { 6696 class ResolutionEraser extends GeneralizingASTVisitor<Object> {
6440 Object visitAssignmentExpression(AssignmentExpression node) { 6697 Object visitAssignmentExpression(AssignmentExpression node) {
6441 node.staticElement = null; 6698 node.staticElement = null;
6442 node.propagatedElement = null; 6699 node.propagatedElement = null;
6443 return super.visitAssignmentExpression(node); 6700 return super.visitAssignmentExpression(node);
6444 } 6701 }
6702
6445 Object visitBinaryExpression(BinaryExpression node) { 6703 Object visitBinaryExpression(BinaryExpression node) {
6446 node.staticElement = null; 6704 node.staticElement = null;
6447 node.propagatedElement = null; 6705 node.propagatedElement = null;
6448 return super.visitBinaryExpression(node); 6706 return super.visitBinaryExpression(node);
6449 } 6707 }
6708
6450 Object visitCompilationUnit(CompilationUnit node) { 6709 Object visitCompilationUnit(CompilationUnit node) {
6451 node.element = null; 6710 node.element = null;
6452 return super.visitCompilationUnit(node); 6711 return super.visitCompilationUnit(node);
6453 } 6712 }
6713
6454 Object visitConstructorDeclaration(ConstructorDeclaration node) { 6714 Object visitConstructorDeclaration(ConstructorDeclaration node) {
6455 node.element = null; 6715 node.element = null;
6456 return super.visitConstructorDeclaration(node); 6716 return super.visitConstructorDeclaration(node);
6457 } 6717 }
6718
6458 Object visitConstructorName(ConstructorName node) { 6719 Object visitConstructorName(ConstructorName node) {
6459 node.staticElement = null; 6720 node.staticElement = null;
6460 return super.visitConstructorName(node); 6721 return super.visitConstructorName(node);
6461 } 6722 }
6723
6462 Object visitDirective(Directive node) { 6724 Object visitDirective(Directive node) {
6463 node.element = null; 6725 node.element = null;
6464 return super.visitDirective(node); 6726 return super.visitDirective(node);
6465 } 6727 }
6728
6466 Object visitExpression(Expression node) { 6729 Object visitExpression(Expression node) {
6467 node.staticType = null; 6730 node.staticType = null;
6468 node.propagatedType = null; 6731 node.propagatedType = null;
6469 return super.visitExpression(node); 6732 return super.visitExpression(node);
6470 } 6733 }
6734
6471 Object visitFunctionExpression(FunctionExpression node) { 6735 Object visitFunctionExpression(FunctionExpression node) {
6472 node.element = null; 6736 node.element = null;
6473 return super.visitFunctionExpression(node); 6737 return super.visitFunctionExpression(node);
6474 } 6738 }
6739
6475 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 6740 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
6476 node.staticElement = null; 6741 node.staticElement = null;
6477 node.propagatedElement = null; 6742 node.propagatedElement = null;
6478 return super.visitFunctionExpressionInvocation(node); 6743 return super.visitFunctionExpressionInvocation(node);
6479 } 6744 }
6745
6480 Object visitIndexExpression(IndexExpression node) { 6746 Object visitIndexExpression(IndexExpression node) {
6481 node.staticElement = null; 6747 node.staticElement = null;
6482 node.propagatedElement = null; 6748 node.propagatedElement = null;
6483 return super.visitIndexExpression(node); 6749 return super.visitIndexExpression(node);
6484 } 6750 }
6751
6485 Object visitInstanceCreationExpression(InstanceCreationExpression node) { 6752 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
6486 node.staticElement = null; 6753 node.staticElement = null;
6487 return super.visitInstanceCreationExpression(node); 6754 return super.visitInstanceCreationExpression(node);
6488 } 6755 }
6756
6489 Object visitPostfixExpression(PostfixExpression node) { 6757 Object visitPostfixExpression(PostfixExpression node) {
6490 node.staticElement = null; 6758 node.staticElement = null;
6491 node.propagatedElement = null; 6759 node.propagatedElement = null;
6492 return super.visitPostfixExpression(node); 6760 return super.visitPostfixExpression(node);
6493 } 6761 }
6762
6494 Object visitPrefixExpression(PrefixExpression node) { 6763 Object visitPrefixExpression(PrefixExpression node) {
6495 node.staticElement = null; 6764 node.staticElement = null;
6496 node.propagatedElement = null; 6765 node.propagatedElement = null;
6497 return super.visitPrefixExpression(node); 6766 return super.visitPrefixExpression(node);
6498 } 6767 }
6768
6499 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { 6769 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
6500 node.staticElement = null; 6770 node.staticElement = null;
6501 return super.visitRedirectingConstructorInvocation(node); 6771 return super.visitRedirectingConstructorInvocation(node);
6502 } 6772 }
6773
6503 Object visitSimpleIdentifier(SimpleIdentifier node) { 6774 Object visitSimpleIdentifier(SimpleIdentifier node) {
6504 node.staticElement = null; 6775 node.staticElement = null;
6505 node.propagatedElement = null; 6776 node.propagatedElement = null;
6506 return super.visitSimpleIdentifier(node); 6777 return super.visitSimpleIdentifier(node);
6507 } 6778 }
6779
6508 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 6780 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
6509 node.staticElement = null; 6781 node.staticElement = null;
6510 return super.visitSuperConstructorInvocation(node); 6782 return super.visitSuperConstructorInvocation(node);
6511 } 6783 }
6512 } 6784 }
6785
6513 /** 6786 /**
6514 * Instances of the class `ResolvableCompilationUnit` represent a compilation un it that is not 6787 * Instances of the class `ResolvableCompilationUnit` represent a compilation un it that is not
6515 * referenced by any other objects and for which we have modification stamp info rmation. It is used 6788 * referenced by any other objects and for which we have modification stamp info rmation. It is used
6516 * by the [LibraryResolver] to resolve a library. 6789 * by the [LibraryResolver] to resolve a library.
6517 */ 6790 */
6518 class ResolvableCompilationUnit extends TimestampedData<CompilationUnit> { 6791 class ResolvableCompilationUnit extends TimestampedData<CompilationUnit> {
6519
6520 /** 6792 /**
6521 * Initialize a newly created holder to hold the given values. 6793 * Initialize a newly created holder to hold the given values.
6522 * 6794 *
6523 * @param modificationTime the modification time of the source from which the AST was created 6795 * @param modificationTime the modification time of the source from which the AST was created
6524 * @param unit the AST that was created from the source 6796 * @param unit the AST that was created from the source
6525 */ 6797 */
6526 ResolvableCompilationUnit(int modificationTime, CompilationUnit unit) : super( modificationTime, unit); 6798 ResolvableCompilationUnit(int modificationTime, CompilationUnit unit) : super( modificationTime, unit);
6527 6799
6528 /** 6800 /**
6529 * Return the AST that was created from the source. 6801 * Return the AST that was created from the source.
6530 * 6802 *
6531 * @return the AST that was created from the source 6803 * @return the AST that was created from the source
6532 */ 6804 */
6533 CompilationUnit get compilationUnit => data; 6805 CompilationUnit get compilationUnit => data;
6534 } 6806 }
6807
6535 /** 6808 /**
6536 * Instances of the class `ResolvableHtmlUnit` represent an HTML unit that is no t referenced 6809 * Instances of the class `ResolvableHtmlUnit` represent an HTML unit that is no t referenced
6537 * by any other objects and for which we have modification stamp information. It is used by the 6810 * by any other objects and for which we have modification stamp information. It is used by the
6538 * [ResolveHtmlTask] to resolve an HTML source. 6811 * [ResolveHtmlTask] to resolve an HTML source.
6539 */ 6812 */
6540 class ResolvableHtmlUnit extends TimestampedData<HtmlUnit> { 6813 class ResolvableHtmlUnit extends TimestampedData<HtmlUnit> {
6541
6542 /** 6814 /**
6543 * Initialize a newly created holder to hold the given values. 6815 * Initialize a newly created holder to hold the given values.
6544 * 6816 *
6545 * @param modificationTime the modification time of the source from which the AST was created 6817 * @param modificationTime the modification time of the source from which the AST was created
6546 * @param unit the AST that was created from the source 6818 * @param unit the AST that was created from the source
6547 */ 6819 */
6548 ResolvableHtmlUnit(int modificationTime, HtmlUnit unit) : super(modificationTi me, unit); 6820 ResolvableHtmlUnit(int modificationTime, HtmlUnit unit) : super(modificationTi me, unit);
6549 6821
6550 /** 6822 /**
6551 * Return the AST that was created from the source. 6823 * Return the AST that was created from the source.
6552 * 6824 *
6553 * @return the AST that was created from the source 6825 * @return the AST that was created from the source
6554 */ 6826 */
6555 HtmlUnit get compilationUnit => data; 6827 HtmlUnit get compilationUnit => data;
6556 } 6828 }
6829
6557 /** 6830 /**
6558 * Instances of the class `TimestampedData` represent analysis data for which we have a 6831 * Instances of the class `TimestampedData` represent analysis data for which we have a
6559 * modification time. 6832 * modification time.
6560 */ 6833 */
6561 class TimestampedData<E> { 6834 class TimestampedData<E> {
6562
6563 /** 6835 /**
6564 * The modification time of the source from which the data was created. 6836 * The modification time of the source from which the data was created.
6565 */ 6837 */
6566 int modificationTime = 0; 6838 int modificationTime = 0;
6567 6839
6568 /** 6840 /**
6569 * The data that was created from the source. 6841 * The data that was created from the source.
6570 */ 6842 */
6571 E data; 6843 E data;
6572 6844
6573 /** 6845 /**
6574 * Initialize a newly created holder to hold the given values. 6846 * Initialize a newly created holder to hold the given values.
6575 * 6847 *
6576 * @param modificationTime the modification time of the source from which the data was created 6848 * @param modificationTime the modification time of the source from which the data was created
6577 * @param unit the data that was created from the source 6849 * @param unit the data that was created from the source
6578 */ 6850 */
6579 TimestampedData(int modificationTime, E data) { 6851 TimestampedData(int modificationTime, E data) {
6580 this.modificationTime = modificationTime; 6852 this.modificationTime = modificationTime;
6581 this.data = data; 6853 this.data = data;
6582 } 6854 }
6583 } 6855 }
6856
6584 /** 6857 /**
6585 * The abstract class `AnalysisTask` defines the behavior of objects used to per form an 6858 * The abstract class `AnalysisTask` defines the behavior of objects used to per form an
6586 * analysis task. 6859 * analysis task.
6587 */ 6860 */
6588 abstract class AnalysisTask { 6861 abstract class AnalysisTask {
6589
6590 /** 6862 /**
6591 * The context in which the task is to be performed. 6863 * The context in which the task is to be performed.
6592 */ 6864 */
6593 InternalAnalysisContext context; 6865 InternalAnalysisContext context;
6594 6866
6595 /** 6867 /**
6596 * The exception that was thrown while performing this task, or `null` if the task completed 6868 * The exception that was thrown while performing this task, or `null` if the task completed
6597 * successfully. 6869 * successfully.
6598 */ 6870 */
6599 AnalysisException exception; 6871 AnalysisException exception;
(...skipping 25 matching lines...) Expand all
6625 */ 6897 */
6626 Object perform(AnalysisTaskVisitor visitor) { 6898 Object perform(AnalysisTaskVisitor visitor) {
6627 try { 6899 try {
6628 safelyPerform(); 6900 safelyPerform();
6629 } on AnalysisException catch (exception) { 6901 } on AnalysisException catch (exception) {
6630 this.exception = exception; 6902 this.exception = exception;
6631 AnalysisEngine.instance.logger.logInformation2("Task failed: ${taskDescrip tion}", exception); 6903 AnalysisEngine.instance.logger.logInformation2("Task failed: ${taskDescrip tion}", exception);
6632 } 6904 }
6633 return accept(visitor); 6905 return accept(visitor);
6634 } 6906 }
6907
6635 String toString() => taskDescription; 6908 String toString() => taskDescription;
6636 6909
6637 /** 6910 /**
6638 * Return a textual description of this task. 6911 * Return a textual description of this task.
6639 * 6912 *
6640 * @return a textual description of this task 6913 * @return a textual description of this task
6641 */ 6914 */
6642 String get taskDescription; 6915 String get taskDescription;
6643 6916
6644 /** 6917 /**
(...skipping 12 matching lines...) Expand all
6657 void safelyPerform() { 6930 void safelyPerform() {
6658 try { 6931 try {
6659 internalPerform(); 6932 internalPerform();
6660 } on AnalysisException catch (exception) { 6933 } on AnalysisException catch (exception) {
6661 throw exception; 6934 throw exception;
6662 } on JavaException catch (exception) { 6935 } on JavaException catch (exception) {
6663 throw new AnalysisException.con3(exception); 6936 throw new AnalysisException.con3(exception);
6664 } 6937 }
6665 } 6938 }
6666 } 6939 }
6940
6667 /** 6941 /**
6668 * The interface `AnalysisTaskVisitor` defines the behavior of objects that can visit tasks. 6942 * The interface `AnalysisTaskVisitor` defines the behavior of objects that can visit tasks.
6669 * While tasks are not structured in any interesting way, this class provides th e ability to 6943 * While tasks are not structured in any interesting way, this class provides th e ability to
6670 * dispatch to an appropriate method. 6944 * dispatch to an appropriate method.
6671 */ 6945 */
6672 abstract class AnalysisTaskVisitor<E> { 6946 abstract class AnalysisTaskVisitor<E> {
6673
6674 /** 6947 /**
6675 * Visit a [GenerateDartErrorsTask]. 6948 * Visit a [GenerateDartErrorsTask].
6676 * 6949 *
6677 * @param task the task to be visited 6950 * @param task the task to be visited
6678 * @return the result of visiting the task 6951 * @return the result of visiting the task
6679 * @throws AnalysisException if the visitor throws an exception for some reaso n 6952 * @throws AnalysisException if the visitor throws an exception for some reaso n
6680 */ 6953 */
6681 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task); 6954 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task);
6682 6955
6683 /** 6956 /**
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6736 7009
6737 /** 7010 /**
6738 * Visit a [ResolveHtmlTask]. 7011 * Visit a [ResolveHtmlTask].
6739 * 7012 *
6740 * @param task the task to be visited 7013 * @param task the task to be visited
6741 * @return the result of visiting the task 7014 * @return the result of visiting the task
6742 * @throws AnalysisException if the visitor throws an exception for some reaso n 7015 * @throws AnalysisException if the visitor throws an exception for some reaso n
6743 */ 7016 */
6744 E visitResolveHtmlTask(ResolveHtmlTask task); 7017 E visitResolveHtmlTask(ResolveHtmlTask task);
6745 } 7018 }
7019
6746 /** 7020 /**
6747 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single 7021 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single
6748 * Dart source. 7022 * Dart source.
6749 */ 7023 */
6750 class GenerateDartErrorsTask extends AnalysisTask { 7024 class GenerateDartErrorsTask extends AnalysisTask {
6751
6752 /** 7025 /**
6753 * The source for which errors and warnings are to be produced. 7026 * The source for which errors and warnings are to be produced.
6754 */ 7027 */
6755 Source source; 7028 Source source;
6756 7029
6757 /** 7030 /**
6758 * The element model for the library containing the source. 7031 * The element model for the library containing the source.
6759 */ 7032 */
6760 LibraryElement libraryElement; 7033 LibraryElement libraryElement;
6761 7034
(...skipping 11 matching lines...) Expand all
6773 * Initialize a newly created task to perform analysis within the given contex t. 7046 * Initialize a newly created task to perform analysis within the given contex t.
6774 * 7047 *
6775 * @param context the context in which the task is to be performed 7048 * @param context the context in which the task is to be performed
6776 * @param source the source for which errors and warnings are to be produced 7049 * @param source the source for which errors and warnings are to be produced
6777 * @param libraryElement the element model for the library containing the sour ce 7050 * @param libraryElement the element model for the library containing the sour ce
6778 */ 7051 */
6779 GenerateDartErrorsTask(InternalAnalysisContext context, Source source, Library Element libraryElement) : super(context) { 7052 GenerateDartErrorsTask(InternalAnalysisContext context, Source source, Library Element libraryElement) : super(context) {
6780 this.source = source; 7053 this.source = source;
6781 this.libraryElement = libraryElement; 7054 this.libraryElement = libraryElement;
6782 } 7055 }
7056
6783 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi s); 7057 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi s);
7058
6784 String get taskDescription => "generate errors and warnings for ${source.fullN ame}"; 7059 String get taskDescription => "generate errors and warnings for ${source.fullN ame}";
7060
6785 void internalPerform() { 7061 void internalPerform() {
6786 InternalAnalysisContext context = this.context; 7062 InternalAnalysisContext context = this.context;
6787 TimestampedData<CompilationUnit> data = context.internalResolveCompilationUn it(source, libraryElement); 7063 TimestampedData<CompilationUnit> data = context.internalResolveCompilationUn it(source, libraryElement);
6788 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta rt(); 7064 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta rt();
6789 try { 7065 try {
6790 modificationTime = data.modificationTime; 7066 modificationTime = data.modificationTime;
6791 CompilationUnit unit = data.data; 7067 CompilationUnit unit = data.data;
6792 RecordingErrorListener errorListener = new RecordingErrorListener(); 7068 RecordingErrorListener errorListener = new RecordingErrorListener();
6793 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 7069 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
6794 Source coreSource = context.sourceFactory.forUri(DartSdk.DART_CORE); 7070 Source coreSource = context.sourceFactory.forUri(DartSdk.DART_CORE);
6795 LibraryElement coreLibrary = context.getLibraryElement(coreSource); 7071 LibraryElement coreLibrary = context.getLibraryElement(coreSource);
6796 TypeProvider typeProvider = new TypeProviderImpl(coreLibrary); 7072 TypeProvider typeProvider = new TypeProviderImpl(coreLibrary);
6797 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty peProvider); 7073 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty peProvider);
6798 unit.accept(constantVerifier); 7074 unit.accept(constantVerifier);
6799 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libraryElem ent, typeProvider, new InheritanceManager(libraryElement)); 7075 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libraryElem ent, typeProvider, new InheritanceManager(libraryElement));
6800 unit.accept(errorVerifier); 7076 unit.accept(errorVerifier);
6801 errors = errorListener.getErrors2(source); 7077 errors = errorListener.getErrors2(source);
6802 } finally { 7078 } finally {
6803 timeCounter.stop(); 7079 timeCounter.stop();
6804 } 7080 }
6805 } 7081 }
6806 } 7082 }
7083
6807 /** 7084 /**
6808 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da rt library. 7085 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da rt library.
6809 */ 7086 */
6810 class GenerateDartHintsTask extends AnalysisTask { 7087 class GenerateDartHintsTask extends AnalysisTask {
6811
6812 /** 7088 /**
6813 * The element model for the library being analyzed. 7089 * The element model for the library being analyzed.
6814 */ 7090 */
6815 LibraryElement libraryElement; 7091 LibraryElement libraryElement;
6816 7092
6817 /** 7093 /**
6818 * A table mapping the sources that were analyzed to the hints that were gener ated for the 7094 * A table mapping the sources that were analyzed to the hints that were gener ated for the
6819 * sources. 7095 * sources.
6820 */ 7096 */
6821 Map<Source, TimestampedData<List<AnalysisError>>> hintMap; 7097 Map<Source, TimestampedData<List<AnalysisError>>> hintMap;
6822 7098
6823 /** 7099 /**
6824 * Initialize a newly created task to perform analysis within the given contex t. 7100 * Initialize a newly created task to perform analysis within the given contex t.
6825 * 7101 *
6826 * @param context the context in which the task is to be performed 7102 * @param context the context in which the task is to be performed
6827 * @param libraryElement the element model for the library being analyzed 7103 * @param libraryElement the element model for the library being analyzed
6828 */ 7104 */
6829 GenerateDartHintsTask(InternalAnalysisContext context, LibraryElement libraryE lement) : super(context) { 7105 GenerateDartHintsTask(InternalAnalysisContext context, LibraryElement libraryE lement) : super(context) {
6830 this.libraryElement = libraryElement; 7106 this.libraryElement = libraryElement;
6831 } 7107 }
7108
6832 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this ); 7109 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this );
7110
6833 String get taskDescription { 7111 String get taskDescription {
6834 Source librarySource = libraryElement.source; 7112 Source librarySource = libraryElement.source;
6835 if (librarySource == null) { 7113 if (librarySource == null) {
6836 return "generate Dart hints for library without source"; 7114 return "generate Dart hints for library without source";
6837 } 7115 }
6838 return "generate Dart hints for ${librarySource.fullName}"; 7116 return "generate Dart hints for ${librarySource.fullName}";
6839 } 7117 }
7118
6840 void internalPerform() { 7119 void internalPerform() {
6841 RecordingErrorListener errorListener = new RecordingErrorListener(); 7120 RecordingErrorListener errorListener = new RecordingErrorListener();
6842 List<CompilationUnitElement> parts = libraryElement.parts; 7121 List<CompilationUnitElement> parts = libraryElement.parts;
6843 int partCount = parts.length; 7122 int partCount = parts.length;
6844 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(partCount + 1); 7123 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(partCount + 1);
6845 Map<Source, TimestampedData<CompilationUnit>> timestampMap = new Map<Source, TimestampedData<CompilationUnit>>(); 7124 Map<Source, TimestampedData<CompilationUnit>> timestampMap = new Map<Source, TimestampedData<CompilationUnit>>();
6846 Source unitSource = libraryElement.definingCompilationUnit.source; 7125 Source unitSource = libraryElement.definingCompilationUnit.source;
6847 TimestampedData<CompilationUnit> resolvedUnit = getCompilationUnit(unitSourc e); 7126 TimestampedData<CompilationUnit> resolvedUnit = getCompilationUnit(unitSourc e);
6848 timestampMap[unitSource] = resolvedUnit; 7127 timestampMap[unitSource] = resolvedUnit;
6849 CompilationUnit unit = resolvedUnit.data; 7128 CompilationUnit unit = resolvedUnit.data;
(...skipping 24 matching lines...) Expand all
6874 7153
6875 /** 7154 /**
6876 * Return the resolved compilation unit associated with the given source. 7155 * Return the resolved compilation unit associated with the given source.
6877 * 7156 *
6878 * @param unitSource the source for the compilation unit whose resolved AST is to be returned 7157 * @param unitSource the source for the compilation unit whose resolved AST is to be returned
6879 * @return the resolved compilation unit associated with the given source 7158 * @return the resolved compilation unit associated with the given source
6880 * @throws AnalysisException if the resolved compilation unit could not be com puted 7159 * @throws AnalysisException if the resolved compilation unit could not be com puted
6881 */ 7160 */
6882 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont ext.internalResolveCompilationUnit(unitSource, libraryElement); 7161 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont ext.internalResolveCompilationUnit(unitSource, libraryElement);
6883 } 7162 }
7163
6884 /** 7164 /**
6885 * Instances of the class `IncrementalAnalysisTask` incrementally update existin g analysis. 7165 * Instances of the class `IncrementalAnalysisTask` incrementally update existin g analysis.
6886 */ 7166 */
6887 class IncrementalAnalysisTask extends AnalysisTask { 7167 class IncrementalAnalysisTask extends AnalysisTask {
6888
6889 /** 7168 /**
6890 * The information used to perform incremental analysis. 7169 * The information used to perform incremental analysis.
6891 */ 7170 */
6892 IncrementalAnalysisCache cache; 7171 IncrementalAnalysisCache cache;
6893 7172
6894 /** 7173 /**
6895 * The compilation unit that was produced by incrementally updating the existi ng unit. 7174 * The compilation unit that was produced by incrementally updating the existi ng unit.
6896 */ 7175 */
6897 CompilationUnit compilationUnit; 7176 CompilationUnit compilationUnit;
6898 7177
6899 /** 7178 /**
6900 * Initialize a newly created task to perform analysis within the given contex t. 7179 * Initialize a newly created task to perform analysis within the given contex t.
6901 * 7180 *
6902 * @param context the context in which the task is to be performed 7181 * @param context the context in which the task is to be performed
6903 * @param cache the incremental analysis cache used to perform the analysis 7182 * @param cache the incremental analysis cache used to perform the analysis
6904 */ 7183 */
6905 IncrementalAnalysisTask(InternalAnalysisContext context, IncrementalAnalysisCa che cache) : super(context) { 7184 IncrementalAnalysisTask(InternalAnalysisContext context, IncrementalAnalysisCa che cache) : super(context) {
6906 this.cache = cache; 7185 this.cache = cache;
6907 } 7186 }
7187
6908 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th is); 7188 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th is);
6909 7189
6910 /** 7190 /**
6911 * Return the source that is to be incrementally analyzed. 7191 * Return the source that is to be incrementally analyzed.
6912 * 7192 *
6913 * @return the source 7193 * @return the source
6914 */ 7194 */
6915 Source get source => cache != null ? cache.source : null; 7195 Source get source => cache != null ? cache.source : null;
7196
6916 String get taskDescription => "incremental analysis ${(cache != null ? cache.s ource : "null")}"; 7197 String get taskDescription => "incremental analysis ${(cache != null ? cache.s ource : "null")}";
7198
6917 void internalPerform() { 7199 void internalPerform() {
6918 if (cache == null) { 7200 if (cache == null) {
6919 return; 7201 return;
6920 } 7202 }
6921 compilationUnit = cache.resolvedUnit; 7203 compilationUnit = cache.resolvedUnit;
6922 } 7204 }
6923 } 7205 }
7206
6924 /** 7207 /**
6925 * Instances of the class `ParseDartTask` parse a specific source as a Dart file . 7208 * Instances of the class `ParseDartTask` parse a specific source as a Dart file .
6926 */ 7209 */
6927 class ParseDartTask extends AnalysisTask { 7210 class ParseDartTask extends AnalysisTask {
6928
6929 /** 7211 /**
6930 * The source to be parsed. 7212 * The source to be parsed.
6931 */ 7213 */
6932 Source source; 7214 Source source;
6933 7215
6934 /** 7216 /**
6935 * The time at which the contents of the source were last modified. 7217 * The time at which the contents of the source were last modified.
6936 */ 7218 */
6937 int modificationTime = -1; 7219 int modificationTime = -1;
6938 7220
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6978 7260
6979 /** 7261 /**
6980 * Initialize a newly created task to perform analysis within the given contex t. 7262 * Initialize a newly created task to perform analysis within the given contex t.
6981 * 7263 *
6982 * @param context the context in which the task is to be performed 7264 * @param context the context in which the task is to be performed
6983 * @param source the source to be parsed 7265 * @param source the source to be parsed
6984 */ 7266 */
6985 ParseDartTask(InternalAnalysisContext context, Source source) : super(context) { 7267 ParseDartTask(InternalAnalysisContext context, Source source) : super(context) {
6986 this.source = source; 7268 this.source = source;
6987 } 7269 }
7270
6988 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); 7271 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this);
6989 7272
6990 /** 7273 /**
6991 * Return an array containing the sources referenced by 'export' directives, o r an empty array if 7274 * Return an array containing the sources referenced by 'export' directives, o r an empty array if
6992 * the task has not yet been performed or if an exception occurred. 7275 * the task has not yet been performed or if an exception occurred.
6993 * 7276 *
6994 * @return an array containing the sources referenced by 'export' directives 7277 * @return an array containing the sources referenced by 'export' directives
6995 */ 7278 */
6996 List<Source> get exportedSources => toArray(_exportedSources); 7279 List<Source> get exportedSources => toArray(_exportedSources);
6997 7280
(...skipping 21 matching lines...) Expand all
7019 */ 7302 */
7020 bool hasLibraryDirective() => _hasLibraryDirective2; 7303 bool hasLibraryDirective() => _hasLibraryDirective2;
7021 7304
7022 /** 7305 /**
7023 * Return `true` if the source contains a 'part of' directive, or `false` if t he task 7306 * Return `true` if the source contains a 'part of' directive, or `false` if t he task
7024 * has not yet been performed or if an exception occurred. 7307 * has not yet been performed or if an exception occurred.
7025 * 7308 *
7026 * @return `true` if the source contains a 'part of' directive 7309 * @return `true` if the source contains a 'part of' directive
7027 */ 7310 */
7028 bool hasPartOfDirective() => _hasPartOfDirective2; 7311 bool hasPartOfDirective() => _hasPartOfDirective2;
7312
7029 String get taskDescription { 7313 String get taskDescription {
7030 if (source == null) { 7314 if (source == null) {
7031 return "parse as dart null source"; 7315 return "parse as dart null source";
7032 } 7316 }
7033 return "parse as dart ${source.fullName}"; 7317 return "parse as dart ${source.fullName}";
7034 } 7318 }
7319
7035 void internalPerform() { 7320 void internalPerform() {
7036 RecordingErrorListener errorListener = new RecordingErrorListener(); 7321 RecordingErrorListener errorListener = new RecordingErrorListener();
7037 List<Token> token = [null]; 7322 List<Token> token = [null];
7038 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s tart(); 7323 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s tart();
7039 try { 7324 try {
7040 Source_ContentReceiver receiver = new Source_ContentReceiver_11(this, erro rListener, token); 7325 Source_ContentReceiver receiver = new Source_ContentReceiver_12(this, erro rListener, token);
7041 try { 7326 try {
7042 source.getContents(receiver); 7327 source.getContents(receiver);
7043 } on JavaException catch (exception) { 7328 } on JavaException catch (exception) {
7044 modificationTime = source.modificationStamp; 7329 modificationTime = source.modificationStamp;
7045 throw new AnalysisException.con3(exception); 7330 throw new AnalysisException.con3(exception);
7046 } 7331 }
7047 } finally { 7332 } finally {
7048 timeCounterScan.stop(); 7333 timeCounterScan.stop();
7049 } 7334 }
7050 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse .start(); 7335 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse .start();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7113 * @return an array containing all of the sources in the given set 7398 * @return an array containing all of the sources in the given set
7114 */ 7399 */
7115 List<Source> toArray(Set<Source> sources) { 7400 List<Source> toArray(Set<Source> sources) {
7116 int size = sources.length; 7401 int size = sources.length;
7117 if (size == 0) { 7402 if (size == 0) {
7118 return Source.EMPTY_ARRAY; 7403 return Source.EMPTY_ARRAY;
7119 } 7404 }
7120 return new List.from(sources); 7405 return new List.from(sources);
7121 } 7406 }
7122 } 7407 }
7123 class Source_ContentReceiver_11 implements Source_ContentReceiver { 7408
7409 class Source_ContentReceiver_12 implements Source_ContentReceiver {
7124 final ParseDartTask ParseDartTask_this; 7410 final ParseDartTask ParseDartTask_this;
7411
7125 RecordingErrorListener errorListener; 7412 RecordingErrorListener errorListener;
7413
7126 List<Token> token; 7414 List<Token> token;
7127 Source_ContentReceiver_11(this.ParseDartTask_this, this.errorListener, this.to ken); 7415
7416 Source_ContentReceiver_12(this.ParseDartTask_this, this.errorListener, this.to ken);
7417
7128 void accept(CharBuffer contents, int modificationTime) { 7418 void accept(CharBuffer contents, int modificationTime) {
7129 ParseDartTask_this.modificationTime = modificationTime; 7419 ParseDartTask_this.modificationTime = modificationTime;
7130 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceRea der(contents), errorListener); 7420 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceRea der(contents), errorListener);
7131 token[0] = scanner.tokenize(); 7421 token[0] = scanner.tokenize();
7132 ParseDartTask_this.lineInfo = new LineInfo(scanner.lineStarts); 7422 ParseDartTask_this.lineInfo = new LineInfo(scanner.lineStarts);
7133 } 7423 }
7424
7134 void accept2(String contents, int modificationTime) { 7425 void accept2(String contents, int modificationTime) {
7135 ParseDartTask_this.modificationTime = modificationTime; 7426 ParseDartTask_this.modificationTime = modificationTime;
7136 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceRea der(new CharSequence(contents)), errorListener); 7427 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceRea der(new CharSequence(contents)), errorListener);
7137 token[0] = scanner.tokenize(); 7428 token[0] = scanner.tokenize();
7138 ParseDartTask_this.lineInfo = new LineInfo(scanner.lineStarts); 7429 ParseDartTask_this.lineInfo = new LineInfo(scanner.lineStarts);
7139 } 7430 }
7140 } 7431 }
7432
7141 /** 7433 /**
7142 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil e. 7434 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil e.
7143 */ 7435 */
7144 class ParseHtmlTask extends AnalysisTask { 7436 class ParseHtmlTask extends AnalysisTask {
7145
7146 /** 7437 /**
7147 * The source to be parsed. 7438 * The source to be parsed.
7148 */ 7439 */
7149 Source source; 7440 Source source;
7150 7441
7151 /** 7442 /**
7152 * The time at which the contents of the source were last modified. 7443 * The time at which the contents of the source were last modified.
7153 */ 7444 */
7154 int modificationTime = -1; 7445 int modificationTime = -1;
7155 7446
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7191 7482
7192 /** 7483 /**
7193 * Initialize a newly created task to perform analysis within the given contex t. 7484 * Initialize a newly created task to perform analysis within the given contex t.
7194 * 7485 *
7195 * @param context the context in which the task is to be performed 7486 * @param context the context in which the task is to be performed
7196 * @param source the source to be parsed 7487 * @param source the source to be parsed
7197 */ 7488 */
7198 ParseHtmlTask(InternalAnalysisContext context, Source source) : super(context) { 7489 ParseHtmlTask(InternalAnalysisContext context, Source source) : super(context) {
7199 this.source = source; 7490 this.source = source;
7200 } 7491 }
7492
7201 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this); 7493 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this);
7494
7202 String get taskDescription { 7495 String get taskDescription {
7203 if (source == null) { 7496 if (source == null) {
7204 return "parse as html null source"; 7497 return "parse as html null source";
7205 } 7498 }
7206 return "parse as html ${source.fullName}"; 7499 return "parse as html ${source.fullName}";
7207 } 7500 }
7501
7208 void internalPerform() { 7502 void internalPerform() {
7209 HtmlScanner scanner = new HtmlScanner(source); 7503 HtmlScanner scanner = new HtmlScanner(source);
7210 try { 7504 try {
7211 source.getContents(scanner); 7505 source.getContents(scanner);
7212 } on JavaException catch (exception) { 7506 } on JavaException catch (exception) {
7213 throw new AnalysisException.con3(exception); 7507 throw new AnalysisException.con3(exception);
7214 } 7508 }
7215 HtmlScanResult scannerResult = scanner.result; 7509 HtmlScanResult scannerResult = scanner.result;
7216 modificationTime = scannerResult.modificationTime; 7510 modificationTime = scannerResult.modificationTime;
7217 lineInfo = new LineInfo(scannerResult.lineStarts); 7511 lineInfo = new LineInfo(scannerResult.lineStarts);
7218 HtmlParseResult result = new HtmlParser(source).parse(scannerResult); 7512 HtmlParseResult result = new HtmlParser(source).parse(scannerResult);
7219 htmlUnit = result.htmlUnit; 7513 htmlUnit = result.htmlUnit;
7220 referencedLibraries = librarySources; 7514 referencedLibraries = librarySources;
7221 } 7515 }
7222 7516
7223 /** 7517 /**
7224 * Return the sources of libraries that are referenced in the specified HTML f ile. 7518 * Return the sources of libraries that are referenced in the specified HTML f ile.
7225 * 7519 *
7226 * @return the sources of libraries that are referenced in the HTML file 7520 * @return the sources of libraries that are referenced in the HTML file
7227 */ 7521 */
7228 List<Source> get librarySources { 7522 List<Source> get librarySources {
7229 List<Source> libraries = new List<Source>(); 7523 List<Source> libraries = new List<Source>();
7230 htmlUnit.accept(new RecursiveXmlVisitor_12(this, libraries)); 7524 htmlUnit.accept(new RecursiveXmlVisitor_13(this, libraries));
7231 if (libraries.isEmpty) { 7525 if (libraries.isEmpty) {
7232 return Source.EMPTY_ARRAY; 7526 return Source.EMPTY_ARRAY;
7233 } 7527 }
7234 return new List.from(libraries); 7528 return new List.from(libraries);
7235 } 7529 }
7236 } 7530 }
7237 class RecursiveXmlVisitor_12 extends RecursiveXmlVisitor<Object> { 7531
7532 class RecursiveXmlVisitor_13 extends RecursiveXmlVisitor<Object> {
7238 final ParseHtmlTask ParseHtmlTask_this; 7533 final ParseHtmlTask ParseHtmlTask_this;
7534
7239 List<Source> libraries; 7535 List<Source> libraries;
7240 RecursiveXmlVisitor_12(this.ParseHtmlTask_this, this.libraries) : super(); 7536
7537 RecursiveXmlVisitor_13(this.ParseHtmlTask_this, this.libraries) : super();
7538
7241 Object visitXmlTagNode(XmlTagNode node) { 7539 Object visitXmlTagNode(XmlTagNode node) {
7242 if (javaStringEqualsIgnoreCase(node.tag.lexeme, ParseHtmlTask._TAG_SCRIPT)) { 7540 if (javaStringEqualsIgnoreCase(node.tag.lexeme, ParseHtmlTask._TAG_SCRIPT)) {
7243 bool isDartScript = false; 7541 bool isDartScript = false;
7244 XmlAttributeNode scriptAttribute = null; 7542 XmlAttributeNode scriptAttribute = null;
7245 for (XmlAttributeNode attribute in node.attributes) { 7543 for (XmlAttributeNode attribute in node.attributes) {
7246 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, ParseHtmlTask._ATT RIBUTE_SRC)) { 7544 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, ParseHtmlTask._ATT RIBUTE_SRC)) {
7247 scriptAttribute = attribute; 7545 scriptAttribute = attribute;
7248 } else if (javaStringEqualsIgnoreCase(attribute.name.lexeme, ParseHtmlTa sk._ATTRIBUTE_TYPE)) { 7546 } else if (javaStringEqualsIgnoreCase(attribute.name.lexeme, ParseHtmlTa sk._ATTRIBUTE_TYPE)) {
7249 if (javaStringEqualsIgnoreCase(attribute.text, ParseHtmlTask._TYPE_DAR T)) { 7547 if (javaStringEqualsIgnoreCase(attribute.text, ParseHtmlTask._TYPE_DAR T)) {
7250 isDartScript = true; 7548 isDartScript = true;
7251 } 7549 }
7252 } 7550 }
7253 } 7551 }
7254 if (isDartScript && scriptAttribute != null) { 7552 if (isDartScript && scriptAttribute != null) {
7255 try { 7553 try {
7256 Uri uri = new Uri(path: scriptAttribute.text); 7554 Uri uri = new Uri(path: scriptAttribute.text);
7257 String fileName = uri.path; 7555 String fileName = uri.path;
7258 Source librarySource = ParseHtmlTask_this.context.sourceFactory.resolv eUri(ParseHtmlTask_this.source, fileName); 7556 Source librarySource = ParseHtmlTask_this.context.sourceFactory.resolv eUri(ParseHtmlTask_this.source, fileName);
7259 if (librarySource != null && librarySource.exists()) { 7557 if (librarySource != null && librarySource.exists()) {
7260 libraries.add(librarySource); 7558 libraries.add(librarySource);
7261 } 7559 }
7262 } on URISyntaxException catch (e) { 7560 } on URISyntaxException catch (e) {
7263 } 7561 }
7264 } 7562 }
7265 } 7563 }
7266 return super.visitXmlTagNode(node); 7564 return super.visitXmlTagNode(node);
7267 } 7565 }
7268 } 7566 }
7567
7269 /** 7568 /**
7270 * Instances of the class `ResolveDartLibraryTask` parse a specific Dart library . 7569 * Instances of the class `ResolveDartLibraryTask` parse a specific Dart library .
7271 */ 7570 */
7272 class ResolveDartLibraryTask extends AnalysisTask { 7571 class ResolveDartLibraryTask extends AnalysisTask {
7273
7274 /** 7572 /**
7275 * The source representing the file whose compilation unit is to be returned. 7573 * The source representing the file whose compilation unit is to be returned.
7276 */ 7574 */
7277 Source unitSource; 7575 Source unitSource;
7278 7576
7279 /** 7577 /**
7280 * The source representing the library to be resolved. 7578 * The source representing the library to be resolved.
7281 */ 7579 */
7282 Source librarySource; 7580 Source librarySource;
7283 7581
7284 /** 7582 /**
7285 * The library resolver holding information about the libraries that were reso lved. 7583 * The library resolver holding information about the libraries that were reso lved.
7286 */ 7584 */
7287 LibraryResolver libraryResolver; 7585 LibraryResolver libraryResolver;
7288 7586
7289 /** 7587 /**
7290 * Initialize a newly created task to perform analysis within the given contex t. 7588 * Initialize a newly created task to perform analysis within the given contex t.
7291 * 7589 *
7292 * @param context the context in which the task is to be performed 7590 * @param context the context in which the task is to be performed
7293 * @param unitSource the source representing the file whose compilation unit i s to be returned 7591 * @param unitSource the source representing the file whose compilation unit i s to be returned
7294 * @param librarySource the source representing the library to be resolved 7592 * @param librarySource the source representing the library to be resolved
7295 */ 7593 */
7296 ResolveDartLibraryTask(InternalAnalysisContext context, Source unitSource, Sou rce librarySource) : super(context) { 7594 ResolveDartLibraryTask(InternalAnalysisContext context, Source unitSource, Sou rce librarySource) : super(context) {
7297 this.unitSource = unitSource; 7595 this.unitSource = unitSource;
7298 this.librarySource = librarySource; 7596 this.librarySource = librarySource;
7299 } 7597 }
7598
7300 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryTask(thi s); 7599 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryTask(thi s);
7600
7301 String get taskDescription { 7601 String get taskDescription {
7302 if (librarySource == null) { 7602 if (librarySource == null) {
7303 return "resolve library null source"; 7603 return "resolve library null source";
7304 } 7604 }
7305 return "resolve library ${librarySource.fullName}"; 7605 return "resolve library ${librarySource.fullName}";
7306 } 7606 }
7607
7307 void internalPerform() { 7608 void internalPerform() {
7308 libraryResolver = new LibraryResolver(context); 7609 libraryResolver = new LibraryResolver(context);
7309 libraryResolver.resolveLibrary(librarySource, true); 7610 libraryResolver.resolveLibrary(librarySource, true);
7310 } 7611 }
7311 } 7612 }
7613
7312 /** 7614 /**
7313 * Instances of the class `ResolveDartUnitTask` resolve a single Dart file based on a existing 7615 * Instances of the class `ResolveDartUnitTask` resolve a single Dart file based on a existing
7314 * element model. 7616 * element model.
7315 */ 7617 */
7316 class ResolveDartUnitTask extends AnalysisTask { 7618 class ResolveDartUnitTask extends AnalysisTask {
7317
7318 /** 7619 /**
7319 * The source that is to be resolved. 7620 * The source that is to be resolved.
7320 */ 7621 */
7321 Source source; 7622 Source source;
7322 7623
7323 /** 7624 /**
7324 * The element model for the library containing the source. 7625 * The element model for the library containing the source.
7325 */ 7626 */
7326 LibraryElement _libraryElement; 7627 LibraryElement _libraryElement;
7327 7628
(...skipping 11 matching lines...) Expand all
7339 * Initialize a newly created task to perform analysis within the given contex t. 7640 * Initialize a newly created task to perform analysis within the given contex t.
7340 * 7641 *
7341 * @param context the context in which the task is to be performed 7642 * @param context the context in which the task is to be performed
7342 * @param source the source to be parsed 7643 * @param source the source to be parsed
7343 * @param libraryElement the element model for the library containing the sour ce 7644 * @param libraryElement the element model for the library containing the sour ce
7344 */ 7645 */
7345 ResolveDartUnitTask(InternalAnalysisContext context, Source source, LibraryEle ment libraryElement) : super(context) { 7646 ResolveDartUnitTask(InternalAnalysisContext context, Source source, LibraryEle ment libraryElement) : super(context) {
7346 this.source = source; 7647 this.source = source;
7347 this._libraryElement = libraryElement; 7648 this._libraryElement = libraryElement;
7348 } 7649 }
7650
7349 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); 7651 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this);
7350 7652
7351 /** 7653 /**
7352 * Return the source for the library containing the source that is to be resol ved. 7654 * Return the source for the library containing the source that is to be resol ved.
7353 * 7655 *
7354 * @return the source for the library containing the source that is to be reso lved 7656 * @return the source for the library containing the source that is to be reso lved
7355 */ 7657 */
7356 Source get librarySource => _libraryElement.source; 7658 Source get librarySource => _libraryElement.source;
7659
7357 String get taskDescription { 7660 String get taskDescription {
7358 Source librarySource = _libraryElement.source; 7661 Source librarySource = _libraryElement.source;
7359 if (librarySource == null) { 7662 if (librarySource == null) {
7360 return "resolve unit null source"; 7663 return "resolve unit null source";
7361 } 7664 }
7362 return "resolve unit ${librarySource.fullName}"; 7665 return "resolve unit ${librarySource.fullName}";
7363 } 7666 }
7667
7364 void internalPerform() { 7668 void internalPerform() {
7365 Source coreLibrarySource = _libraryElement.context.sourceFactory.forUri(Dart Sdk.DART_CORE); 7669 Source coreLibrarySource = _libraryElement.context.sourceFactory.forUri(Dart Sdk.DART_CORE);
7366 LibraryElement coreElement = context.computeLibraryElement(coreLibrarySource ); 7670 LibraryElement coreElement = context.computeLibraryElement(coreLibrarySource );
7367 TypeProvider typeProvider = new TypeProviderImpl(coreElement); 7671 TypeProvider typeProvider = new TypeProviderImpl(coreElement);
7368 ResolvableCompilationUnit resolvableUnit = context.computeResolvableCompilat ionUnit(source); 7672 ResolvableCompilationUnit resolvableUnit = context.computeResolvableCompilat ionUnit(source);
7369 modificationTime = resolvableUnit.modificationTime; 7673 modificationTime = resolvableUnit.modificationTime;
7370 CompilationUnit unit = resolvableUnit.compilationUnit; 7674 CompilationUnit unit = resolvableUnit.compilationUnit;
7371 if (unit == null) { 7675 if (unit == null) {
7372 throw new AnalysisException.con1("Internal error: computeResolvableCompila tionUnit returned a value without a parsed Dart unit"); 7676 throw new AnalysisException.con1("Internal error: computeResolvableCompila tionUnit returned a value without a parsed Dart unit");
7373 } 7677 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
7411 return element; 7715 return element;
7412 } 7716 }
7413 for (CompilationUnitElement partElement in libraryElement.parts) { 7717 for (CompilationUnitElement partElement in libraryElement.parts) {
7414 if (partElement.source == unitSource) { 7718 if (partElement.source == unitSource) {
7415 return partElement; 7719 return partElement;
7416 } 7720 }
7417 } 7721 }
7418 return null; 7722 return null;
7419 } 7723 }
7420 } 7724 }
7725
7421 /** 7726 /**
7422 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML file. 7727 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML file.
7423 */ 7728 */
7424 class ResolveHtmlTask extends AnalysisTask { 7729 class ResolveHtmlTask extends AnalysisTask {
7425
7426 /** 7730 /**
7427 * The source to be resolved. 7731 * The source to be resolved.
7428 */ 7732 */
7429 Source source; 7733 Source source;
7430 7734
7431 /** 7735 /**
7432 * The time at which the contents of the source were last modified. 7736 * The time at which the contents of the source were last modified.
7433 */ 7737 */
7434 int modificationTime = -1; 7738 int modificationTime = -1;
7435 7739
7436 /** 7740 /**
7437 * The element produced by resolving the source. 7741 * The element produced by resolving the source.
7438 */ 7742 */
7439 HtmlElement element = null; 7743 HtmlElement element = null;
7440 7744
7441 /** 7745 /**
7442 * The resolution errors that were discovered while resolving the source. 7746 * The resolution errors that were discovered while resolving the source.
7443 */ 7747 */
7444 List<AnalysisError> resolutionErrors = AnalysisError.NO_ERRORS; 7748 List<AnalysisError> resolutionErrors = AnalysisError.NO_ERRORS;
7445 7749
7446 /** 7750 /**
7447 * Initialize a newly created task to perform analysis within the given contex t. 7751 * Initialize a newly created task to perform analysis within the given contex t.
7448 * 7752 *
7449 * @param context the context in which the task is to be performed 7753 * @param context the context in which the task is to be performed
7450 * @param source the source to be resolved 7754 * @param source the source to be resolved
7451 */ 7755 */
7452 ResolveHtmlTask(InternalAnalysisContext context, Source source) : super(contex t) { 7756 ResolveHtmlTask(InternalAnalysisContext context, Source source) : super(contex t) {
7453 this.source = source; 7757 this.source = source;
7454 } 7758 }
7759
7455 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); 7760 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this);
7761
7456 String get taskDescription { 7762 String get taskDescription {
7457 if (source == null) { 7763 if (source == null) {
7458 return "resolve as html null source"; 7764 return "resolve as html null source";
7459 } 7765 }
7460 return "resolve as html ${source.fullName}"; 7766 return "resolve as html ${source.fullName}";
7461 } 7767 }
7768
7462 void internalPerform() { 7769 void internalPerform() {
7463 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so urce); 7770 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so urce);
7464 HtmlUnit unit = resolvableHtmlUnit.compilationUnit; 7771 HtmlUnit unit = resolvableHtmlUnit.compilationUnit;
7465 if (unit == null) { 7772 if (unit == null) {
7466 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit"); 7773 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni t returned a value without a parsed HTML unit");
7467 } 7774 }
7468 modificationTime = resolvableHtmlUnit.modificationTime; 7775 modificationTime = resolvableHtmlUnit.modificationTime;
7469 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); 7776 HtmlUnitBuilder builder = new HtmlUnitBuilder(context);
7470 element = builder.buildHtmlElement2(source, modificationTime, unit); 7777 element = builder.buildHtmlElement2(source, modificationTime, unit);
7471 resolutionErrors = builder.errorListener.getErrors2(source); 7778 resolutionErrors = builder.errorListener.getErrors2(source);
7472 } 7779 }
7473 } 7780 }
7781
7474 /** 7782 /**
7475 * The interface `Logger` defines the behavior of objects that can be used to re ceive 7783 * The interface `Logger` defines the behavior of objects that can be used to re ceive
7476 * information about errors within the analysis engine. Implementations usually write this 7784 * information about errors within the analysis engine. Implementations usually write this
7477 * information to a file, but can also record the information for later use (suc h as during testing) 7785 * information to a file, but can also record the information for later use (suc h as during testing)
7478 * or even ignore the information. 7786 * or even ignore the information.
7479 * 7787 *
7480 * @coverage dart.engine.utilities 7788 * @coverage dart.engine.utilities
7481 */ 7789 */
7482 abstract class Logger { 7790 abstract class Logger {
7483 static final Logger NULL = new Logger_NullLogger(); 7791 static final Logger NULL = new Logger_NullLogger();
(...skipping 29 matching lines...) Expand all
7513 void logInformation(String message); 7821 void logInformation(String message);
7514 7822
7515 /** 7823 /**
7516 * Log the given exception as one representing an informational message. 7824 * Log the given exception as one representing an informational message.
7517 * 7825 *
7518 * @param message an explanation of why the error occurred or what it means 7826 * @param message an explanation of why the error occurred or what it means
7519 * @param exception the exception being logged 7827 * @param exception the exception being logged
7520 */ 7828 */
7521 void logInformation2(String message, Exception exception); 7829 void logInformation2(String message, Exception exception);
7522 } 7830 }
7831
7523 /** 7832 /**
7524 * Implementation of [Logger] that does nothing. 7833 * Implementation of [Logger] that does nothing.
7525 */ 7834 */
7526 class Logger_NullLogger implements Logger { 7835 class Logger_NullLogger implements Logger {
7527 void logError(String message) { 7836 void logError(String message) {
7528 } 7837 }
7838
7529 void logError2(String message, Exception exception) { 7839 void logError2(String message, Exception exception) {
7530 } 7840 }
7841
7531 void logError3(Exception exception) { 7842 void logError3(Exception exception) {
7532 } 7843 }
7844
7533 void logInformation(String message) { 7845 void logInformation(String message) {
7534 } 7846 }
7847
7535 void logInformation2(String message, Exception exception) { 7848 void logInformation2(String message, Exception exception) {
7536 } 7849 }
7537 } 7850 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698