OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine; | 8 library engine; |
9 | 9 |
10 import "dart:math" as math; | 10 import "dart:math" as math; |
11 import 'dart:async'; | 11 import 'dart:async'; |
12 import 'dart:collection'; | 12 import 'dart:collection'; |
13 | 13 |
14 import 'package:analyzer/src/cancelable_future.dart'; | 14 import 'package:analyzer/src/cancelable_future.dart'; |
15 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; | 15 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; |
16 import 'package:analyzer/src/services/lint.dart'; | 16 import 'package:analyzer/src/services/lint.dart'; |
17 import 'package:analyzer/src/task/task_dart.dart'; | 17 import 'package:analyzer/src/task/task_dart.dart'; |
18 | 18 |
19 import '../../instrumentation/instrumentation.dart'; | 19 import '../../instrumentation/instrumentation.dart'; |
20 import 'ast.dart'; | 20 import 'ast.dart'; |
21 import 'constant.dart'; | 21 import 'constant.dart'; |
22 import 'element.dart'; | 22 import 'element.dart'; |
23 import 'error.dart'; | 23 import 'error.dart'; |
24 import 'error_verifier.dart'; | 24 import 'error_verifier.dart'; |
25 import 'html.dart' as ht; | 25 import 'html.dart' as ht; |
26 import 'incremental_resolver.dart' show IncrementalResolver, | 26 import 'incremental_resolver.dart' |
27 PoorMansIncrementalResolver; | 27 show IncrementalResolver, PoorMansIncrementalResolver; |
28 import 'incremental_scanner.dart'; | 28 import 'incremental_scanner.dart'; |
29 import 'java_core.dart'; | 29 import 'java_core.dart'; |
30 import 'java_engine.dart'; | 30 import 'java_engine.dart'; |
31 import 'parser.dart' show Parser, IncrementalParser; | 31 import 'parser.dart' show Parser, IncrementalParser; |
32 import 'resolver.dart'; | 32 import 'resolver.dart'; |
33 import 'scanner.dart'; | 33 import 'scanner.dart'; |
34 import 'sdk.dart' show DartSdk; | 34 import 'sdk.dart' show DartSdk; |
35 import 'source.dart'; | 35 import 'source.dart'; |
36 import 'utilities_collection.dart'; | 36 import 'utilities_collection.dart'; |
37 import 'utilities_general.dart'; | 37 import 'utilities_general.dart'; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 * | 95 * |
96 * @return information about each of the partitions in this cache | 96 * @return information about each of the partitions in this cache |
97 */ | 97 */ |
98 List<AnalysisContextStatistics_PartitionData> get partitionData { | 98 List<AnalysisContextStatistics_PartitionData> get partitionData { |
99 int count = _partitions.length; | 99 int count = _partitions.length; |
100 List<AnalysisContextStatistics_PartitionData> data = | 100 List<AnalysisContextStatistics_PartitionData> data = |
101 new List<AnalysisContextStatistics_PartitionData>(count); | 101 new List<AnalysisContextStatistics_PartitionData>(count); |
102 for (int i = 0; i < count; i++) { | 102 for (int i = 0; i < count; i++) { |
103 CachePartition partition = _partitions[i]; | 103 CachePartition partition = _partitions[i]; |
104 data[i] = new AnalysisContextStatisticsImpl_PartitionDataImpl( | 104 data[i] = new AnalysisContextStatisticsImpl_PartitionDataImpl( |
105 partition.astSize, | 105 partition.astSize, partition.map.length); |
106 partition.map.length); | |
107 } | 106 } |
108 return data; | 107 return data; |
109 } | 108 } |
110 | 109 |
111 /** | 110 /** |
112 * Record that the AST associated with the given source was just read from the
cache. | 111 * Record that the AST associated with the given source was just read from the
cache. |
113 * | 112 * |
114 * @param source the source whose AST was accessed | 113 * @param source the source whose AST was accessed |
115 */ | 114 */ |
116 void accessedAst(Source source) { | 115 void accessedAst(Source source) { |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 * Return a future which will be completed with the fully resolved AST for a | 571 * Return a future which will be completed with the fully resolved AST for a |
573 * single compilation unit within the given library, once that AST is up to | 572 * single compilation unit within the given library, once that AST is up to |
574 * date. | 573 * date. |
575 * | 574 * |
576 * If the resolved AST can't be computed for some reason, the future will be | 575 * If the resolved AST can't be computed for some reason, the future will be |
577 * completed with an error. One possible error is AnalysisNotScheduledError, | 576 * completed with an error. One possible error is AnalysisNotScheduledError, |
578 * which means that the resolved AST can't be computed because the given | 577 * which means that the resolved AST can't be computed because the given |
579 * source file is not scheduled to be analyzed within the context of the | 578 * source file is not scheduled to be analyzed within the context of the |
580 * given library. | 579 * given library. |
581 */ | 580 */ |
582 CancelableFuture<CompilationUnit> | 581 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
583 computeResolvedCompilationUnitAsync(Source source, Source librarySource); | 582 Source source, Source librarySource); |
584 | 583 |
585 /** | 584 /** |
586 * Notifies the context that the client is going to stop using this context. | 585 * Notifies the context that the client is going to stop using this context. |
587 */ | 586 */ |
588 void dispose(); | 587 void dispose(); |
589 | 588 |
590 /** | 589 /** |
591 * Return `true` if the given source exists. | 590 * Return `true` if the given source exists. |
592 * | 591 * |
593 * This method should be used rather than the method [Source.exists] because c
ontexts can | 592 * This method should be used rather than the method [Source.exists] because c
ontexts can |
594 * have local overrides of the content of a source that the source is not awar
e of and a source | 593 * have local overrides of the content of a source that the source is not awar
e of and a source |
595 * with local content is considered to exist even if there is no file on disk. | 594 * with local content is considered to exist even if there is no file on disk. |
596 * | 595 * |
597 * @param source the source whose modification stamp is to be returned | 596 * @param source the source whose modification stamp is to be returned |
598 * @return `true` if the source exists | 597 * @return `true` if the source exists |
599 */ | 598 */ |
600 bool exists(Source source); | 599 bool exists(Source source); |
601 | 600 |
602 /** | 601 /** |
603 * Return the element model corresponding to the compilation unit defined by t
he given source in | 602 * Return the element model corresponding to the compilation unit defined by t
he given source in |
604 * the library defined by the given source, or `null` if the element model doe
s not | 603 * the library defined by the given source, or `null` if the element model doe
s not |
605 * currently exist or if the library cannot be analyzed for some reason. | 604 * currently exist or if the library cannot be analyzed for some reason. |
606 * | 605 * |
607 * @param unitSource the source of the compilation unit | 606 * @param unitSource the source of the compilation unit |
608 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 607 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
609 * compilation unit | 608 * compilation unit |
610 * @return the element model corresponding to the compilation unit defined by
the given source | 609 * @return the element model corresponding to the compilation unit defined by
the given source |
611 */ | 610 */ |
612 CompilationUnitElement getCompilationUnitElement(Source unitSource, | 611 CompilationUnitElement getCompilationUnitElement( |
613 Source librarySource); | 612 Source unitSource, Source librarySource); |
614 | 613 |
615 /** | 614 /** |
616 * Get the contents and timestamp of the given source. | 615 * Get the contents and timestamp of the given source. |
617 * | 616 * |
618 * This method should be used rather than the method [Source.getContents] beca
use contexts | 617 * This method should be used rather than the method [Source.getContents] beca
use contexts |
619 * can have local overrides of the content of a source that the source is not
aware of. | 618 * can have local overrides of the content of a source that the source is not
aware of. |
620 * | 619 * |
621 * @param source the source whose content is to be returned | 620 * @param source the source whose content is to be returned |
622 * @return the contents and timestamp of the source | 621 * @return the contents and timestamp of the source |
623 * @throws Exception if the contents of the source could not be accessed | 622 * @throws Exception if the contents of the source could not be accessed |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 747 |
749 /** | 748 /** |
750 * Return a fully resolved AST for a single compilation unit within the given
library, or | 749 * Return a fully resolved AST for a single compilation unit within the given
library, or |
751 * `null` if the resolved AST is not already computed. | 750 * `null` if the resolved AST is not already computed. |
752 * | 751 * |
753 * @param unitSource the source of the compilation unit | 752 * @param unitSource the source of the compilation unit |
754 * @param library the library containing the compilation unit | 753 * @param library the library containing the compilation unit |
755 * @return a fully resolved AST for the compilation unit | 754 * @return a fully resolved AST for the compilation unit |
756 * See [resolveCompilationUnit]. | 755 * See [resolveCompilationUnit]. |
757 */ | 756 */ |
758 CompilationUnit getResolvedCompilationUnit(Source unitSource, | 757 CompilationUnit getResolvedCompilationUnit( |
759 LibraryElement library); | 758 Source unitSource, LibraryElement library); |
760 | 759 |
761 /** | 760 /** |
762 * Return a fully resolved AST for a single compilation unit within the given
library, or | 761 * Return a fully resolved AST for a single compilation unit within the given
library, or |
763 * `null` if the resolved AST is not already computed. | 762 * `null` if the resolved AST is not already computed. |
764 * | 763 * |
765 * @param unitSource the source of the compilation unit | 764 * @param unitSource the source of the compilation unit |
766 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 765 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
767 * compilation unit | 766 * compilation unit |
768 * @return a fully resolved AST for the compilation unit | 767 * @return a fully resolved AST for the compilation unit |
769 * See [resolveCompilationUnit]. | 768 * See [resolveCompilationUnit]. |
770 */ | 769 */ |
771 CompilationUnit getResolvedCompilationUnit2(Source unitSource, | 770 CompilationUnit getResolvedCompilationUnit2( |
772 Source librarySource); | 771 Source unitSource, Source librarySource); |
773 | 772 |
774 /** | 773 /** |
775 * Return a fully resolved HTML unit, or `null` if the resolved unit is not al
ready | 774 * Return a fully resolved HTML unit, or `null` if the resolved unit is not al
ready |
776 * computed. | 775 * computed. |
777 * | 776 * |
778 * @param htmlSource the source of the HTML unit | 777 * @param htmlSource the source of the HTML unit |
779 * @return a fully resolved HTML unit | 778 * @return a fully resolved HTML unit |
780 * See [resolveHtmlUnit]. | 779 * See [resolveHtmlUnit]. |
781 */ | 780 */ |
782 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); | 781 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 * | 855 * |
857 * <b>Note:</b> This method cannot be used in an async environment. | 856 * <b>Note:</b> This method cannot be used in an async environment. |
858 * | 857 * |
859 * @param unitSource the source to be parsed and resolved | 858 * @param unitSource the source to be parsed and resolved |
860 * @param library the library containing the source to be resolved | 859 * @param library the library containing the source to be resolved |
861 * @return the result of resolving the AST structure representing the content
of the source in the | 860 * @return the result of resolving the AST structure representing the content
of the source in the |
862 * context of the given library | 861 * context of the given library |
863 * @throws AnalysisException if the analysis could not be performed | 862 * @throws AnalysisException if the analysis could not be performed |
864 * See [getResolvedCompilationUnit]. | 863 * See [getResolvedCompilationUnit]. |
865 */ | 864 */ |
866 CompilationUnit resolveCompilationUnit(Source unitSource, | 865 CompilationUnit resolveCompilationUnit( |
867 LibraryElement library); | 866 Source unitSource, LibraryElement library); |
868 | 867 |
869 /** | 868 /** |
870 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 869 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
871 * Return the resolved AST structure, or `null` if the source could not be eit
her parsed or | 870 * Return the resolved AST structure, or `null` if the source could not be eit
her parsed or |
872 * resolved. | 871 * resolved. |
873 * | 872 * |
874 * <b>Note:</b> This method cannot be used in an async environment. | 873 * <b>Note:</b> This method cannot be used in an async environment. |
875 * | 874 * |
876 * @param unitSource the source to be parsed and resolved | 875 * @param unitSource the source to be parsed and resolved |
877 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 876 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
878 * source to be resolved | 877 * source to be resolved |
879 * @return the result of resolving the AST structure representing the content
of the source in the | 878 * @return the result of resolving the AST structure representing the content
of the source in the |
880 * context of the given library | 879 * context of the given library |
881 * @throws AnalysisException if the analysis could not be performed | 880 * @throws AnalysisException if the analysis could not be performed |
882 * See [getResolvedCompilationUnit]. | 881 * See [getResolvedCompilationUnit]. |
883 */ | 882 */ |
884 CompilationUnit resolveCompilationUnit2(Source unitSource, | 883 CompilationUnit resolveCompilationUnit2( |
885 Source librarySource); | 884 Source unitSource, Source librarySource); |
886 | 885 |
887 /** | 886 /** |
888 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 887 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
889 * | 888 * |
890 * <b>Note:</b> This method cannot be used in an async environment. | 889 * <b>Note:</b> This method cannot be used in an async environment. |
891 * | 890 * |
892 * @param htmlSource the source to be parsed and resolved | 891 * @param htmlSource the source to be parsed and resolved |
893 * @return the result of resolving the AST structure representing the content
of the source | 892 * @return the result of resolving the AST structure representing the content
of the source |
894 * @throws AnalysisException if the analysis could not be performed | 893 * @throws AnalysisException if the analysis could not be performed |
895 */ | 894 */ |
896 ht.HtmlUnit resolveHtmlUnit(Source htmlSource); | 895 ht.HtmlUnit resolveHtmlUnit(Source htmlSource); |
897 | 896 |
898 /** | 897 /** |
899 * Set the contents of the given source to the given contents and mark the sou
rce as having | 898 * Set the contents of the given source to the given contents and mark the sou
rce as having |
900 * changed. The additional offset and length information is used by the contex
t to determine what | 899 * changed. The additional offset and length information is used by the contex
t to determine what |
901 * reanalysis is necessary. | 900 * reanalysis is necessary. |
902 * | 901 * |
903 * @param source the source whose contents are being overridden | 902 * @param source the source whose contents are being overridden |
904 * @param contents the text to replace the range in the current contents | 903 * @param contents the text to replace the range in the current contents |
905 * @param offset the offset into the current contents | 904 * @param offset the offset into the current contents |
906 * @param oldLength the number of characters in the original contents that wer
e replaced | 905 * @param oldLength the number of characters in the original contents that wer
e replaced |
907 * @param newLength the number of characters in the replacement text | 906 * @param newLength the number of characters in the replacement text |
908 */ | 907 */ |
909 void setChangedContents(Source source, String contents, int offset, | 908 void setChangedContents( |
910 int oldLength, int newLength); | 909 Source source, String contents, int offset, int oldLength, int newLength); |
911 | 910 |
912 /** | 911 /** |
913 * Set the contents of the given source to the given contents and mark the sou
rce as having | 912 * Set the contents of the given source to the given contents and mark the sou
rce as having |
914 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents | 913 * changed. This has the effect of overriding the default contents of the sour
ce. If the contents |
915 * are `null` the override is removed so that the default contents will be ret
urned. | 914 * are `null` the override is removed so that the default contents will be ret
urned. |
916 * | 915 * |
917 * @param source the source whose contents are being overridden | 916 * @param source the source whose contents are being overridden |
918 * @param contents the new contents of the source | 917 * @param contents the new contents of the source |
919 */ | 918 */ |
920 void setContents(Source source, String contents); | 919 void setContents(Source source, String contents); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 ResolverVisitorFactory resolverVisitorFactory; | 1093 ResolverVisitorFactory resolverVisitorFactory; |
1095 | 1094 |
1096 /** A factory to override how [TypeResolverVisitor] is created. */ | 1095 /** A factory to override how [TypeResolverVisitor] is created. */ |
1097 TypeResolverVisitorFactory typeResolverVisitorFactory; | 1096 TypeResolverVisitorFactory typeResolverVisitorFactory; |
1098 | 1097 |
1099 /** | 1098 /** |
1100 * Initialize a newly created analysis context. | 1099 * Initialize a newly created analysis context. |
1101 */ | 1100 */ |
1102 AnalysisContextImpl() { | 1101 AnalysisContextImpl() { |
1103 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); | 1102 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); |
1104 _privatePartition = new UniversalCachePartition( | 1103 _privatePartition = new UniversalCachePartition(this, |
1105 this, | |
1106 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, | 1104 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, |
1107 new AnalysisContextImpl_ContextRetentionPolicy(this)); | 1105 new AnalysisContextImpl_ContextRetentionPolicy(this)); |
1108 _cache = createCacheFromSourceFactory(null); | 1106 _cache = createCacheFromSourceFactory(null); |
1109 _onSourcesChangedController = | 1107 _onSourcesChangedController = |
1110 new StreamController<SourcesChangedEvent>.broadcast(); | 1108 new StreamController<SourcesChangedEvent>.broadcast(); |
1111 } | 1109 } |
1112 | 1110 |
1113 @override | 1111 @override |
1114 AnalysisOptions get analysisOptions => _options; | 1112 AnalysisOptions get analysisOptions => _options; |
1115 | 1113 |
1116 @override | 1114 @override |
1117 void set analysisOptions(AnalysisOptions options) { | 1115 void set analysisOptions(AnalysisOptions options) { |
1118 bool needsRecompute = | 1116 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != |
1119 this._options.analyzeFunctionBodiesPredicate != | |
1120 options.analyzeFunctionBodiesPredicate || | 1117 options.analyzeFunctionBodiesPredicate || |
1121 this._options.generateSdkErrors != options.generateSdkErrors || | 1118 this._options.generateSdkErrors != options.generateSdkErrors || |
1122 this._options.dart2jsHint != options.dart2jsHint || | 1119 this._options.dart2jsHint != options.dart2jsHint || |
1123 (this._options.hint && !options.hint) || | 1120 (this._options.hint && !options.hint) || |
1124 this._options.preserveComments != options.preserveComments; | 1121 this._options.preserveComments != options.preserveComments; |
1125 int cacheSize = options.cacheSize; | 1122 int cacheSize = options.cacheSize; |
1126 if (this._options.cacheSize != cacheSize) { | 1123 if (this._options.cacheSize != cacheSize) { |
1127 this._options.cacheSize = cacheSize; | 1124 this._options.cacheSize = cacheSize; |
1128 //cache.setMaxCacheSize(cacheSize); | 1125 //cache.setMaxCacheSize(cacheSize); |
1129 _privatePartition.maxCacheSize = cacheSize; | 1126 _privatePartition.maxCacheSize = cacheSize; |
1130 // | 1127 // |
1131 // Cap the size of the priority list to being less than the cache size. | 1128 // Cap the size of the priority list to being less than the cache size. |
1132 // Failure to do so can result in an infinite loop in | 1129 // Failure to do so can result in an infinite loop in |
1133 // performAnalysisTask() because re-caching one AST structure | 1130 // performAnalysisTask() because re-caching one AST structure |
1134 // can cause another priority source's AST structure to be flushed. | 1131 // can cause another priority source's AST structure to be flushed. |
1135 // | 1132 // |
1136 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 1133 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
1137 if (_priorityOrder.length > maxPriorityOrderSize) { | 1134 if (_priorityOrder.length > maxPriorityOrderSize) { |
1138 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); | 1135 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); |
1139 JavaSystem.arraycopy( | 1136 JavaSystem.arraycopy( |
1140 _priorityOrder, | 1137 _priorityOrder, 0, newPriorityOrder, 0, maxPriorityOrderSize); |
1141 0, | |
1142 newPriorityOrder, | |
1143 0, | |
1144 maxPriorityOrderSize); | |
1145 _priorityOrder = newPriorityOrder; | 1138 _priorityOrder = newPriorityOrder; |
1146 } | 1139 } |
1147 } | 1140 } |
1148 this._options.analyzeFunctionBodiesPredicate = | 1141 this._options.analyzeFunctionBodiesPredicate = |
1149 options.analyzeFunctionBodiesPredicate; | 1142 options.analyzeFunctionBodiesPredicate; |
1150 this._options.generateSdkErrors = options.generateSdkErrors; | 1143 this._options.generateSdkErrors = options.generateSdkErrors; |
1151 this._options.dart2jsHint = options.dart2jsHint; | 1144 this._options.dart2jsHint = options.dart2jsHint; |
1152 this._options.hint = options.hint; | 1145 this._options.hint = options.hint; |
1153 this._options.incremental = options.incremental; | 1146 this._options.incremental = options.incremental; |
1154 this._options.incrementalApi = options.incrementalApi; | 1147 this._options.incrementalApi = options.incrementalApi; |
(...skipping 16 matching lines...) Expand all Loading... |
1171 } | 1164 } |
1172 if (sources.isEmpty) { | 1165 if (sources.isEmpty) { |
1173 _priorityOrder = Source.EMPTY_ARRAY; | 1166 _priorityOrder = Source.EMPTY_ARRAY; |
1174 } | 1167 } |
1175 // | 1168 // |
1176 // Cap the size of the priority list to being less than the cache size. | 1169 // Cap the size of the priority list to being less than the cache size. |
1177 // Failure to do so can result in an infinite loop in | 1170 // Failure to do so can result in an infinite loop in |
1178 // performAnalysisTask() because re-caching one AST structure | 1171 // performAnalysisTask() because re-caching one AST structure |
1179 // can cause another priority source's AST structure to be flushed. | 1172 // can cause another priority source's AST structure to be flushed. |
1180 // | 1173 // |
1181 int count = | 1174 int count = math.min( |
1182 math.min(sources.length, _options.cacheSize - _PRIORITY_ORDER_SIZE_DEL
TA); | 1175 sources.length, _options.cacheSize - _PRIORITY_ORDER_SIZE_DELTA); |
1183 _priorityOrder = new List<Source>(count); | 1176 _priorityOrder = new List<Source>(count); |
1184 for (int i = 0; i < count; i++) { | 1177 for (int i = 0; i < count; i++) { |
1185 _priorityOrder[i] = sources[i]; | 1178 _priorityOrder[i] = sources[i]; |
1186 } | 1179 } |
1187 } | 1180 } |
1188 } | 1181 } |
1189 | 1182 |
1190 @override | 1183 @override |
1191 set contentCache(ContentCache value) { | 1184 set contentCache(ContentCache value) { |
1192 _contentCache = value; | 1185 _contentCache = value; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 // | 1258 // |
1266 // Look for a source that needs to be analyzed because it has futures | 1259 // Look for a source that needs to be analyzed because it has futures |
1267 // pending. | 1260 // pending. |
1268 // | 1261 // |
1269 if (_pendingFutureSources.isNotEmpty) { | 1262 if (_pendingFutureSources.isNotEmpty) { |
1270 List<Source> sourcesToRemove = <Source>[]; | 1263 List<Source> sourcesToRemove = <Source>[]; |
1271 AnalysisTask task; | 1264 AnalysisTask task; |
1272 for (Source source in _pendingFutureSources.keys) { | 1265 for (Source source in _pendingFutureSources.keys) { |
1273 SourceEntry sourceEntry = _cache.get(source); | 1266 SourceEntry sourceEntry = _cache.get(source); |
1274 List<PendingFuture> pendingFutures = _pendingFutureSources[source]; | 1267 List<PendingFuture> pendingFutures = _pendingFutureSources[source]; |
1275 for (int i = 0; i < pendingFutures.length; ) { | 1268 for (int i = 0; i < pendingFutures.length;) { |
1276 if (pendingFutures[i].evaluate(sourceEntry)) { | 1269 if (pendingFutures[i].evaluate(sourceEntry)) { |
1277 pendingFutures.removeAt(i); | 1270 pendingFutures.removeAt(i); |
1278 } else { | 1271 } else { |
1279 i++; | 1272 i++; |
1280 } | 1273 } |
1281 } | 1274 } |
1282 if (pendingFutures.isEmpty) { | 1275 if (pendingFutures.isEmpty) { |
1283 sourcesToRemove.add(source); | 1276 sourcesToRemove.add(source); |
1284 continue; | 1277 continue; |
1285 } | 1278 } |
1286 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource( | 1279 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource( |
1287 source, | 1280 source, sourceEntry, true, hintsEnabled, lintsEnabled); |
1288 sourceEntry, | |
1289 true, | |
1290 hintsEnabled, | |
1291 lintsEnabled); | |
1292 task = taskData.task; | 1281 task = taskData.task; |
1293 if (task != null) { | 1282 if (task != null) { |
1294 break; | 1283 break; |
1295 } else if (taskData.isBlocked) { | 1284 } else if (taskData.isBlocked) { |
1296 hasBlockedTask = true; | 1285 hasBlockedTask = true; |
1297 } else { | 1286 } else { |
1298 // There is no more work to do for this task, so forcibly complete | 1287 // There is no more work to do for this task, so forcibly complete |
1299 // all its pending futures. | 1288 // all its pending futures. |
1300 for (PendingFuture pendingFuture in pendingFutures) { | 1289 for (PendingFuture pendingFuture in pendingFutures) { |
1301 pendingFuture.forciblyComplete(); | 1290 pendingFuture.forciblyComplete(); |
1302 } | 1291 } |
1303 sourcesToRemove.add(source); | 1292 sourcesToRemove.add(source); |
1304 } | 1293 } |
1305 } | 1294 } |
1306 for (Source source in sourcesToRemove) { | 1295 for (Source source in sourcesToRemove) { |
1307 _pendingFutureSources.remove(source); | 1296 _pendingFutureSources.remove(source); |
1308 } | 1297 } |
1309 if (task != null) { | 1298 if (task != null) { |
1310 return task; | 1299 return task; |
1311 } | 1300 } |
1312 } | 1301 } |
1313 // | 1302 // |
1314 // Look for a priority source that needs to be analyzed. | 1303 // Look for a priority source that needs to be analyzed. |
1315 // | 1304 // |
1316 int priorityCount = _priorityOrder.length; | 1305 int priorityCount = _priorityOrder.length; |
1317 for (int i = 0; i < priorityCount; i++) { | 1306 for (int i = 0; i < priorityCount; i++) { |
1318 Source source = _priorityOrder[i]; | 1307 Source source = _priorityOrder[i]; |
1319 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource( | 1308 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource( |
1320 source, | 1309 source, _cache.get(source), true, hintsEnabled, lintsEnabled); |
1321 _cache.get(source), | |
1322 true, | |
1323 hintsEnabled, | |
1324 lintsEnabled); | |
1325 AnalysisTask task = taskData.task; | 1310 AnalysisTask task = taskData.task; |
1326 if (task != null) { | 1311 if (task != null) { |
1327 return task; | 1312 return task; |
1328 } else if (taskData.isBlocked) { | 1313 } else if (taskData.isBlocked) { |
1329 hasBlockedTask = true; | 1314 hasBlockedTask = true; |
1330 } | 1315 } |
1331 } | 1316 } |
1332 if (_neededForResolution != null) { | 1317 if (_neededForResolution != null) { |
1333 List<Source> sourcesToRemove = new List<Source>(); | 1318 List<Source> sourcesToRemove = new List<Source>(); |
1334 for (Source source in _neededForResolution) { | 1319 for (Source source in _neededForResolution) { |
(...skipping 23 matching lines...) Expand all Loading... |
1358 } | 1343 } |
1359 // | 1344 // |
1360 // Look for a non-priority source that needs to be analyzed. | 1345 // Look for a non-priority source that needs to be analyzed. |
1361 // | 1346 // |
1362 List<Source> sourcesToRemove = new List<Source>(); | 1347 List<Source> sourcesToRemove = new List<Source>(); |
1363 WorkManager_WorkIterator sources = _workManager.iterator(); | 1348 WorkManager_WorkIterator sources = _workManager.iterator(); |
1364 try { | 1349 try { |
1365 while (sources.hasNext) { | 1350 while (sources.hasNext) { |
1366 Source source = sources.next(); | 1351 Source source = sources.next(); |
1367 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource( | 1352 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource( |
1368 source, | 1353 source, _cache.get(source), false, hintsEnabled, lintsEnabled); |
1369 _cache.get(source), | |
1370 false, | |
1371 hintsEnabled, | |
1372 lintsEnabled); | |
1373 AnalysisTask task = taskData.task; | 1354 AnalysisTask task = taskData.task; |
1374 if (task != null) { | 1355 if (task != null) { |
1375 return task; | 1356 return task; |
1376 } else if (taskData.isBlocked) { | 1357 } else if (taskData.isBlocked) { |
1377 hasBlockedTask = true; | 1358 hasBlockedTask = true; |
1378 } else { | 1359 } else { |
1379 sourcesToRemove.add(source); | 1360 sourcesToRemove.add(source); |
1380 } | 1361 } |
1381 } | 1362 } |
1382 } finally { | 1363 } finally { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 */ | 1434 */ |
1454 List<Source> get sourcesNeedingProcessing { | 1435 List<Source> get sourcesNeedingProcessing { |
1455 HashSet<Source> sources = new HashSet<Source>(); | 1436 HashSet<Source> sources = new HashSet<Source>(); |
1456 bool hintsEnabled = _options.hint; | 1437 bool hintsEnabled = _options.hint; |
1457 bool lintsEnabled = _options.lint; | 1438 bool lintsEnabled = _options.lint; |
1458 | 1439 |
1459 // | 1440 // |
1460 // Look for priority sources that need to be analyzed. | 1441 // Look for priority sources that need to be analyzed. |
1461 // | 1442 // |
1462 for (Source source in _priorityOrder) { | 1443 for (Source source in _priorityOrder) { |
1463 _getSourcesNeedingProcessing( | 1444 _getSourcesNeedingProcessing(source, _cache.get(source), true, |
1464 source, | 1445 hintsEnabled, lintsEnabled, sources); |
1465 _cache.get(source), | |
1466 true, | |
1467 hintsEnabled, | |
1468 lintsEnabled, | |
1469 sources); | |
1470 } | 1446 } |
1471 // | 1447 // |
1472 // Look for non-priority sources that need to be analyzed. | 1448 // Look for non-priority sources that need to be analyzed. |
1473 // | 1449 // |
1474 WorkManager_WorkIterator iterator = _workManager.iterator(); | 1450 WorkManager_WorkIterator iterator = _workManager.iterator(); |
1475 while (iterator.hasNext) { | 1451 while (iterator.hasNext) { |
1476 Source source = iterator.next(); | 1452 Source source = iterator.next(); |
1477 _getSourcesNeedingProcessing( | 1453 _getSourcesNeedingProcessing(source, |
1478 source, | 1454 _cache.get(source), false, hintsEnabled, lintsEnabled, sources); |
1479 _cache.get(source), | |
1480 false, | |
1481 hintsEnabled, | |
1482 lintsEnabled, | |
1483 sources); | |
1484 } | 1455 } |
1485 return new List<Source>.from(sources); | 1456 return new List<Source>.from(sources); |
1486 } | 1457 } |
1487 | 1458 |
1488 @override | 1459 @override |
1489 AnalysisContextStatistics get statistics { | 1460 AnalysisContextStatistics get statistics { |
1490 AnalysisContextStatisticsImpl statistics = | 1461 AnalysisContextStatisticsImpl statistics = |
1491 new AnalysisContextStatisticsImpl(); | 1462 new AnalysisContextStatisticsImpl(); |
1492 visitCacheItems(statistics._internalPutCacheItem); | 1463 visitCacheItems(statistics._internalPutCacheItem); |
1493 statistics.partitionData = _cache.partitionData; | 1464 statistics.partitionData = _cache.partitionData; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1579 // re-analysis. | 1550 // re-analysis. |
1580 continue; | 1551 continue; |
1581 } | 1552 } |
1582 _sourceChanged(source); | 1553 _sourceChanged(source); |
1583 } | 1554 } |
1584 changeSet.changedContents.forEach((Source key, String value) { | 1555 changeSet.changedContents.forEach((Source key, String value) { |
1585 _contentsChanged(key, value, false); | 1556 _contentsChanged(key, value, false); |
1586 }); | 1557 }); |
1587 changeSet.changedRanges.forEach( | 1558 changeSet.changedRanges.forEach( |
1588 (Source source, ChangeSet_ContentChange change) { | 1559 (Source source, ChangeSet_ContentChange change) { |
1589 _contentRangeChanged( | 1560 _contentRangeChanged(source, change.contents, change.offset, |
1590 source, | 1561 change.oldLength, change.newLength); |
1591 change.contents, | |
1592 change.offset, | |
1593 change.oldLength, | |
1594 change.newLength); | |
1595 }); | 1562 }); |
1596 for (Source source in changeSet.deletedSources) { | 1563 for (Source source in changeSet.deletedSources) { |
1597 _sourceDeleted(source); | 1564 _sourceDeleted(source); |
1598 } | 1565 } |
1599 for (Source source in removedSources) { | 1566 for (Source source in removedSources) { |
1600 _sourceRemoved(source); | 1567 _sourceRemoved(source); |
1601 } | 1568 } |
1602 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); | 1569 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); |
1603 } | 1570 } |
1604 | 1571 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 List<AnalysisError> computeErrors(Source source) { | 1609 List<AnalysisError> computeErrors(Source source) { |
1643 bool enableHints = _options.hint; | 1610 bool enableHints = _options.hint; |
1644 bool enableLints = _options.lint; | 1611 bool enableLints = _options.lint; |
1645 | 1612 |
1646 SourceEntry sourceEntry = _getReadableSourceEntry(source); | 1613 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
1647 if (sourceEntry is DartEntry) { | 1614 if (sourceEntry is DartEntry) { |
1648 List<AnalysisError> errors = new List<AnalysisError>(); | 1615 List<AnalysisError> errors = new List<AnalysisError>(); |
1649 try { | 1616 try { |
1650 DartEntry dartEntry = sourceEntry; | 1617 DartEntry dartEntry = sourceEntry; |
1651 ListUtilities.addAll( | 1618 ListUtilities.addAll( |
1652 errors, | 1619 errors, _getDartScanData(source, dartEntry, DartEntry.SCAN_ERRORS)); |
1653 _getDartScanData(source, dartEntry, DartEntry.SCAN_ERRORS)); | |
1654 dartEntry = _getReadableDartEntry(source); | 1620 dartEntry = _getReadableDartEntry(source); |
1655 ListUtilities.addAll( | 1621 ListUtilities.addAll(errors, |
1656 errors, | |
1657 _getDartParseData(source, dartEntry, DartEntry.PARSE_ERRORS)); | 1622 _getDartParseData(source, dartEntry, DartEntry.PARSE_ERRORS)); |
1658 dartEntry = _getReadableDartEntry(source); | 1623 dartEntry = _getReadableDartEntry(source); |
1659 if (dartEntry.getValue(DartEntry.SOURCE_KIND) == SourceKind.LIBRARY) { | 1624 if (dartEntry.getValue(DartEntry.SOURCE_KIND) == SourceKind.LIBRARY) { |
1660 ListUtilities.addAll( | 1625 ListUtilities.addAll(errors, _getDartResolutionData( |
1661 errors, | 1626 source, source, dartEntry, DartEntry.RESOLUTION_ERRORS)); |
1662 _getDartResolutionData(source, source, dartEntry, DartEntry.RESOLU
TION_ERRORS)); | |
1663 dartEntry = _getReadableDartEntry(source); | 1627 dartEntry = _getReadableDartEntry(source); |
1664 ListUtilities.addAll( | 1628 ListUtilities.addAll(errors, _getDartVerificationData( |
1665 errors, | 1629 source, source, dartEntry, DartEntry.VERIFICATION_ERRORS)); |
1666 _getDartVerificationData( | |
1667 source, | |
1668 source, | |
1669 dartEntry, | |
1670 DartEntry.VERIFICATION_ERRORS)); | |
1671 if (enableHints) { | 1630 if (enableHints) { |
1672 dartEntry = _getReadableDartEntry(source); | 1631 dartEntry = _getReadableDartEntry(source); |
1673 ListUtilities.addAll( | 1632 ListUtilities.addAll(errors, |
1674 errors, | |
1675 _getDartHintData(source, source, dartEntry, DartEntry.HINTS)); | 1633 _getDartHintData(source, source, dartEntry, DartEntry.HINTS)); |
1676 } | 1634 } |
1677 if (enableLints) { | 1635 if (enableLints) { |
1678 dartEntry = _getReadableDartEntry(source); | 1636 dartEntry = _getReadableDartEntry(source); |
1679 ListUtilities.addAll( | 1637 ListUtilities.addAll(errors, |
1680 errors, | |
1681 _getDartLintData(source, source, dartEntry, DartEntry.LINTS)); | 1638 _getDartLintData(source, source, dartEntry, DartEntry.LINTS)); |
1682 } | 1639 } |
1683 } else { | 1640 } else { |
1684 List<Source> libraries = getLibrariesContaining(source); | 1641 List<Source> libraries = getLibrariesContaining(source); |
1685 for (Source librarySource in libraries) { | 1642 for (Source librarySource in libraries) { |
1686 ListUtilities.addAll( | 1643 ListUtilities.addAll(errors, _getDartResolutionData( |
1687 errors, | 1644 source, librarySource, dartEntry, DartEntry.RESOLUTION_ERRORS)); |
1688 _getDartResolutionData( | |
1689 source, | |
1690 librarySource, | |
1691 dartEntry, | |
1692 DartEntry.RESOLUTION_ERRORS)); | |
1693 dartEntry = _getReadableDartEntry(source); | 1645 dartEntry = _getReadableDartEntry(source); |
1694 ListUtilities.addAll( | 1646 ListUtilities.addAll(errors, _getDartVerificationData(source, |
1695 errors, | 1647 librarySource, dartEntry, DartEntry.VERIFICATION_ERRORS)); |
1696 _getDartVerificationData( | |
1697 source, | |
1698 librarySource, | |
1699 dartEntry, | |
1700 DartEntry.VERIFICATION_ERRORS)); | |
1701 if (enableHints) { | 1648 if (enableHints) { |
1702 dartEntry = _getReadableDartEntry(source); | 1649 dartEntry = _getReadableDartEntry(source); |
1703 ListUtilities.addAll( | 1650 ListUtilities.addAll(errors, _getDartHintData( |
1704 errors, | 1651 source, librarySource, dartEntry, DartEntry.HINTS)); |
1705 _getDartHintData(source, librarySource, dartEntry, DartEntry.H
INTS)); | |
1706 } | 1652 } |
1707 if (enableLints) { | 1653 if (enableLints) { |
1708 dartEntry = _getReadableDartEntry(source); | 1654 dartEntry = _getReadableDartEntry(source); |
1709 ListUtilities.addAll( | 1655 ListUtilities.addAll(errors, _getDartLintData( |
1710 errors, | 1656 source, librarySource, dartEntry, DartEntry.LINTS)); |
1711 _getDartLintData(source, librarySource, dartEntry, DartEntry.L
INTS)); | |
1712 } | 1657 } |
1713 } | 1658 } |
1714 } | 1659 } |
1715 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 1660 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
1716 AnalysisEngine.instance.logger.logInformation( | 1661 AnalysisEngine.instance.logger.logInformation( |
1717 "Could not compute errors", | 1662 "Could not compute errors", |
1718 new CaughtException(exception, stackTrace)); | 1663 new CaughtException(exception, stackTrace)); |
1719 } | 1664 } |
1720 if (errors.isEmpty) { | 1665 if (errors.isEmpty) { |
1721 return AnalysisError.NO_ERRORS; | 1666 return AnalysisError.NO_ERRORS; |
1722 } | 1667 } |
1723 return errors; | 1668 return errors; |
1724 } else if (sourceEntry is HtmlEntry) { | 1669 } else if (sourceEntry is HtmlEntry) { |
1725 HtmlEntry htmlEntry = sourceEntry; | 1670 HtmlEntry htmlEntry = sourceEntry; |
1726 try { | 1671 try { |
1727 return _getHtmlResolutionData2( | 1672 return _getHtmlResolutionData2( |
1728 source, | 1673 source, htmlEntry, HtmlEntry.RESOLUTION_ERRORS); |
1729 htmlEntry, | |
1730 HtmlEntry.RESOLUTION_ERRORS); | |
1731 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 1674 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
1732 AnalysisEngine.instance.logger.logInformation( | 1675 AnalysisEngine.instance.logger.logInformation( |
1733 "Could not compute errors", | 1676 "Could not compute errors", |
1734 new CaughtException(exception, stackTrace)); | 1677 new CaughtException(exception, stackTrace)); |
1735 } | 1678 } |
1736 } | 1679 } |
1737 return AnalysisError.NO_ERRORS; | 1680 return AnalysisError.NO_ERRORS; |
1738 } | 1681 } |
1739 | 1682 |
1740 @override | 1683 @override |
1741 List<Source> computeExportedLibraries(Source source) => | 1684 List<Source> computeExportedLibraries(Source source) => _getDartParseData2( |
1742 _getDartParseData2(source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRA
Y); | 1685 source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
1743 | 1686 |
1744 @override | 1687 @override |
1745 HtmlElement computeHtmlElement(Source source) => | 1688 HtmlElement computeHtmlElement(Source source) => |
1746 _getHtmlResolutionData(source, HtmlEntry.ELEMENT, null); | 1689 _getHtmlResolutionData(source, HtmlEntry.ELEMENT, null); |
1747 | 1690 |
1748 @override | 1691 @override |
1749 List<Source> computeImportedLibraries(Source source) => | 1692 List<Source> computeImportedLibraries(Source source) => _getDartParseData2( |
1750 _getDartParseData2(source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRA
Y); | 1693 source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
1751 | 1694 |
1752 @override | 1695 @override |
1753 SourceKind computeKindOf(Source source) { | 1696 SourceKind computeKindOf(Source source) { |
1754 SourceEntry sourceEntry = _getReadableSourceEntry(source); | 1697 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
1755 if (sourceEntry == null) { | 1698 if (sourceEntry == null) { |
1756 return SourceKind.UNKNOWN; | 1699 return SourceKind.UNKNOWN; |
1757 } else if (sourceEntry is DartEntry) { | 1700 } else if (sourceEntry is DartEntry) { |
1758 try { | 1701 try { |
1759 return _getDartParseData(source, sourceEntry, DartEntry.SOURCE_KIND); | 1702 return _getDartParseData(source, sourceEntry, DartEntry.SOURCE_KIND); |
1760 } on AnalysisException catch (exception) { | 1703 } on AnalysisException catch (exception) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1796 CompilationUnit unit = dartEntry.resolvableCompilationUnit; | 1739 CompilationUnit unit = dartEntry.resolvableCompilationUnit; |
1797 if (unit == null) { | 1740 if (unit == null) { |
1798 throw new AnalysisException( | 1741 throw new AnalysisException( |
1799 "Internal error: computeResolvableCompilationUnit could not parse ${so
urce.fullName}", | 1742 "Internal error: computeResolvableCompilationUnit could not parse ${so
urce.fullName}", |
1800 new CaughtException(dartEntry.exception, null)); | 1743 new CaughtException(dartEntry.exception, null)); |
1801 } | 1744 } |
1802 return unit; | 1745 return unit; |
1803 } | 1746 } |
1804 | 1747 |
1805 @override | 1748 @override |
1806 CancelableFuture<CompilationUnit> | 1749 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
1807 computeResolvedCompilationUnitAsync(Source unitSource, Source librarySourc
e) { | 1750 Source unitSource, Source librarySource) { |
1808 return new _AnalysisFutureHelper<CompilationUnit>( | 1751 return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync( |
1809 this).computeAsync(unitSource, (SourceEntry sourceEntry) { | 1752 unitSource, (SourceEntry sourceEntry) { |
1810 if (sourceEntry is DartEntry) { | 1753 if (sourceEntry is DartEntry) { |
1811 if (sourceEntry.getStateInLibrary( | 1754 if (sourceEntry.getStateInLibrary( |
1812 DartEntry.RESOLVED_UNIT, | 1755 DartEntry.RESOLVED_UNIT, librarySource) == |
1813 librarySource) == | |
1814 CacheState.ERROR) { | 1756 CacheState.ERROR) { |
1815 throw sourceEntry.exception; | 1757 throw sourceEntry.exception; |
1816 } | 1758 } |
1817 return sourceEntry.getValueInLibrary( | 1759 return sourceEntry.getValueInLibrary( |
1818 DartEntry.RESOLVED_UNIT, | 1760 DartEntry.RESOLVED_UNIT, librarySource); |
1819 librarySource); | |
1820 } | 1761 } |
1821 throw new AnalysisNotScheduledError(); | 1762 throw new AnalysisNotScheduledError(); |
1822 }); | 1763 }); |
1823 } | 1764 } |
1824 | 1765 |
1825 /** | 1766 /** |
1826 * Create an analysis cache based on the given source factory. | 1767 * Create an analysis cache based on the given source factory. |
1827 * | 1768 * |
1828 * @param factory the source factory containing the information needed to crea
te the cache | 1769 * @param factory the source factory containing the information needed to crea
te the cache |
1829 * @return the cache that was created | 1770 * @return the cache that was created |
1830 */ | 1771 */ |
1831 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 1772 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
1832 if (factory == null) { | 1773 if (factory == null) { |
1833 return new AnalysisCache(<CachePartition>[_privatePartition]); | 1774 return new AnalysisCache(<CachePartition>[_privatePartition]); |
1834 } | 1775 } |
1835 DartSdk sdk = factory.dartSdk; | 1776 DartSdk sdk = factory.dartSdk; |
1836 if (sdk == null) { | 1777 if (sdk == null) { |
1837 return new AnalysisCache(<CachePartition>[_privatePartition]); | 1778 return new AnalysisCache(<CachePartition>[_privatePartition]); |
1838 } | 1779 } |
1839 return new AnalysisCache( | 1780 return new AnalysisCache(<CachePartition>[ |
1840 <CachePartition>[ | 1781 AnalysisEngine.instance.partitionManager.forSdk(sdk), |
1841 AnalysisEngine.instance.partitionManager.forSdk(sdk), | 1782 _privatePartition |
1842 _privatePartition]); | 1783 ]); |
1843 } | 1784 } |
1844 | 1785 |
1845 @override | 1786 @override |
1846 void dispose() { | 1787 void dispose() { |
1847 _disposed = true; | 1788 _disposed = true; |
1848 for (List<PendingFuture> pendingFutures in _pendingFutureSources.values) { | 1789 for (List<PendingFuture> pendingFutures in _pendingFutureSources.values) { |
1849 for (PendingFuture pendingFuture in pendingFutures) { | 1790 for (PendingFuture pendingFuture in pendingFutures) { |
1850 pendingFuture.forciblyComplete(); | 1791 pendingFuture.forciblyComplete(); |
1851 } | 1792 } |
1852 } | 1793 } |
(...skipping 17 matching lines...) Expand all Loading... |
1870 units = null; | 1811 units = null; |
1871 break; | 1812 break; |
1872 } | 1813 } |
1873 units.add(unit); | 1814 units.add(unit); |
1874 } | 1815 } |
1875 // Invalidate the flushed RESOLVED_UNIT to force it eventually. | 1816 // Invalidate the flushed RESOLVED_UNIT to force it eventually. |
1876 if (units == null) { | 1817 if (units == null) { |
1877 bool shouldBeScheduled = false; | 1818 bool shouldBeScheduled = false; |
1878 for (Source librarySource in containingLibraries) { | 1819 for (Source librarySource in containingLibraries) { |
1879 if (dartEntry.getStateInLibrary( | 1820 if (dartEntry.getStateInLibrary( |
1880 DartEntry.RESOLVED_UNIT, | 1821 DartEntry.RESOLVED_UNIT, librarySource) == |
1881 librarySource) == | |
1882 CacheState.FLUSHED) { | 1822 CacheState.FLUSHED) { |
1883 dartEntry.setStateInLibrary( | 1823 dartEntry.setStateInLibrary( |
1884 DartEntry.RESOLVED_UNIT, | 1824 DartEntry.RESOLVED_UNIT, librarySource, CacheState.INVALID); |
1885 librarySource, | |
1886 CacheState.INVALID); | |
1887 shouldBeScheduled = true; | 1825 shouldBeScheduled = true; |
1888 } | 1826 } |
1889 } | 1827 } |
1890 if (shouldBeScheduled) { | 1828 if (shouldBeScheduled) { |
1891 _workManager.add(unitSource, SourcePriority.UNKNOWN); | 1829 _workManager.add(unitSource, SourcePriority.UNKNOWN); |
1892 } | 1830 } |
1893 // We cannot provide resolved units right now, | 1831 // We cannot provide resolved units right now, |
1894 // but the future analysis will. | 1832 // but the future analysis will. |
1895 return null; | 1833 return null; |
1896 } | 1834 } |
(...skipping 26 matching lines...) Expand all Loading... |
1923 } | 1861 } |
1924 } | 1862 } |
1925 } | 1863 } |
1926 } on _ElementByIdFinderException catch (e) { | 1864 } on _ElementByIdFinderException catch (e) { |
1927 return finder.result; | 1865 return finder.result; |
1928 } | 1866 } |
1929 return null; | 1867 return null; |
1930 } | 1868 } |
1931 | 1869 |
1932 @override | 1870 @override |
1933 CompilationUnitElement getCompilationUnitElement(Source unitSource, | 1871 CompilationUnitElement getCompilationUnitElement( |
1934 Source librarySource) { | 1872 Source unitSource, Source librarySource) { |
1935 LibraryElement libraryElement = getLibraryElement(librarySource); | 1873 LibraryElement libraryElement = getLibraryElement(librarySource); |
1936 if (libraryElement != null) { | 1874 if (libraryElement != null) { |
1937 // try defining unit | 1875 // try defining unit |
1938 CompilationUnitElement definingUnit = | 1876 CompilationUnitElement definingUnit = |
1939 libraryElement.definingCompilationUnit; | 1877 libraryElement.definingCompilationUnit; |
1940 if (definingUnit.source == unitSource) { | 1878 if (definingUnit.source == unitSource) { |
1941 return definingUnit; | 1879 return definingUnit; |
1942 } | 1880 } |
1943 // try parts | 1881 // try parts |
1944 for (CompilationUnitElement partUnit in libraryElement.parts) { | 1882 for (CompilationUnitElement partUnit in libraryElement.parts) { |
1945 if (partUnit.source == unitSource) { | 1883 if (partUnit.source == unitSource) { |
1946 return partUnit; | 1884 return partUnit; |
1947 } | 1885 } |
1948 } | 1886 } |
1949 } | 1887 } |
1950 return null; | 1888 return null; |
1951 } | 1889 } |
1952 | 1890 |
1953 @override | 1891 @override |
1954 TimestampedData<String> getContents(Source source) { | 1892 TimestampedData<String> getContents(Source source) { |
1955 String contents = _contentCache.getContents(source); | 1893 String contents = _contentCache.getContents(source); |
1956 if (contents != null) { | 1894 if (contents != null) { |
1957 return new TimestampedData<String>( | 1895 return new TimestampedData<String>( |
1958 _contentCache.getModificationStamp(source), | 1896 _contentCache.getModificationStamp(source), contents); |
1959 contents); | |
1960 } | 1897 } |
1961 return source.contents; | 1898 return source.contents; |
1962 } | 1899 } |
1963 | 1900 |
1964 @override | 1901 @override |
1965 InternalAnalysisContext getContextFor(Source source) { | 1902 InternalAnalysisContext getContextFor(Source source) { |
1966 InternalAnalysisContext context = _cache.getContextFor(source); | 1903 InternalAnalysisContext context = _cache.getContextFor(source); |
1967 return context == null ? this : context; | 1904 return context == null ? this : context; |
1968 } | 1905 } |
1969 | 1906 |
(...skipping 24 matching lines...) Expand all Loading... |
1994 } | 1931 } |
1995 return null; | 1932 return null; |
1996 } | 1933 } |
1997 | 1934 |
1998 @override | 1935 @override |
1999 AnalysisErrorInfo getErrors(Source source) { | 1936 AnalysisErrorInfo getErrors(Source source) { |
2000 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); | 1937 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); |
2001 if (sourceEntry is DartEntry) { | 1938 if (sourceEntry is DartEntry) { |
2002 DartEntry dartEntry = sourceEntry; | 1939 DartEntry dartEntry = sourceEntry; |
2003 return new AnalysisErrorInfoImpl( | 1940 return new AnalysisErrorInfoImpl( |
2004 dartEntry.allErrors, | 1941 dartEntry.allErrors, dartEntry.getValue(SourceEntry.LINE_INFO)); |
2005 dartEntry.getValue(SourceEntry.LINE_INFO)); | |
2006 } else if (sourceEntry is HtmlEntry) { | 1942 } else if (sourceEntry is HtmlEntry) { |
2007 HtmlEntry htmlEntry = sourceEntry; | 1943 HtmlEntry htmlEntry = sourceEntry; |
2008 return new AnalysisErrorInfoImpl( | 1944 return new AnalysisErrorInfoImpl( |
2009 htmlEntry.allErrors, | 1945 htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LINE_INFO)); |
2010 htmlEntry.getValue(SourceEntry.LINE_INFO)); | |
2011 } | 1946 } |
2012 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); | 1947 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); |
2013 } | 1948 } |
2014 | 1949 |
2015 @override | 1950 @override |
2016 HtmlElement getHtmlElement(Source source) { | 1951 HtmlElement getHtmlElement(Source source) { |
2017 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); | 1952 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); |
2018 if (sourceEntry is HtmlEntry) { | 1953 if (sourceEntry is HtmlEntry) { |
2019 return sourceEntry.getValue(HtmlEntry.ELEMENT); | 1954 return sourceEntry.getValue(HtmlEntry.ELEMENT); |
2020 } | 1955 } |
2021 return null; | 1956 return null; |
2022 } | 1957 } |
2023 | 1958 |
2024 @override | 1959 @override |
2025 List<Source> getHtmlFilesReferencing(Source source) { | 1960 List<Source> getHtmlFilesReferencing(Source source) { |
2026 SourceKind sourceKind = getKindOf(source); | 1961 SourceKind sourceKind = getKindOf(source); |
2027 if (sourceKind == null) { | 1962 if (sourceKind == null) { |
2028 return Source.EMPTY_ARRAY; | 1963 return Source.EMPTY_ARRAY; |
2029 } | 1964 } |
2030 List<Source> htmlSources = new List<Source>(); | 1965 List<Source> htmlSources = new List<Source>(); |
2031 while (true) { | 1966 while (true) { |
2032 if (sourceKind == SourceKind.PART) { | 1967 if (sourceKind == SourceKind.PART) { |
2033 List<Source> librarySources = getLibrariesContaining(source); | 1968 List<Source> librarySources = getLibrariesContaining(source); |
2034 MapIterator<Source, SourceEntry> partIterator = _cache.iterator(); | 1969 MapIterator<Source, SourceEntry> partIterator = _cache.iterator(); |
2035 while (partIterator.moveNext()) { | 1970 while (partIterator.moveNext()) { |
2036 SourceEntry sourceEntry = partIterator.value; | 1971 SourceEntry sourceEntry = partIterator.value; |
2037 if (sourceEntry.kind == SourceKind.HTML) { | 1972 if (sourceEntry.kind == SourceKind.HTML) { |
2038 List<Source> referencedLibraries = | 1973 List<Source> referencedLibraries = (sourceEntry as HtmlEntry) |
2039 (sourceEntry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARI
ES); | 1974 .getValue(HtmlEntry.REFERENCED_LIBRARIES); |
2040 if (_containsAny(referencedLibraries, librarySources)) { | 1975 if (_containsAny(referencedLibraries, librarySources)) { |
2041 htmlSources.add(partIterator.key); | 1976 htmlSources.add(partIterator.key); |
2042 } | 1977 } |
2043 } | 1978 } |
2044 } | 1979 } |
2045 } else { | 1980 } else { |
2046 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 1981 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
2047 while (iterator.moveNext()) { | 1982 while (iterator.moveNext()) { |
2048 SourceEntry sourceEntry = iterator.value; | 1983 SourceEntry sourceEntry = iterator.value; |
2049 if (sourceEntry.kind == SourceKind.HTML) { | 1984 if (sourceEntry.kind == SourceKind.HTML) { |
2050 List<Source> referencedLibraries = | 1985 List<Source> referencedLibraries = (sourceEntry as HtmlEntry) |
2051 (sourceEntry as HtmlEntry).getValue(HtmlEntry.REFERENCED_LIBRARI
ES); | 1986 .getValue(HtmlEntry.REFERENCED_LIBRARIES); |
2052 if (_contains(referencedLibraries, source)) { | 1987 if (_contains(referencedLibraries, source)) { |
2053 htmlSources.add(iterator.key); | 1988 htmlSources.add(iterator.key); |
2054 } | 1989 } |
2055 } | 1990 } |
2056 } | 1991 } |
2057 } | 1992 } |
2058 break; | 1993 break; |
2059 } | 1994 } |
2060 if (htmlSources.isEmpty) { | 1995 if (htmlSources.isEmpty) { |
2061 return Source.EMPTY_ARRAY; | 1996 return Source.EMPTY_ARRAY; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 Namespace namespace = null; | 2090 Namespace namespace = null; |
2156 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 2091 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
2157 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 2092 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
2158 } | 2093 } |
2159 if (namespace == null) { | 2094 if (namespace == null) { |
2160 NamespaceBuilder builder = new NamespaceBuilder(); | 2095 NamespaceBuilder builder = new NamespaceBuilder(); |
2161 namespace = builder.createPublicNamespaceForLibrary(library); | 2096 namespace = builder.createPublicNamespaceForLibrary(library); |
2162 if (dartEntry == null) { | 2097 if (dartEntry == null) { |
2163 AnalysisEngine.instance.logger.logError( | 2098 AnalysisEngine.instance.logger.logError( |
2164 "Could not compute the public namespace for ${library.source.fullNam
e}", | 2099 "Could not compute the public namespace for ${library.source.fullNam
e}", |
2165 new CaughtException( | 2100 new CaughtException(new AnalysisException( |
2166 new AnalysisException("A Dart file became a non-Dart file: ${sou
rce.fullName}"), | 2101 "A Dart file became a non-Dart file: ${source.fullName}"), |
2167 null)); | 2102 null)); |
2168 return null; | 2103 return null; |
2169 } | 2104 } |
2170 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 2105 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
2171 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 2106 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
2172 } | 2107 } |
2173 } | 2108 } |
2174 return namespace; | 2109 return namespace; |
2175 } | 2110 } |
2176 | 2111 |
2177 /** | 2112 /** |
2178 * Return the cache entry associated with the given source, or `null` if there
is no entry | 2113 * Return the cache entry associated with the given source, or `null` if there
is no entry |
2179 * associated with the source. | 2114 * associated with the source. |
2180 * | 2115 * |
2181 * @param source the source for which a cache entry is being sought | 2116 * @param source the source for which a cache entry is being sought |
2182 * @return the source cache entry associated with the given source | 2117 * @return the source cache entry associated with the given source |
2183 */ | 2118 */ |
2184 SourceEntry getReadableSourceEntryOrNull(Source source) => _cache.get(source); | 2119 SourceEntry getReadableSourceEntryOrNull(Source source) => _cache.get(source); |
2185 | 2120 |
2186 @override | 2121 @override |
2187 CompilationUnit getResolvedCompilationUnit(Source unitSource, | 2122 CompilationUnit getResolvedCompilationUnit( |
2188 LibraryElement library) { | 2123 Source unitSource, LibraryElement library) { |
2189 if (library == null) { | 2124 if (library == null) { |
2190 return null; | 2125 return null; |
2191 } | 2126 } |
2192 return getResolvedCompilationUnit2(unitSource, library.source); | 2127 return getResolvedCompilationUnit2(unitSource, library.source); |
2193 } | 2128 } |
2194 | 2129 |
2195 @override | 2130 @override |
2196 CompilationUnit getResolvedCompilationUnit2(Source unitSource, | 2131 CompilationUnit getResolvedCompilationUnit2( |
2197 Source librarySource) { | 2132 Source unitSource, Source librarySource) { |
2198 SourceEntry sourceEntry = getReadableSourceEntryOrNull(unitSource); | 2133 SourceEntry sourceEntry = getReadableSourceEntryOrNull(unitSource); |
2199 if (sourceEntry is DartEntry) { | 2134 if (sourceEntry is DartEntry) { |
2200 return sourceEntry.getValueInLibrary( | 2135 return sourceEntry.getValueInLibrary( |
2201 DartEntry.RESOLVED_UNIT, | 2136 DartEntry.RESOLVED_UNIT, librarySource); |
2202 librarySource); | |
2203 } | 2137 } |
2204 return null; | 2138 return null; |
2205 } | 2139 } |
2206 | 2140 |
2207 @override | 2141 @override |
2208 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 2142 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
2209 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); | 2143 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); |
2210 if (sourceEntry is HtmlEntry) { | 2144 if (sourceEntry is HtmlEntry) { |
2211 HtmlEntry htmlEntry = sourceEntry; | 2145 HtmlEntry htmlEntry = sourceEntry; |
2212 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2146 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
2213 } | 2147 } |
2214 return null; | 2148 return null; |
2215 } | 2149 } |
2216 | 2150 |
2217 @override | 2151 @override |
2218 bool handleContentsChanged(Source source, String originalContents, | 2152 bool handleContentsChanged( |
2219 String newContents, bool notify) { | 2153 Source source, String originalContents, String newContents, bool notify) { |
2220 SourceEntry sourceEntry = _cache.get(source); | 2154 SourceEntry sourceEntry = _cache.get(source); |
2221 if (sourceEntry == null) { | 2155 if (sourceEntry == null) { |
2222 return false; | 2156 return false; |
2223 } | 2157 } |
2224 bool changed = newContents != originalContents; | 2158 bool changed = newContents != originalContents; |
2225 if (newContents != null) { | 2159 if (newContents != null) { |
2226 if (newContents != originalContents) { | 2160 if (newContents != originalContents) { |
2227 _incrementalAnalysisCache = | 2161 _incrementalAnalysisCache = |
2228 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 2162 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
2229 if (!analysisOptions.incremental || | 2163 if (!analysisOptions.incremental || |
(...skipping 14 matching lines...) Expand all Loading... |
2244 // We are removing the overlay for the file, check if the file's | 2178 // We are removing the overlay for the file, check if the file's |
2245 // contents is the same as it was in the overlay. | 2179 // contents is the same as it was in the overlay. |
2246 try { | 2180 try { |
2247 TimestampedData<String> fileContents = getContents(source); | 2181 TimestampedData<String> fileContents = getContents(source); |
2248 String fileContentsData = fileContents.data; | 2182 String fileContentsData = fileContents.data; |
2249 if (fileContentsData == originalContents) { | 2183 if (fileContentsData == originalContents) { |
2250 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData); | 2184 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData); |
2251 sourceEntry.modificationTime = fileContents.modificationTime; | 2185 sourceEntry.modificationTime = fileContents.modificationTime; |
2252 changed = false; | 2186 changed = false; |
2253 } | 2187 } |
2254 } catch (e) { | 2188 } catch (e) {} |
2255 } | |
2256 // If not the same content (e.g. the file is being closed without save), | 2189 // If not the same content (e.g. the file is being closed without save), |
2257 // then force analysis. | 2190 // then force analysis. |
2258 if (changed) { | 2191 if (changed) { |
2259 _sourceChanged(source); | 2192 _sourceChanged(source); |
2260 } | 2193 } |
2261 } | 2194 } |
2262 if (notify && changed) { | 2195 if (notify && changed) { |
2263 _onSourcesChangedController.add( | 2196 _onSourcesChangedController |
2264 new SourcesChangedEvent.changedContent(source, newContents)); | 2197 .add(new SourcesChangedEvent.changedContent(source, newContents)); |
2265 } | 2198 } |
2266 return changed; | 2199 return changed; |
2267 } | 2200 } |
2268 | 2201 |
2269 /** | 2202 /** |
2270 * Invalidates hints in the given [librarySource] and included parts. | 2203 * Invalidates hints in the given [librarySource] and included parts. |
2271 */ | 2204 */ |
2272 void invalidateLibraryHints(Source librarySource) { | 2205 void invalidateLibraryHints(Source librarySource) { |
2273 SourceEntry sourceEntry = _cache.get(librarySource); | 2206 SourceEntry sourceEntry = _cache.get(librarySource); |
2274 if (sourceEntry is! DartEntry) { | 2207 if (sourceEntry is! DartEntry) { |
2275 return; | 2208 return; |
2276 } | 2209 } |
2277 DartEntry dartEntry = sourceEntry; | 2210 DartEntry dartEntry = sourceEntry; |
2278 // Prepare sources to invalidate hints in. | 2211 // Prepare sources to invalidate hints in. |
2279 List<Source> sources = <Source>[librarySource]; | 2212 List<Source> sources = <Source>[librarySource]; |
2280 sources.addAll(dartEntry.getValue(DartEntry.INCLUDED_PARTS)); | 2213 sources.addAll(dartEntry.getValue(DartEntry.INCLUDED_PARTS)); |
2281 // Invalidate hints. | 2214 // Invalidate hints. |
2282 for (Source source in sources) { | 2215 for (Source source in sources) { |
2283 DartEntry dartEntry = _cache.get(source); | 2216 DartEntry dartEntry = _cache.get(source); |
2284 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == | 2217 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == |
2285 CacheState.VALID) { | 2218 CacheState.VALID) { |
2286 dartEntry.setStateInLibrary( | 2219 dartEntry.setStateInLibrary( |
2287 DartEntry.HINTS, | 2220 DartEntry.HINTS, librarySource, CacheState.INVALID); |
2288 librarySource, | |
2289 CacheState.INVALID); | |
2290 } | 2221 } |
2291 } | 2222 } |
2292 } | 2223 } |
2293 | 2224 |
2294 @override | 2225 @override |
2295 bool isClientLibrary(Source librarySource) { | 2226 bool isClientLibrary(Source librarySource) { |
2296 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); | 2227 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); |
2297 if (sourceEntry is DartEntry) { | 2228 if (sourceEntry is DartEntry) { |
2298 DartEntry dartEntry = sourceEntry; | 2229 DartEntry dartEntry = sourceEntry; |
2299 return dartEntry.getValue(DartEntry.IS_CLIENT) && | 2230 return dartEntry.getValue(DartEntry.IS_CLIENT) && |
(...skipping 21 matching lines...) Expand all Loading... |
2321 ht.HtmlUnit parseHtmlUnit(Source source) => | 2252 ht.HtmlUnit parseHtmlUnit(Source source) => |
2322 _getHtmlParseData(source, HtmlEntry.PARSED_UNIT, null); | 2253 _getHtmlParseData(source, HtmlEntry.PARSED_UNIT, null); |
2323 | 2254 |
2324 @override | 2255 @override |
2325 AnalysisResult performAnalysisTask() { | 2256 AnalysisResult performAnalysisTask() { |
2326 if (_TRACE_PERFORM_TASK) { | 2257 if (_TRACE_PERFORM_TASK) { |
2327 print("----------------------------------------"); | 2258 print("----------------------------------------"); |
2328 } | 2259 } |
2329 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { | 2260 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { |
2330 int getStart = JavaSystem.currentTimeMillis(); | 2261 int getStart = JavaSystem.currentTimeMillis(); |
2331 AnalysisTask task = | 2262 AnalysisTask task = PerformanceStatistics.nextTask |
2332 PerformanceStatistics.nextTask.makeCurrentWhile(() => nextAnalysisTask
); | 2263 .makeCurrentWhile(() => nextAnalysisTask); |
2333 int getEnd = JavaSystem.currentTimeMillis(); | 2264 int getEnd = JavaSystem.currentTimeMillis(); |
2334 if (task == null && _validateCacheConsistency()) { | 2265 if (task == null && _validateCacheConsistency()) { |
2335 task = nextAnalysisTask; | 2266 task = nextAnalysisTask; |
2336 } | 2267 } |
2337 if (task == null) { | 2268 if (task == null) { |
2338 _validateLastIncrementalResolutionResult(); | 2269 _validateLastIncrementalResolutionResult(); |
2339 if (_performAnalysisTaskStopwatch != null) { | 2270 if (_performAnalysisTaskStopwatch != null) { |
2340 AnalysisEngine.instance.instrumentationService.logPerformance( | 2271 AnalysisEngine.instance.instrumentationService.logPerformance( |
2341 AnalysisPerformanceKind.FULL, | 2272 AnalysisPerformanceKind.FULL, _performAnalysisTaskStopwatch, |
2342 _performAnalysisTaskStopwatch, | |
2343 'context_id=$_id'); | 2273 'context_id=$_id'); |
2344 _performAnalysisTaskStopwatch = null; | 2274 _performAnalysisTaskStopwatch = null; |
2345 } | 2275 } |
2346 return new AnalysisResult( | 2276 return new AnalysisResult( |
2347 _getChangeNotices(true), | 2277 _getChangeNotices(true), getEnd - getStart, null, -1); |
2348 getEnd - getStart, | |
2349 null, | |
2350 -1); | |
2351 } | 2278 } |
2352 if (_performAnalysisTaskStopwatch == null) { | 2279 if (_performAnalysisTaskStopwatch == null) { |
2353 _performAnalysisTaskStopwatch = new Stopwatch()..start(); | 2280 _performAnalysisTaskStopwatch = new Stopwatch()..start(); |
2354 } | 2281 } |
2355 String taskDescription = task.toString(); | 2282 String taskDescription = task.toString(); |
2356 _notifyAboutToPerformTask(taskDescription); | 2283 _notifyAboutToPerformTask(taskDescription); |
2357 if (_TRACE_PERFORM_TASK) { | 2284 if (_TRACE_PERFORM_TASK) { |
2358 print(taskDescription); | 2285 print(taskDescription); |
2359 } | 2286 } |
2360 int performStart = JavaSystem.currentTimeMillis(); | 2287 int performStart = JavaSystem.currentTimeMillis(); |
(...skipping 20 matching lines...) Expand all Loading... |
2381 // always resolved, or whether we need to decide whether to invoke the | 2308 // always resolved, or whether we need to decide whether to invoke the |
2382 // "parsed" or "resolved" method. This might be better done when | 2309 // "parsed" or "resolved" method. This might be better done when |
2383 // recording task results in order to reduce the chance of errors. | 2310 // recording task results in order to reduce the chance of errors. |
2384 // if (notice.getCompilationUnit() != null) { | 2311 // if (notice.getCompilationUnit() != null) { |
2385 // notifyResolvedDart(source, notice.getCompilationUnit()); | 2312 // notifyResolvedDart(source, notice.getCompilationUnit()); |
2386 // } else if (notice.getHtmlUnit() != null) { | 2313 // } else if (notice.getHtmlUnit() != null) { |
2387 // notifyResolvedHtml(source, notice.getHtmlUnit()); | 2314 // notifyResolvedHtml(source, notice.getHtmlUnit()); |
2388 // } | 2315 // } |
2389 _notifyErrors(source, notice.errors, notice.lineInfo); | 2316 _notifyErrors(source, notice.errors, notice.lineInfo); |
2390 } | 2317 } |
2391 return new AnalysisResult( | 2318 return new AnalysisResult(notices, getEnd - getStart, |
2392 notices, | 2319 task.runtimeType.toString(), performEnd - performStart); |
2393 getEnd - getStart, | |
2394 task.runtimeType.toString(), | |
2395 performEnd - performStart); | |
2396 }); | 2320 }); |
2397 } | 2321 } |
2398 | 2322 |
2399 @override | 2323 @override |
2400 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 2324 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
2401 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | 2325 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
2402 elementMap.forEach((Source librarySource, LibraryElement library) { | 2326 elementMap.forEach((Source librarySource, LibraryElement library) { |
2403 // | 2327 // |
2404 // Cache the element in the library's info. | 2328 // Cache the element in the library's info. |
2405 // | 2329 // |
2406 DartEntry dartEntry = _getReadableDartEntry(librarySource); | 2330 DartEntry dartEntry = _getReadableDartEntry(librarySource); |
2407 if (dartEntry != null) { | 2331 if (dartEntry != null) { |
2408 _recordElementData(dartEntry, library, library.source, htmlSource); | 2332 _recordElementData(dartEntry, library, library.source, htmlSource); |
2409 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 2333 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
2410 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); | 2334 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); |
2411 // DartEntry.ELEMENT - set in recordElementData | 2335 // DartEntry.ELEMENT - set in recordElementData |
2412 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 2336 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
2413 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 2337 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
2414 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); | 2338 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); |
2415 // DartEntry.IS_CLIENT - set in recordElementData | 2339 // DartEntry.IS_CLIENT - set in recordElementData |
2416 // DartEntry.IS_LAUNCHABLE - set in recordElementData | 2340 // DartEntry.IS_LAUNCHABLE - set in recordElementData |
2417 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); | 2341 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); |
2418 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 2342 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
2419 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED); | 2343 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED); |
2420 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); | 2344 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); |
2421 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 2345 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
2422 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); | 2346 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); |
| 2347 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, |
| 2348 librarySource, AnalysisError.NO_ERRORS); |
| 2349 dartEntry.setStateInLibrary( |
| 2350 DartEntry.RESOLVED_UNIT, librarySource, CacheState.FLUSHED); |
| 2351 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, |
| 2352 librarySource, AnalysisError.NO_ERRORS); |
2423 dartEntry.setValueInLibrary( | 2353 dartEntry.setValueInLibrary( |
2424 DartEntry.RESOLUTION_ERRORS, | 2354 DartEntry.HINTS, librarySource, AnalysisError.NO_ERRORS); |
2425 librarySource, | |
2426 AnalysisError.NO_ERRORS); | |
2427 dartEntry.setStateInLibrary( | |
2428 DartEntry.RESOLVED_UNIT, | |
2429 librarySource, | |
2430 CacheState.FLUSHED); | |
2431 dartEntry.setValueInLibrary( | 2355 dartEntry.setValueInLibrary( |
2432 DartEntry.VERIFICATION_ERRORS, | 2356 DartEntry.LINTS, librarySource, AnalysisError.NO_ERRORS); |
2433 librarySource, | |
2434 AnalysisError.NO_ERRORS); | |
2435 dartEntry.setValueInLibrary( | |
2436 DartEntry.HINTS, | |
2437 librarySource, | |
2438 AnalysisError.NO_ERRORS); | |
2439 dartEntry.setValueInLibrary( | |
2440 DartEntry.LINTS, | |
2441 librarySource, | |
2442 AnalysisError.NO_ERRORS); | |
2443 } | 2357 } |
2444 }); | 2358 }); |
2445 } | 2359 } |
2446 | 2360 |
2447 /** | 2361 /** |
2448 * Record the results produced by performing a [task] and return the cache | 2362 * Record the results produced by performing a [task] and return the cache |
2449 * entry associated with the results. | 2363 * entry associated with the results. |
2450 */ | 2364 */ |
2451 DartEntry | 2365 DartEntry recordResolveDartLibraryCycleTaskResults( |
2452 recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task)
{ | 2366 ResolveDartLibraryCycleTask task) { |
2453 LibraryResolver2 resolver = task.libraryResolver; | 2367 LibraryResolver2 resolver = task.libraryResolver; |
2454 CaughtException thrownException = task.exception; | 2368 CaughtException thrownException = task.exception; |
2455 Source unitSource = task.unitSource; | 2369 Source unitSource = task.unitSource; |
2456 DartEntry unitEntry = _getReadableDartEntry(unitSource); | 2370 DartEntry unitEntry = _getReadableDartEntry(unitSource); |
2457 if (resolver != null) { | 2371 if (resolver != null) { |
2458 // | 2372 // |
2459 // The resolver should only be null if an exception was thrown before (or | 2373 // The resolver should only be null if an exception was thrown before (or |
2460 // while) it was being created. | 2374 // while) it was being created. |
2461 // | 2375 // |
2462 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries; | 2376 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries; |
2463 if (resolvedLibraries == null) { | 2377 if (resolvedLibraries == null) { |
2464 // | 2378 // |
2465 // The resolved libraries should only be null if an exception was thrown | 2379 // The resolved libraries should only be null if an exception was thrown |
2466 // during resolution. | 2380 // during resolution. |
2467 // | 2381 // |
2468 if (thrownException == null) { | 2382 if (thrownException == null) { |
2469 var message = | 2383 var message = "In recordResolveDartLibraryCycleTaskResults, " |
2470 "In recordResolveDartLibraryCycleTaskResults, " | 2384 "resolvedLibraries was null and there was no thrown exception"; |
2471 "resolvedLibraries was null and there was no thrown exception"
; | |
2472 unitEntry.recordResolutionError( | 2385 unitEntry.recordResolutionError( |
2473 new CaughtException(new AnalysisException(message), null)); | 2386 new CaughtException(new AnalysisException(message), null)); |
2474 } else { | 2387 } else { |
2475 unitEntry.recordResolutionError(thrownException); | 2388 unitEntry.recordResolutionError(thrownException); |
2476 } | 2389 } |
2477 _cache.remove(unitSource); | 2390 _cache.remove(unitSource); |
2478 if (thrownException != null) { | 2391 if (thrownException != null) { |
2479 throw new AnalysisException('<rethrow>', thrownException); | 2392 throw new AnalysisException('<rethrow>', thrownException); |
2480 } | 2393 } |
2481 return unitEntry; | 2394 return unitEntry; |
2482 } | 2395 } |
2483 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 2396 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
2484 RecordingErrorListener errorListener = resolver.errorListener; | 2397 RecordingErrorListener errorListener = resolver.errorListener; |
2485 for (ResolvableLibrary library in resolvedLibraries) { | 2398 for (ResolvableLibrary library in resolvedLibraries) { |
2486 Source librarySource = library.librarySource; | 2399 Source librarySource = library.librarySource; |
2487 for (Source source in library.compilationUnitSources) { | 2400 for (Source source in library.compilationUnitSources) { |
2488 CompilationUnit unit = library.getAST(source); | 2401 CompilationUnit unit = library.getAST(source); |
2489 List<AnalysisError> errors = errorListener.getErrorsForSource(source); | 2402 List<AnalysisError> errors = errorListener.getErrorsForSource(source); |
2490 LineInfo lineInfo = getLineInfo(source); | 2403 LineInfo lineInfo = getLineInfo(source); |
2491 DartEntry dartEntry = _cache.get(source); | 2404 DartEntry dartEntry = _cache.get(source); |
2492 if (thrownException == null) { | 2405 if (thrownException == null) { |
2493 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 2406 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
2494 dartEntry.setValueInLibrary( | 2407 dartEntry.setValueInLibrary( |
2495 DartEntry.RESOLVED_UNIT, | 2408 DartEntry.RESOLVED_UNIT, librarySource, unit); |
2496 librarySource, | |
2497 unit); | |
2498 dartEntry.setValueInLibrary( | 2409 dartEntry.setValueInLibrary( |
2499 DartEntry.RESOLUTION_ERRORS, | 2410 DartEntry.RESOLUTION_ERRORS, librarySource, errors); |
2500 librarySource, | |
2501 errors); | |
2502 if (source == librarySource) { | 2411 if (source == librarySource) { |
2503 _recordElementData( | 2412 _recordElementData( |
2504 dartEntry, | 2413 dartEntry, library.libraryElement, librarySource, htmlSource); |
2505 library.libraryElement, | |
2506 librarySource, | |
2507 htmlSource); | |
2508 } | 2414 } |
2509 _cache.storedAst(source); | 2415 _cache.storedAst(source); |
2510 } else { | 2416 } else { |
2511 dartEntry.recordResolutionErrorInLibrary( | 2417 dartEntry.recordResolutionErrorInLibrary( |
2512 librarySource, | 2418 librarySource, thrownException); |
2513 thrownException); | |
2514 } | 2419 } |
2515 if (source != librarySource) { | 2420 if (source != librarySource) { |
2516 _workManager.add(source, SourcePriority.PRIORITY_PART); | 2421 _workManager.add(source, SourcePriority.PRIORITY_PART); |
2517 } | 2422 } |
2518 ChangeNoticeImpl notice = _getNotice(source); | 2423 ChangeNoticeImpl notice = _getNotice(source); |
2519 notice.resolvedDartUnit = unit; | 2424 notice.resolvedDartUnit = unit; |
2520 notice.setErrors(dartEntry.allErrors, lineInfo); | 2425 notice.setErrors(dartEntry.allErrors, lineInfo); |
2521 } | 2426 } |
2522 } | 2427 } |
2523 } | 2428 } |
(...skipping 17 matching lines...) Expand all Loading... |
2541 // The resolver should only be null if an exception was thrown before (or | 2446 // The resolver should only be null if an exception was thrown before (or |
2542 // while) it was being created. | 2447 // while) it was being created. |
2543 // | 2448 // |
2544 Set<Library> resolvedLibraries = resolver.resolvedLibraries; | 2449 Set<Library> resolvedLibraries = resolver.resolvedLibraries; |
2545 if (resolvedLibraries == null) { | 2450 if (resolvedLibraries == null) { |
2546 // | 2451 // |
2547 // The resolved libraries should only be null if an exception was thrown | 2452 // The resolved libraries should only be null if an exception was thrown |
2548 // during resolution. | 2453 // during resolution. |
2549 // | 2454 // |
2550 if (thrownException == null) { | 2455 if (thrownException == null) { |
2551 String message = | 2456 String message = "In recordResolveDartLibraryTaskResults, " |
2552 "In recordResolveDartLibraryTaskResults, " | 2457 "resolvedLibraries was null and there was no thrown exception"; |
2553 "resolvedLibraries was null and there was no thrown exception"
; | |
2554 unitEntry.recordResolutionError( | 2458 unitEntry.recordResolutionError( |
2555 new CaughtException(new AnalysisException(message), null)); | 2459 new CaughtException(new AnalysisException(message), null)); |
2556 } else { | 2460 } else { |
2557 unitEntry.recordResolutionError(thrownException); | 2461 unitEntry.recordResolutionError(thrownException); |
2558 } | 2462 } |
2559 _cache.remove(unitSource); | 2463 _cache.remove(unitSource); |
2560 if (thrownException != null) { | 2464 if (thrownException != null) { |
2561 throw new AnalysisException('<rethrow>', thrownException); | 2465 throw new AnalysisException('<rethrow>', thrownException); |
2562 } | 2466 } |
2563 return unitEntry; | 2467 return unitEntry; |
2564 } | 2468 } |
2565 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 2469 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
2566 RecordingErrorListener errorListener = resolver.errorListener; | 2470 RecordingErrorListener errorListener = resolver.errorListener; |
2567 for (Library library in resolvedLibraries) { | 2471 for (Library library in resolvedLibraries) { |
2568 Source librarySource = library.librarySource; | 2472 Source librarySource = library.librarySource; |
2569 for (Source source in library.compilationUnitSources) { | 2473 for (Source source in library.compilationUnitSources) { |
2570 CompilationUnit unit = library.getAST(source); | 2474 CompilationUnit unit = library.getAST(source); |
2571 List<AnalysisError> errors = errorListener.getErrorsForSource(source); | 2475 List<AnalysisError> errors = errorListener.getErrorsForSource(source); |
2572 LineInfo lineInfo = getLineInfo(source); | 2476 LineInfo lineInfo = getLineInfo(source); |
2573 DartEntry dartEntry = _cache.get(source); | 2477 DartEntry dartEntry = _cache.get(source); |
2574 if (thrownException == null) { | 2478 if (thrownException == null) { |
2575 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 2479 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
2576 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 2480 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
2577 dartEntry.setValueInLibrary( | 2481 dartEntry.setValueInLibrary( |
2578 DartEntry.RESOLVED_UNIT, | 2482 DartEntry.RESOLVED_UNIT, librarySource, unit); |
2579 librarySource, | |
2580 unit); | |
2581 dartEntry.setValueInLibrary( | 2483 dartEntry.setValueInLibrary( |
2582 DartEntry.RESOLUTION_ERRORS, | 2484 DartEntry.RESOLUTION_ERRORS, librarySource, errors); |
2583 librarySource, | |
2584 errors); | |
2585 if (source == librarySource) { | 2485 if (source == librarySource) { |
2586 _recordElementData( | 2486 _recordElementData( |
2587 dartEntry, | 2487 dartEntry, library.libraryElement, librarySource, htmlSource); |
2588 library.libraryElement, | |
2589 librarySource, | |
2590 htmlSource); | |
2591 } | 2488 } |
2592 _cache.storedAst(source); | 2489 _cache.storedAst(source); |
2593 } else { | 2490 } else { |
2594 dartEntry.recordResolutionErrorInLibrary( | 2491 dartEntry.recordResolutionErrorInLibrary( |
2595 librarySource, | 2492 librarySource, thrownException); |
2596 thrownException); | |
2597 _cache.remove(source); | 2493 _cache.remove(source); |
2598 } | 2494 } |
2599 if (source != librarySource) { | 2495 if (source != librarySource) { |
2600 _workManager.add(source, SourcePriority.PRIORITY_PART); | 2496 _workManager.add(source, SourcePriority.PRIORITY_PART); |
2601 } | 2497 } |
2602 ChangeNoticeImpl notice = _getNotice(source); | 2498 ChangeNoticeImpl notice = _getNotice(source); |
2603 notice.resolvedDartUnit = unit; | 2499 notice.resolvedDartUnit = unit; |
2604 notice.setErrors(dartEntry.allErrors, lineInfo); | 2500 notice.setErrors(dartEntry.allErrors, lineInfo); |
2605 } | 2501 } |
2606 } | 2502 } |
2607 } | 2503 } |
2608 if (thrownException != null) { | 2504 if (thrownException != null) { |
2609 throw new AnalysisException('<rethrow>', thrownException); | 2505 throw new AnalysisException('<rethrow>', thrownException); |
2610 } | 2506 } |
2611 return unitEntry; | 2507 return unitEntry; |
2612 } | 2508 } |
2613 | 2509 |
2614 @override | 2510 @override |
2615 void removeListener(AnalysisListener listener) { | 2511 void removeListener(AnalysisListener listener) { |
2616 _listeners.remove(listener); | 2512 _listeners.remove(listener); |
2617 } | 2513 } |
2618 | 2514 |
2619 @override | 2515 @override |
2620 CompilationUnit resolveCompilationUnit(Source unitSource, | 2516 CompilationUnit resolveCompilationUnit( |
2621 LibraryElement library) { | 2517 Source unitSource, LibraryElement library) { |
2622 if (library == null) { | 2518 if (library == null) { |
2623 return null; | 2519 return null; |
2624 } | 2520 } |
2625 return resolveCompilationUnit2(unitSource, library.source); | 2521 return resolveCompilationUnit2(unitSource, library.source); |
2626 } | 2522 } |
2627 | 2523 |
2628 @override | 2524 @override |
2629 CompilationUnit resolveCompilationUnit2(Source unitSource, | 2525 CompilationUnit resolveCompilationUnit2( |
2630 Source librarySource) => | 2526 Source unitSource, Source librarySource) => _getDartResolutionData2( |
2631 _getDartResolutionData2( | 2527 unitSource, librarySource, DartEntry.RESOLVED_UNIT, null); |
2632 unitSource, | |
2633 librarySource, | |
2634 DartEntry.RESOLVED_UNIT, | |
2635 null); | |
2636 | 2528 |
2637 @override | 2529 @override |
2638 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 2530 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
2639 computeHtmlElement(htmlSource); | 2531 computeHtmlElement(htmlSource); |
2640 return parseHtmlUnit(htmlSource); | 2532 return parseHtmlUnit(htmlSource); |
2641 } | 2533 } |
2642 | 2534 |
2643 @override | 2535 @override |
2644 void setChangedContents(Source source, String contents, int offset, | 2536 void setChangedContents(Source source, String contents, int offset, |
2645 int oldLength, int newLength) { | 2537 int oldLength, int newLength) { |
2646 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { | 2538 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { |
2647 _onSourcesChangedController.add( | 2539 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( |
2648 new SourcesChangedEvent.changedRange( | 2540 source, contents, offset, oldLength, newLength)); |
2649 source, | |
2650 contents, | |
2651 offset, | |
2652 oldLength, | |
2653 newLength)); | |
2654 } | 2541 } |
2655 } | 2542 } |
2656 | 2543 |
2657 @override | 2544 @override |
2658 void setContents(Source source, String contents) { | 2545 void setContents(Source source, String contents) { |
2659 _contentsChanged(source, contents, true); | 2546 _contentsChanged(source, contents, true); |
2660 } | 2547 } |
2661 | 2548 |
2662 @override | 2549 @override |
2663 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 2550 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
(...skipping 14 matching lines...) Expand all Loading... |
2678 continue; | 2565 continue; |
2679 } else if (descriptor == DartEntry.PUBLIC_NAMESPACE) { | 2566 } else if (descriptor == DartEntry.PUBLIC_NAMESPACE) { |
2680 // The public namespace isn't computed by performAnalysisTask() | 2567 // The public namespace isn't computed by performAnalysisTask() |
2681 // and therefore isn't interesting. | 2568 // and therefore isn't interesting. |
2682 continue; | 2569 continue; |
2683 } else if (descriptor == HtmlEntry.HINTS) { | 2570 } else if (descriptor == HtmlEntry.HINTS) { |
2684 // We are not currently recording any hints related to HTML. | 2571 // We are not currently recording any hints related to HTML. |
2685 continue; | 2572 continue; |
2686 } | 2573 } |
2687 callback( | 2574 callback( |
2688 source, | 2575 source, sourceEntry, descriptor, sourceEntry.getState(descriptor)); |
2689 sourceEntry, | |
2690 descriptor, | |
2691 sourceEntry.getState(descriptor)); | |
2692 } | 2576 } |
2693 if (sourceEntry is DartEntry) { | 2577 if (sourceEntry is DartEntry) { |
2694 // get library-specific values | 2578 // get library-specific values |
2695 List<Source> librarySources = getLibrariesContaining(source); | 2579 List<Source> librarySources = getLibrariesContaining(source); |
2696 for (Source librarySource in librarySources) { | 2580 for (Source librarySource in librarySources) { |
2697 for (DataDescriptor descriptor in sourceEntry.libraryDescriptors) { | 2581 for (DataDescriptor descriptor in sourceEntry.libraryDescriptors) { |
2698 if (descriptor == DartEntry.BUILT_ELEMENT || | 2582 if (descriptor == DartEntry.BUILT_ELEMENT || |
2699 descriptor == DartEntry.BUILT_UNIT) { | 2583 descriptor == DartEntry.BUILT_UNIT) { |
2700 // These values are not currently being computed, so their state | 2584 // These values are not currently being computed, so their state |
2701 // is not interesting. | 2585 // is not interesting. |
2702 continue; | 2586 continue; |
2703 } else if (source.isInSystemLibrary && | 2587 } else if (source.isInSystemLibrary && |
2704 !_generateSdkErrors && | 2588 !_generateSdkErrors && |
2705 (descriptor == DartEntry.VERIFICATION_ERRORS || | 2589 (descriptor == DartEntry.VERIFICATION_ERRORS || |
2706 descriptor == DartEntry.HINTS || | 2590 descriptor == DartEntry.HINTS || |
2707 descriptor == DartEntry.LINTS)) { | 2591 descriptor == DartEntry.LINTS)) { |
2708 continue; | 2592 continue; |
2709 } else if (!hintsEnabled && descriptor == DartEntry.HINTS) { | 2593 } else if (!hintsEnabled && descriptor == DartEntry.HINTS) { |
2710 continue; | 2594 continue; |
2711 } else if (!lintsEnabled && descriptor == DartEntry.LINTS) { | 2595 } else if (!lintsEnabled && descriptor == DartEntry.LINTS) { |
2712 continue; | 2596 continue; |
2713 } | 2597 } |
2714 callback( | 2598 callback(librarySource, sourceEntry, descriptor, |
2715 librarySource, | |
2716 sourceEntry, | |
2717 descriptor, | |
2718 sourceEntry.getStateInLibrary(descriptor, librarySource)); | 2599 sourceEntry.getStateInLibrary(descriptor, librarySource)); |
2719 } | 2600 } |
2720 } | 2601 } |
2721 } | 2602 } |
2722 } | 2603 } |
2723 } | 2604 } |
2724 | 2605 |
2725 /** | 2606 /** |
2726 * Visit all entries of the content cache. | 2607 * Visit all entries of the content cache. |
2727 */ | 2608 */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2779 // | 2660 // |
2780 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); | 2661 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); |
2781 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2662 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2782 // | 2663 // |
2783 // If not, compute the information. | 2664 // If not, compute the information. |
2784 // Unless the modification date of the source continues to change, | 2665 // Unless the modification date of the source continues to change, |
2785 // this loop will eventually terminate. | 2666 // this loop will eventually terminate. |
2786 // | 2667 // |
2787 DartEntry libraryEntry = _getReadableDartEntry(librarySource); | 2668 DartEntry libraryEntry = _getReadableDartEntry(librarySource); |
2788 libraryEntry = _cacheDartResolutionData( | 2669 libraryEntry = _cacheDartResolutionData( |
2789 librarySource, | 2670 librarySource, librarySource, libraryEntry, DartEntry.ELEMENT); |
2790 librarySource, | |
2791 libraryEntry, | |
2792 DartEntry.ELEMENT); | |
2793 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); | 2671 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
2794 CompilationUnitElement definingUnit = | 2672 CompilationUnitElement definingUnit = |
2795 libraryElement.definingCompilationUnit; | 2673 libraryElement.definingCompilationUnit; |
2796 List<CompilationUnitElement> parts = libraryElement.parts; | 2674 List<CompilationUnitElement> parts = libraryElement.parts; |
2797 List<TimestampedData<CompilationUnit>> units = | 2675 List<TimestampedData<CompilationUnit>> units = |
2798 new List<TimestampedData>(parts.length + 1); | 2676 new List<TimestampedData>(parts.length + 1); |
2799 units[0] = _getResolvedUnit(definingUnit, librarySource); | 2677 units[0] = _getResolvedUnit(definingUnit, librarySource); |
2800 if (units[0] == null) { | 2678 if (units[0] == null) { |
2801 Source source = definingUnit.source; | 2679 Source source = definingUnit.source; |
2802 units[0] = new TimestampedData<CompilationUnit>( | 2680 units[0] = new TimestampedData<CompilationUnit>( |
2803 getModificationStamp(source), | 2681 getModificationStamp(source), |
2804 resolveCompilationUnit(source, libraryElement)); | 2682 resolveCompilationUnit(source, libraryElement)); |
2805 } | 2683 } |
2806 for (int i = 0; i < parts.length; i++) { | 2684 for (int i = 0; i < parts.length; i++) { |
2807 units[i + 1] = _getResolvedUnit(parts[i], librarySource); | 2685 units[i + 1] = _getResolvedUnit(parts[i], librarySource); |
2808 if (units[i + 1] == null) { | 2686 if (units[i + 1] == null) { |
2809 Source source = parts[i].source; | 2687 Source source = parts[i].source; |
2810 units[i + | 2688 units[i + 1] = new TimestampedData<CompilationUnit>( |
2811 1] = new TimestampedData<CompilationUnit>( | 2689 getModificationStamp(source), |
2812 getModificationStamp(source), | 2690 resolveCompilationUnit(source, libraryElement)); |
2813 resolveCompilationUnit(source, libraryElement)); | |
2814 } | 2691 } |
2815 } | 2692 } |
2816 dartEntry = new GenerateDartHintsTask( | 2693 dartEntry = new GenerateDartHintsTask( |
2817 this, | 2694 this, units, getLibraryElement(librarySource)) |
2818 units, | 2695 .perform(_resultRecorder) as DartEntry; |
2819 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr
y; | |
2820 state = dartEntry.getStateInLibrary(descriptor, librarySource); | 2696 state = dartEntry.getStateInLibrary(descriptor, librarySource); |
2821 } | 2697 } |
2822 return dartEntry; | 2698 return dartEntry; |
2823 } | 2699 } |
2824 | 2700 |
2825 /** | 2701 /** |
2826 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 2702 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
2827 * the state of the data represented by the given descriptor is either [CacheS
tate.VALID] or | 2703 * the state of the data represented by the given descriptor is either [CacheS
tate.VALID] or |
2828 * [CacheStateERROR]. This method assumes that the data can be produced by gen
erating lints | 2704 * [CacheStateERROR]. This method assumes that the data can be produced by gen
erating lints |
2829 * for the library if the data is not already cached. | 2705 * for the library if the data is not already cached. |
(...skipping 14 matching lines...) Expand all Loading... |
2844 // | 2720 // |
2845 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); | 2721 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); |
2846 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2722 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2847 // | 2723 // |
2848 // If not, compute the information. | 2724 // If not, compute the information. |
2849 // Unless the modification date of the source continues to change, | 2725 // Unless the modification date of the source continues to change, |
2850 // this loop will eventually terminate. | 2726 // this loop will eventually terminate. |
2851 // | 2727 // |
2852 DartEntry libraryEntry = _getReadableDartEntry(librarySource); | 2728 DartEntry libraryEntry = _getReadableDartEntry(librarySource); |
2853 libraryEntry = _cacheDartResolutionData( | 2729 libraryEntry = _cacheDartResolutionData( |
2854 librarySource, | 2730 librarySource, librarySource, libraryEntry, DartEntry.ELEMENT); |
2855 librarySource, | |
2856 libraryEntry, | |
2857 DartEntry.ELEMENT); | |
2858 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); | 2731 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
2859 CompilationUnitElement definingUnit = | 2732 CompilationUnitElement definingUnit = |
2860 libraryElement.definingCompilationUnit; | 2733 libraryElement.definingCompilationUnit; |
2861 List<CompilationUnitElement> parts = libraryElement.parts; | 2734 List<CompilationUnitElement> parts = libraryElement.parts; |
2862 List<TimestampedData<CompilationUnit>> units = | 2735 List<TimestampedData<CompilationUnit>> units = |
2863 new List<TimestampedData>(parts.length + 1); | 2736 new List<TimestampedData>(parts.length + 1); |
2864 units[0] = _getResolvedUnit(definingUnit, librarySource); | 2737 units[0] = _getResolvedUnit(definingUnit, librarySource); |
2865 if (units[0] == null) { | 2738 if (units[0] == null) { |
2866 Source source = definingUnit.source; | 2739 Source source = definingUnit.source; |
2867 units[0] = new TimestampedData<CompilationUnit>( | 2740 units[0] = new TimestampedData<CompilationUnit>( |
2868 getModificationStamp(source), | 2741 getModificationStamp(source), |
2869 resolveCompilationUnit(source, libraryElement)); | 2742 resolveCompilationUnit(source, libraryElement)); |
2870 } | 2743 } |
2871 for (int i = 0; i < parts.length; i++) { | 2744 for (int i = 0; i < parts.length; i++) { |
2872 units[i + 1] = _getResolvedUnit(parts[i], librarySource); | 2745 units[i + 1] = _getResolvedUnit(parts[i], librarySource); |
2873 if (units[i + 1] == null) { | 2746 if (units[i + 1] == null) { |
2874 Source source = parts[i].source; | 2747 Source source = parts[i].source; |
2875 units[i + | 2748 units[i + 1] = new TimestampedData<CompilationUnit>( |
2876 1] = new TimestampedData<CompilationUnit>( | 2749 getModificationStamp(source), |
2877 getModificationStamp(source), | 2750 resolveCompilationUnit(source, libraryElement)); |
2878 resolveCompilationUnit(source, libraryElement)); | |
2879 } | 2751 } |
2880 } | 2752 } |
2881 //TODO(pquitslund): revisit if we need all units or whether one will do | 2753 //TODO(pquitslund): revisit if we need all units or whether one will do |
2882 dartEntry = new GenerateDartLintsTask( | 2754 dartEntry = new GenerateDartLintsTask( |
2883 this, | 2755 this, units, getLibraryElement(librarySource)) |
2884 units, | 2756 .perform(_resultRecorder) as DartEntry; |
2885 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr
y; | |
2886 state = dartEntry.getStateInLibrary(descriptor, librarySource); | 2757 state = dartEntry.getStateInLibrary(descriptor, librarySource); |
2887 } | 2758 } |
2888 return dartEntry; | 2759 return dartEntry; |
2889 } | 2760 } |
2890 | 2761 |
2891 /** | 2762 /** |
2892 * Given a source for a Dart file, return a cache entry in which the state of
the data represented | 2763 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
2893 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR].
This | 2764 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR].
This |
2894 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 2765 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
2895 * | 2766 * |
2896 * <b>Note:</b> This method cannot be used in an async environment. | 2767 * <b>Note:</b> This method cannot be used in an async environment. |
2897 * | 2768 * |
2898 * @param source the source representing the Dart file | 2769 * @param source the source representing the Dart file |
2899 * @param dartEntry the cache entry associated with the Dart file | 2770 * @param dartEntry the cache entry associated with the Dart file |
2900 * @param descriptor the descriptor representing the data to be returned | 2771 * @param descriptor the descriptor representing the data to be returned |
2901 * @return a cache entry containing the required data | 2772 * @return a cache entry containing the required data |
2902 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 2773 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
2903 */ | 2774 */ |
2904 DartEntry _cacheDartParseData(Source source, DartEntry dartEntry, | 2775 DartEntry _cacheDartParseData( |
2905 DataDescriptor descriptor) { | 2776 Source source, DartEntry dartEntry, DataDescriptor descriptor) { |
2906 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 2777 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
2907 if (dartEntry.hasResolvableCompilationUnit) { | 2778 if (dartEntry.hasResolvableCompilationUnit) { |
2908 return dartEntry; | 2779 return dartEntry; |
2909 } | 2780 } |
2910 } | 2781 } |
2911 // | 2782 // |
2912 // Check to see whether we already have the information being requested. | 2783 // Check to see whether we already have the information being requested. |
2913 // | 2784 // |
2914 CacheState state = dartEntry.getState(descriptor); | 2785 CacheState state = dartEntry.getState(descriptor); |
2915 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2786 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2916 // | 2787 // |
2917 // If not, compute the information. Unless the modification date of the | 2788 // If not, compute the information. Unless the modification date of the |
2918 // source continues to change, this loop will eventually terminate. | 2789 // source continues to change, this loop will eventually terminate. |
2919 // | 2790 // |
2920 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); | 2791 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); |
2921 dartEntry = new ParseDartTask( | 2792 dartEntry = new ParseDartTask(this, source, |
2922 this, | 2793 dartEntry.getValue(DartEntry.TOKEN_STREAM), |
2923 source, | 2794 dartEntry.getValue(SourceEntry.LINE_INFO)) |
2924 dartEntry.getValue(DartEntry.TOKEN_STREAM), | 2795 .perform(_resultRecorder) as DartEntry; |
2925 dartEntry.getValue( | |
2926 SourceEntry.LINE_INFO)).perform(_resultRecorder) as DartEntry; | |
2927 state = dartEntry.getState(descriptor); | 2796 state = dartEntry.getState(descriptor); |
2928 } | 2797 } |
2929 return dartEntry; | 2798 return dartEntry; |
2930 } | 2799 } |
2931 | 2800 |
2932 /** | 2801 /** |
2933 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 2802 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
2934 * the state of the data represented by the given descriptor is either [CacheS
tate.VALID] or | 2803 * the state of the data represented by the given descriptor is either [CacheS
tate.VALID] or |
2935 * [CacheState.ERROR]. This method assumes that the data can be produced by re
solving the | 2804 * [CacheState.ERROR]. This method assumes that the data can be produced by re
solving the |
2936 * source in the context of the library if it is not already cached. | 2805 * source in the context of the library if it is not already cached. |
2937 * | 2806 * |
2938 * <b>Note:</b> This method cannot be used in an async environment. | 2807 * <b>Note:</b> This method cannot be used in an async environment. |
2939 * | 2808 * |
2940 * @param unitSource the source representing the Dart file | 2809 * @param unitSource the source representing the Dart file |
2941 * @param librarySource the source representing the library containing the Dar
t file | 2810 * @param librarySource the source representing the library containing the Dar
t file |
2942 * @param dartEntry the cache entry associated with the Dart file | 2811 * @param dartEntry the cache entry associated with the Dart file |
2943 * @param descriptor the descriptor representing the data to be returned | 2812 * @param descriptor the descriptor representing the data to be returned |
2944 * @return a cache entry containing the required data | 2813 * @return a cache entry containing the required data |
2945 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 2814 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
2946 */ | 2815 */ |
2947 DartEntry _cacheDartResolutionData(Source unitSource, Source librarySource, | 2816 DartEntry _cacheDartResolutionData(Source unitSource, Source librarySource, |
2948 DartEntry dartEntry, DataDescriptor descriptor) { | 2817 DartEntry dartEntry, DataDescriptor descriptor) { |
2949 // | 2818 // |
2950 // Check to see whether we already have the information being requested. | 2819 // Check to see whether we already have the information being requested. |
2951 // | 2820 // |
2952 CacheState state = (identical(descriptor, DartEntry.ELEMENT)) ? | 2821 CacheState state = (identical(descriptor, DartEntry.ELEMENT)) |
2953 dartEntry.getState(descriptor) : | 2822 ? dartEntry.getState(descriptor) |
2954 dartEntry.getStateInLibrary(descriptor, librarySource); | 2823 : dartEntry.getStateInLibrary(descriptor, librarySource); |
2955 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2824 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2956 // | 2825 // |
2957 // If not, compute the information. Unless the modification date of the | 2826 // If not, compute the information. Unless the modification date of the |
2958 // source continues to change, this loop will eventually terminate. | 2827 // source continues to change, this loop will eventually terminate. |
2959 // | 2828 // |
2960 // TODO(brianwilkerson) As an optimization, if we already have the | 2829 // TODO(brianwilkerson) As an optimization, if we already have the |
2961 // element model for the library we can use ResolveDartUnitTask to produce | 2830 // element model for the library we can use ResolveDartUnitTask to produce |
2962 // the resolved AST structure much faster. | 2831 // the resolved AST structure much faster. |
2963 dartEntry = new ResolveDartLibraryTask( | 2832 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource) |
2964 this, | 2833 .perform(_resultRecorder) as DartEntry; |
2965 unitSource, | 2834 state = (identical(descriptor, DartEntry.ELEMENT)) |
2966 librarySource).perform(_resultRecorder) as DartEntry; | 2835 ? dartEntry.getState(descriptor) |
2967 state = (identical(descriptor, DartEntry.ELEMENT)) ? | 2836 : dartEntry.getStateInLibrary(descriptor, librarySource); |
2968 dartEntry.getState(descriptor) : | |
2969 dartEntry.getStateInLibrary(descriptor, librarySource); | |
2970 } | 2837 } |
2971 return dartEntry; | 2838 return dartEntry; |
2972 } | 2839 } |
2973 | 2840 |
2974 /** | 2841 /** |
2975 * Given a source for a Dart file, return a cache entry in which the state of
the data represented | 2842 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
2976 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR].
This | 2843 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR].
This |
2977 * method assumes that the data can be produced by scanning the source if it i
s not already | 2844 * method assumes that the data can be produced by scanning the source if it i
s not already |
2978 * cached. | 2845 * cached. |
2979 * | 2846 * |
2980 * <b>Note:</b> This method cannot be used in an async environment. | 2847 * <b>Note:</b> This method cannot be used in an async environment. |
2981 * | 2848 * |
2982 * @param source the source representing the Dart file | 2849 * @param source the source representing the Dart file |
2983 * @param dartEntry the cache entry associated with the Dart file | 2850 * @param dartEntry the cache entry associated with the Dart file |
2984 * @param descriptor the descriptor representing the data to be returned | 2851 * @param descriptor the descriptor representing the data to be returned |
2985 * @return a cache entry containing the required data | 2852 * @return a cache entry containing the required data |
2986 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 2853 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
2987 */ | 2854 */ |
2988 DartEntry _cacheDartScanData(Source source, DartEntry dartEntry, | 2855 DartEntry _cacheDartScanData( |
2989 DataDescriptor descriptor) { | 2856 Source source, DartEntry dartEntry, DataDescriptor descriptor) { |
2990 // | 2857 // |
2991 // Check to see whether we already have the information being requested. | 2858 // Check to see whether we already have the information being requested. |
2992 // | 2859 // |
2993 CacheState state = dartEntry.getState(descriptor); | 2860 CacheState state = dartEntry.getState(descriptor); |
2994 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2861 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2995 // | 2862 // |
2996 // If not, compute the information. Unless the modification date of the | 2863 // If not, compute the information. Unless the modification date of the |
2997 // source continues to change, this loop will eventually terminate. | 2864 // source continues to change, this loop will eventually terminate. |
2998 // | 2865 // |
2999 try { | 2866 try { |
3000 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 2867 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3001 dartEntry = | 2868 dartEntry = new GetContentTask(this, source) |
3002 new GetContentTask(this, source).perform(_resultRecorder) as DartE
ntry; | 2869 .perform(_resultRecorder) as DartEntry; |
3003 } | 2870 } |
3004 dartEntry = new ScanDartTask( | 2871 dartEntry = new ScanDartTask( |
3005 this, | 2872 this, source, dartEntry.getValue(SourceEntry.CONTENT)) |
3006 source, | 2873 .perform(_resultRecorder) as DartEntry; |
3007 dartEntry.getValue(SourceEntry.CONTENT)).perform(_resultRecorder) as
DartEntry; | |
3008 } on AnalysisException catch (exception) { | 2874 } on AnalysisException catch (exception) { |
3009 throw exception; | 2875 throw exception; |
3010 } catch (exception, stackTrace) { | 2876 } catch (exception, stackTrace) { |
3011 throw new AnalysisException( | 2877 throw new AnalysisException( |
3012 "Exception", | 2878 "Exception", new CaughtException(exception, stackTrace)); |
3013 new CaughtException(exception, stackTrace)); | |
3014 } | 2879 } |
3015 state = dartEntry.getState(descriptor); | 2880 state = dartEntry.getState(descriptor); |
3016 } | 2881 } |
3017 return dartEntry; | 2882 return dartEntry; |
3018 } | 2883 } |
3019 | 2884 |
3020 /** | 2885 /** |
3021 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 2886 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
3022 * the state of the data represented by the given descriptor is either [CacheS
tate.VALID] or | 2887 * the state of the data represented by the given descriptor is either [CacheS
tate.VALID] or |
3023 * [CacheState.ERROR]. This method assumes that the data can be produced by ve
rifying the | 2888 * [CacheState.ERROR]. This method assumes that the data can be produced by ve
rifying the |
(...skipping 18 matching lines...) Expand all Loading... |
3042 // | 2907 // |
3043 // If not, compute the information. Unless the modification date of the | 2908 // If not, compute the information. Unless the modification date of the |
3044 // source continues to change, this loop will eventually terminate. | 2909 // source continues to change, this loop will eventually terminate. |
3045 // | 2910 // |
3046 LibraryElement library = computeLibraryElement(librarySource); | 2911 LibraryElement library = computeLibraryElement(librarySource); |
3047 CompilationUnit unit = resolveCompilationUnit(unitSource, library); | 2912 CompilationUnit unit = resolveCompilationUnit(unitSource, library); |
3048 if (unit == null) { | 2913 if (unit == null) { |
3049 throw new AnalysisException( | 2914 throw new AnalysisException( |
3050 "Could not resolve compilation unit ${unitSource.fullName} in ${libr
arySource.fullName}"); | 2915 "Could not resolve compilation unit ${unitSource.fullName} in ${libr
arySource.fullName}"); |
3051 } | 2916 } |
3052 dartEntry = new GenerateDartErrorsTask( | 2917 dartEntry = new GenerateDartErrorsTask(this, unitSource, unit, library) |
3053 this, | 2918 .perform(_resultRecorder) as DartEntry; |
3054 unitSource, | |
3055 unit, | |
3056 library).perform(_resultRecorder) as DartEntry; | |
3057 state = dartEntry.getStateInLibrary(descriptor, librarySource); | 2919 state = dartEntry.getStateInLibrary(descriptor, librarySource); |
3058 } | 2920 } |
3059 return dartEntry; | 2921 return dartEntry; |
3060 } | 2922 } |
3061 | 2923 |
3062 /** | 2924 /** |
3063 * Given a source for an HTML file, return a cache entry in which all of the d
ata represented by | 2925 * Given a source for an HTML file, return a cache entry in which all of the d
ata represented by |
3064 * the state of the given descriptors is either [CacheState.VALID] or | 2926 * the state of the given descriptors is either [CacheState.VALID] or |
3065 * [CacheState.ERROR]. This method assumes that the data can be produced by pa
rsing the | 2927 * [CacheState.ERROR]. This method assumes that the data can be produced by pa
rsing the |
3066 * source if it is not already cached. | 2928 * source if it is not already cached. |
3067 * | 2929 * |
3068 * <b>Note:</b> This method cannot be used in an async environment. | 2930 * <b>Note:</b> This method cannot be used in an async environment. |
3069 * | 2931 * |
3070 * @param source the source representing the HTML file | 2932 * @param source the source representing the HTML file |
3071 * @param htmlEntry the cache entry associated with the HTML file | 2933 * @param htmlEntry the cache entry associated with the HTML file |
3072 * @param descriptor the descriptor representing the data to be returned | 2934 * @param descriptor the descriptor representing the data to be returned |
3073 * @return a cache entry containing the required data | 2935 * @return a cache entry containing the required data |
3074 * @throws AnalysisException if data could not be returned because the source
could not be | 2936 * @throws AnalysisException if data could not be returned because the source
could not be |
3075 * resolved | 2937 * resolved |
3076 */ | 2938 */ |
3077 HtmlEntry _cacheHtmlParseData(Source source, HtmlEntry htmlEntry, | 2939 HtmlEntry _cacheHtmlParseData( |
3078 DataDescriptor descriptor) { | 2940 Source source, HtmlEntry htmlEntry, DataDescriptor descriptor) { |
3079 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 2941 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
3080 ht.HtmlUnit unit = htmlEntry.anyParsedUnit; | 2942 ht.HtmlUnit unit = htmlEntry.anyParsedUnit; |
3081 if (unit != null) { | 2943 if (unit != null) { |
3082 return htmlEntry; | 2944 return htmlEntry; |
3083 } | 2945 } |
3084 } | 2946 } |
3085 // | 2947 // |
3086 // Check to see whether we already have the information being requested. | 2948 // Check to see whether we already have the information being requested. |
3087 // | 2949 // |
3088 CacheState state = htmlEntry.getState(descriptor); | 2950 CacheState state = htmlEntry.getState(descriptor); |
3089 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2951 while (state != CacheState.ERROR && state != CacheState.VALID) { |
3090 // | 2952 // |
3091 // If not, compute the information. Unless the modification date of the | 2953 // If not, compute the information. Unless the modification date of the |
3092 // source continues to change, this loop will eventually terminate. | 2954 // source continues to change, this loop will eventually terminate. |
3093 // | 2955 // |
3094 try { | 2956 try { |
3095 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 2957 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3096 htmlEntry = | 2958 htmlEntry = new GetContentTask(this, source) |
3097 new GetContentTask(this, source).perform(_resultRecorder) as HtmlE
ntry; | 2959 .perform(_resultRecorder) as HtmlEntry; |
3098 } | 2960 } |
3099 htmlEntry = new ParseHtmlTask( | 2961 htmlEntry = new ParseHtmlTask( |
3100 this, | 2962 this, source, htmlEntry.getValue(SourceEntry.CONTENT)) |
3101 source, | 2963 .perform(_resultRecorder) as HtmlEntry; |
3102 htmlEntry.getValue(SourceEntry.CONTENT)).perform(_resultRecorder) as
HtmlEntry; | |
3103 } on AnalysisException catch (exception) { | 2964 } on AnalysisException catch (exception) { |
3104 throw exception; | 2965 throw exception; |
3105 } catch (exception, stackTrace) { | 2966 } catch (exception, stackTrace) { |
3106 throw new AnalysisException( | 2967 throw new AnalysisException( |
3107 "Exception", | 2968 "Exception", new CaughtException(exception, stackTrace)); |
3108 new CaughtException(exception, stackTrace)); | |
3109 } | 2969 } |
3110 state = htmlEntry.getState(descriptor); | 2970 state = htmlEntry.getState(descriptor); |
3111 } | 2971 } |
3112 return htmlEntry; | 2972 return htmlEntry; |
3113 } | 2973 } |
3114 | 2974 |
3115 /** | 2975 /** |
3116 * Given a source for an HTML file, return a cache entry in which the state of
the data | 2976 * Given a source for an HTML file, return a cache entry in which the state of
the data |
3117 * represented by the given descriptor is either [CacheState.VALID] or | 2977 * represented by the given descriptor is either [CacheState.VALID] or |
3118 * [CacheState.ERROR]. This method assumes that the data can be produced by re
solving the | 2978 * [CacheState.ERROR]. This method assumes that the data can be produced by re
solving the |
3119 * source if it is not already cached. | 2979 * source if it is not already cached. |
3120 * | 2980 * |
3121 * <b>Note:</b> This method cannot be used in an async environment. | 2981 * <b>Note:</b> This method cannot be used in an async environment. |
3122 * | 2982 * |
3123 * @param source the source representing the HTML file | 2983 * @param source the source representing the HTML file |
3124 * @param dartEntry the cache entry associated with the HTML file | 2984 * @param dartEntry the cache entry associated with the HTML file |
3125 * @param descriptor the descriptor representing the data to be returned | 2985 * @param descriptor the descriptor representing the data to be returned |
3126 * @return a cache entry containing the required data | 2986 * @return a cache entry containing the required data |
3127 * @throws AnalysisException if data could not be returned because the source
could not be | 2987 * @throws AnalysisException if data could not be returned because the source
could not be |
3128 * resolved | 2988 * resolved |
3129 */ | 2989 */ |
3130 HtmlEntry _cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, | 2990 HtmlEntry _cacheHtmlResolutionData( |
3131 DataDescriptor descriptor) { | 2991 Source source, HtmlEntry htmlEntry, DataDescriptor descriptor) { |
3132 // | 2992 // |
3133 // Check to see whether we already have the information being requested. | 2993 // Check to see whether we already have the information being requested. |
3134 // | 2994 // |
3135 CacheState state = htmlEntry.getState(descriptor); | 2995 CacheState state = htmlEntry.getState(descriptor); |
3136 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2996 while (state != CacheState.ERROR && state != CacheState.VALID) { |
3137 // | 2997 // |
3138 // If not, compute the information. Unless the modification date of the | 2998 // If not, compute the information. Unless the modification date of the |
3139 // source continues to change, this loop will eventually terminate. | 2999 // source continues to change, this loop will eventually terminate. |
3140 // | 3000 // |
3141 htmlEntry = _cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); | 3001 htmlEntry = _cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); |
3142 htmlEntry = new ResolveHtmlTask( | 3002 htmlEntry = new ResolveHtmlTask(this, source, htmlEntry.modificationTime, |
3143 this, | 3003 htmlEntry.getValue(HtmlEntry.PARSED_UNIT)) |
3144 source, | 3004 .perform(_resultRecorder) as HtmlEntry; |
3145 htmlEntry.modificationTime, | |
3146 htmlEntry.getValue( | |
3147 HtmlEntry.PARSED_UNIT)).perform(_resultRecorder) as HtmlEntry; | |
3148 state = htmlEntry.getState(descriptor); | 3005 state = htmlEntry.getState(descriptor); |
3149 } | 3006 } |
3150 return htmlEntry; | 3007 return htmlEntry; |
3151 } | 3008 } |
3152 | 3009 |
3153 /** | 3010 /** |
3154 * Remove the given [pendingFuture] from [_pendingFutureSources], since the | 3011 * Remove the given [pendingFuture] from [_pendingFutureSources], since the |
3155 * client has indicated its computation is not needed anymore. | 3012 * client has indicated its computation is not needed anymore. |
3156 */ | 3013 */ |
3157 void _cancelFuture(PendingFuture pendingFuture) { | 3014 void _cancelFuture(PendingFuture pendingFuture) { |
3158 List<PendingFuture> pendingFutures = | 3015 List<PendingFuture> pendingFutures = |
3159 _pendingFutureSources[pendingFuture.source]; | 3016 _pendingFutureSources[pendingFuture.source]; |
3160 if (pendingFutures != null) { | 3017 if (pendingFutures != null) { |
3161 pendingFutures.remove(pendingFuture); | 3018 pendingFutures.remove(pendingFuture); |
3162 if (pendingFutures.isEmpty) { | 3019 if (pendingFutures.isEmpty) { |
3163 _pendingFutureSources.remove(pendingFuture.source); | 3020 _pendingFutureSources.remove(pendingFuture.source); |
3164 } | 3021 } |
3165 } | 3022 } |
3166 } | 3023 } |
3167 | 3024 |
3168 /** | 3025 /** |
3169 * Compute the transitive closure of all libraries that depend on the given li
brary by adding such | 3026 * Compute the transitive closure of all libraries that depend on the given li
brary by adding such |
3170 * libraries to the given collection. | 3027 * libraries to the given collection. |
3171 * | 3028 * |
3172 * @param library the library on which the other libraries depend | 3029 * @param library the library on which the other libraries depend |
3173 * @param librariesToInvalidate the libraries that depend on the given library | 3030 * @param librariesToInvalidate the libraries that depend on the given library |
3174 */ | 3031 */ |
3175 void _computeAllLibrariesDependingOn(Source library, | 3032 void _computeAllLibrariesDependingOn( |
3176 HashSet<Source> librariesToInvalidate) { | 3033 Source library, HashSet<Source> librariesToInvalidate) { |
3177 if (librariesToInvalidate.add(library)) { | 3034 if (librariesToInvalidate.add(library)) { |
3178 for (Source dependentLibrary in getLibrariesDependingOn(library)) { | 3035 for (Source dependentLibrary in getLibrariesDependingOn(library)) { |
3179 _computeAllLibrariesDependingOn( | 3036 _computeAllLibrariesDependingOn( |
3180 dependentLibrary, | 3037 dependentLibrary, librariesToInvalidate); |
3181 librariesToInvalidate); | |
3182 } | 3038 } |
3183 } | 3039 } |
3184 } | 3040 } |
3185 | 3041 |
3186 /** | 3042 /** |
3187 * Compute the priority that should be used when the source associated with th
e given entry is | 3043 * Compute the priority that should be used when the source associated with th
e given entry is |
3188 * added to the work manager. | 3044 * added to the work manager. |
3189 * | 3045 * |
3190 * @param dartEntry the entry associated with the source | 3046 * @param dartEntry the entry associated with the source |
3191 * @return the priority that was computed | 3047 * @return the priority that was computed |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3254 * @param newLength the number of characters in the replacement text | 3110 * @param newLength the number of characters in the replacement text |
3255 */ | 3111 */ |
3256 bool _contentRangeChanged(Source source, String contents, int offset, | 3112 bool _contentRangeChanged(Source source, String contents, int offset, |
3257 int oldLength, int newLength) { | 3113 int oldLength, int newLength) { |
3258 bool changed = false; | 3114 bool changed = false; |
3259 String originalContents = _contentCache.setContents(source, contents); | 3115 String originalContents = _contentCache.setContents(source, contents); |
3260 if (contents != null) { | 3116 if (contents != null) { |
3261 if (contents != originalContents) { | 3117 if (contents != originalContents) { |
3262 if (_options.incremental) { | 3118 if (_options.incremental) { |
3263 _incrementalAnalysisCache = IncrementalAnalysisCache.update( | 3119 _incrementalAnalysisCache = IncrementalAnalysisCache.update( |
3264 _incrementalAnalysisCache, | 3120 _incrementalAnalysisCache, source, originalContents, contents, |
3265 source, | 3121 offset, oldLength, newLength, _getReadableSourceEntry(source)); |
3266 originalContents, | |
3267 contents, | |
3268 offset, | |
3269 oldLength, | |
3270 newLength, | |
3271 _getReadableSourceEntry(source)); | |
3272 } | 3122 } |
3273 _sourceChanged(source); | 3123 _sourceChanged(source); |
3274 changed = true; | 3124 changed = true; |
3275 SourceEntry sourceEntry = _cache.get(source); | 3125 SourceEntry sourceEntry = _cache.get(source); |
3276 if (sourceEntry != null) { | 3126 if (sourceEntry != null) { |
3277 sourceEntry.modificationTime = | 3127 sourceEntry.modificationTime = |
3278 _contentCache.getModificationStamp(source); | 3128 _contentCache.getModificationStamp(source); |
3279 sourceEntry.setValue(SourceEntry.CONTENT, contents); | 3129 sourceEntry.setValue(SourceEntry.CONTENT, contents); |
3280 } | 3130 } |
3281 } | 3131 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3324 * | 3174 * |
3325 * @param unitSource the source for the compilation unit to be verified | 3175 * @param unitSource the source for the compilation unit to be verified |
3326 * @param unitEntry the entry for the compilation unit | 3176 * @param unitEntry the entry for the compilation unit |
3327 * @param librarySource the source for the library containing the compilation
unit | 3177 * @param librarySource the source for the library containing the compilation
unit |
3328 * @param libraryEntry the entry for the library | 3178 * @param libraryEntry the entry for the library |
3329 * @return task data representing the created task | 3179 * @return task data representing the created task |
3330 */ | 3180 */ |
3331 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, | 3181 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, |
3332 DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) { | 3182 DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) { |
3333 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != | 3183 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != |
3334 CacheState.VALID || | 3184 CacheState.VALID || |
3335 libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { | 3185 libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { |
3336 return _createResolveDartLibraryTask(librarySource, libraryEntry); | 3186 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
3337 } | 3187 } |
3338 CompilationUnit unit = | 3188 CompilationUnit unit = |
3339 unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource); | 3189 unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource); |
3340 if (unit == null) { | 3190 if (unit == null) { |
3341 CaughtException exception = new CaughtException( | 3191 CaughtException exception = new CaughtException(new AnalysisException( |
3342 new AnalysisException( | |
3343 "Entry has VALID state for RESOLVED_UNIT but null value for ${unit
Source.fullName} in ${librarySource.fullName}"), | 3192 "Entry has VALID state for RESOLVED_UNIT but null value for ${unit
Source.fullName} in ${librarySource.fullName}"), |
3344 null); | 3193 null); |
3345 AnalysisEngine.instance.logger.logInformation( | 3194 AnalysisEngine.instance.logger.logInformation( |
3346 exception.toString(), | 3195 exception.toString(), exception); |
3347 exception); | |
3348 unitEntry.recordResolutionError(exception); | 3196 unitEntry.recordResolutionError(exception); |
3349 return new AnalysisContextImpl_TaskData(null, false); | 3197 return new AnalysisContextImpl_TaskData(null, false); |
3350 } | 3198 } |
3351 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); | 3199 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
3352 return new AnalysisContextImpl_TaskData( | 3200 return new AnalysisContextImpl_TaskData( |
3353 new GenerateDartErrorsTask(this, unitSource, unit, libraryElement), | 3201 new GenerateDartErrorsTask(this, unitSource, unit, libraryElement), |
3354 false); | 3202 false); |
3355 } | 3203 } |
3356 | 3204 |
3357 /** | 3205 /** |
(...skipping 25 matching lines...) Expand all Loading... |
3383 } | 3231 } |
3384 for (int i = 0; i < parts.length; i++) { | 3232 for (int i = 0; i < parts.length; i++) { |
3385 units[i + 1] = _getResolvedUnit(parts[i], librarySource); | 3233 units[i + 1] = _getResolvedUnit(parts[i], librarySource); |
3386 if (units[i + 1] == null) { | 3234 if (units[i + 1] == null) { |
3387 // TODO(brianwilkerson) We should return a ResolveDartUnitTask | 3235 // TODO(brianwilkerson) We should return a ResolveDartUnitTask |
3388 // (unless there are multiple ASTs that need to be resolved). | 3236 // (unless there are multiple ASTs that need to be resolved). |
3389 return _createResolveDartLibraryTask(librarySource, libraryEntry); | 3237 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
3390 } | 3238 } |
3391 } | 3239 } |
3392 return new AnalysisContextImpl_TaskData( | 3240 return new AnalysisContextImpl_TaskData( |
3393 new GenerateDartHintsTask(this, units, libraryElement), | 3241 new GenerateDartHintsTask(this, units, libraryElement), false); |
3394 false); | |
3395 } | 3242 } |
3396 | 3243 |
3397 /** | 3244 /** |
3398 * Create a [GenerateDartLintsTask] for the given source, marking the lints as | 3245 * Create a [GenerateDartLintsTask] for the given source, marking the lints as |
3399 * being in-process. | 3246 * being in-process. |
3400 * | 3247 * |
3401 * @param source the source whose content is to be verified | 3248 * @param source the source whose content is to be verified |
3402 * @param dartEntry the entry for the source | 3249 * @param dartEntry the entry for the source |
3403 * @param librarySource the source for the library containing the source | 3250 * @param librarySource the source for the library containing the source |
3404 * @param libraryEntry the entry for the library | 3251 * @param libraryEntry the entry for the library |
(...skipping 19 matching lines...) Expand all Loading... |
3424 for (int i = 0; i < parts.length; i++) { | 3271 for (int i = 0; i < parts.length; i++) { |
3425 units[i + 1] = _getResolvedUnit(parts[i], librarySource); | 3272 units[i + 1] = _getResolvedUnit(parts[i], librarySource); |
3426 if (units[i + 1] == null) { | 3273 if (units[i + 1] == null) { |
3427 // TODO(brianwilkerson) We should return a ResolveDartUnitTask | 3274 // TODO(brianwilkerson) We should return a ResolveDartUnitTask |
3428 // (unless there are multiple ASTs that need to be resolved). | 3275 // (unless there are multiple ASTs that need to be resolved). |
3429 return _createResolveDartLibraryTask(librarySource, libraryEntry); | 3276 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
3430 } | 3277 } |
3431 } | 3278 } |
3432 //TODO(pquitslund): revisit if we need all units or whether one will do | 3279 //TODO(pquitslund): revisit if we need all units or whether one will do |
3433 return new AnalysisContextImpl_TaskData( | 3280 return new AnalysisContextImpl_TaskData( |
3434 new GenerateDartLintsTask(this, units, libraryElement), | 3281 new GenerateDartLintsTask(this, units, libraryElement), false); |
3435 false); | |
3436 } | 3282 } |
3437 | 3283 |
3438 /** | 3284 /** |
3439 * Create a [GetContentTask] for the given source, marking the content as bein
g in-process. | 3285 * Create a [GetContentTask] for the given source, marking the content as bein
g in-process. |
3440 * | 3286 * |
3441 * @param source the source whose content is to be accessed | 3287 * @param source the source whose content is to be accessed |
3442 * @param sourceEntry the entry for the source | 3288 * @param sourceEntry the entry for the source |
3443 * @return task data representing the created task | 3289 * @return task data representing the created task |
3444 */ | 3290 */ |
3445 AnalysisContextImpl_TaskData _createGetContentTask(Source source, | 3291 AnalysisContextImpl_TaskData _createGetContentTask( |
3446 SourceEntry sourceEntry) { | 3292 Source source, SourceEntry sourceEntry) { |
3447 return new AnalysisContextImpl_TaskData( | 3293 return new AnalysisContextImpl_TaskData( |
3448 new GetContentTask(this, source), | 3294 new GetContentTask(this, source), false); |
3449 false); | |
3450 } | 3295 } |
3451 | 3296 |
3452 /** | 3297 /** |
3453 * Create a [ParseDartTask] for the given [source]. | 3298 * Create a [ParseDartTask] for the given [source]. |
3454 */ | 3299 */ |
3455 AnalysisContextImpl_TaskData _createParseDartTask(Source source, | 3300 AnalysisContextImpl_TaskData _createParseDartTask( |
3456 DartEntry dartEntry) { | 3301 Source source, DartEntry dartEntry) { |
3457 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || | 3302 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || |
3458 dartEntry.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | 3303 dartEntry.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
3459 return _createScanDartTask(source, dartEntry); | 3304 return _createScanDartTask(source, dartEntry); |
3460 } | 3305 } |
3461 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); | 3306 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); |
3462 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); | 3307 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); |
3463 return new AnalysisContextImpl_TaskData( | 3308 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, |
3464 new ParseDartTask( | 3309 tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false); |
3465 this, | |
3466 source, | |
3467 tokenStream, | |
3468 dartEntry.getValue(SourceEntry.LINE_INFO)), | |
3469 false); | |
3470 } | 3310 } |
3471 | 3311 |
3472 /** | 3312 /** |
3473 * Create a [ParseHtmlTask] for the given [source]. | 3313 * Create a [ParseHtmlTask] for the given [source]. |
3474 */ | 3314 */ |
3475 AnalysisContextImpl_TaskData _createParseHtmlTask(Source source, | 3315 AnalysisContextImpl_TaskData _createParseHtmlTask( |
3476 HtmlEntry htmlEntry) { | 3316 Source source, HtmlEntry htmlEntry) { |
3477 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 3317 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3478 return _createGetContentTask(source, htmlEntry); | 3318 return _createGetContentTask(source, htmlEntry); |
3479 } | 3319 } |
3480 String content = htmlEntry.getValue(SourceEntry.CONTENT); | 3320 String content = htmlEntry.getValue(SourceEntry.CONTENT); |
3481 htmlEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 3321 htmlEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
3482 return new AnalysisContextImpl_TaskData( | 3322 return new AnalysisContextImpl_TaskData( |
3483 new ParseHtmlTask(this, source, content), | 3323 new ParseHtmlTask(this, source, content), false); |
3484 false); | |
3485 } | 3324 } |
3486 | 3325 |
3487 /** | 3326 /** |
3488 * Create a [ResolveDartLibraryTask] for the given source, marking ? as being
in-process. | 3327 * Create a [ResolveDartLibraryTask] for the given source, marking ? as being
in-process. |
3489 * | 3328 * |
3490 * @param source the source whose content is to be resolved | 3329 * @param source the source whose content is to be resolved |
3491 * @param dartEntry the entry for the source | 3330 * @param dartEntry the entry for the source |
3492 * @return task data representing the created task | 3331 * @return task data representing the created task |
3493 */ | 3332 */ |
3494 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, | 3333 AnalysisContextImpl_TaskData _createResolveDartLibraryTask( |
3495 DartEntry dartEntry) { | 3334 Source source, DartEntry dartEntry) { |
3496 try { | 3335 try { |
3497 AnalysisContextImpl_CycleBuilder builder = | 3336 AnalysisContextImpl_CycleBuilder builder = |
3498 new AnalysisContextImpl_CycleBuilder(this); | 3337 new AnalysisContextImpl_CycleBuilder(this); |
3499 PerformanceStatistics.cycles.makeCurrentWhile(() { | 3338 PerformanceStatistics.cycles.makeCurrentWhile(() { |
3500 builder.computeCycleContaining(source); | 3339 builder.computeCycleContaining(source); |
3501 }); | 3340 }); |
3502 AnalysisContextImpl_TaskData taskData = builder.taskData; | 3341 AnalysisContextImpl_TaskData taskData = builder.taskData; |
3503 if (taskData != null) { | 3342 if (taskData != null) { |
3504 return taskData; | 3343 return taskData; |
3505 } | 3344 } |
3506 return new AnalysisContextImpl_TaskData( | 3345 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask( |
3507 new ResolveDartLibraryCycleTask(this, source, source, builder.librarie
sInCycle), | 3346 this, source, source, builder.librariesInCycle), false); |
3508 false); | |
3509 } on AnalysisException catch (exception, stackTrace) { | 3347 } on AnalysisException catch (exception, stackTrace) { |
3510 dartEntry.recordResolutionError( | 3348 dartEntry |
3511 new CaughtException(exception, stackTrace)); | 3349 .recordResolutionError(new CaughtException(exception, stackTrace)); |
3512 AnalysisEngine.instance.logger.logError( | 3350 AnalysisEngine.instance.logger.logError( |
3513 "Internal error trying to create a ResolveDartLibraryTask", | 3351 "Internal error trying to create a ResolveDartLibraryTask", |
3514 new CaughtException(exception, stackTrace)); | 3352 new CaughtException(exception, stackTrace)); |
3515 } | 3353 } |
3516 return new AnalysisContextImpl_TaskData(null, false); | 3354 return new AnalysisContextImpl_TaskData(null, false); |
3517 } | 3355 } |
3518 | 3356 |
3519 /** | 3357 /** |
3520 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit
as being | 3358 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit
as being |
3521 * in-process. | 3359 * in-process. |
3522 * | 3360 * |
3523 * @param source the source whose content is to be resolved | 3361 * @param source the source whose content is to be resolved |
3524 * @param htmlEntry the entry for the source | 3362 * @param htmlEntry the entry for the source |
3525 * @return task data representing the created task | 3363 * @return task data representing the created task |
3526 */ | 3364 */ |
3527 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, | 3365 AnalysisContextImpl_TaskData _createResolveHtmlTask( |
3528 HtmlEntry htmlEntry) { | 3366 Source source, HtmlEntry htmlEntry) { |
3529 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { | 3367 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { |
3530 return _createParseHtmlTask(source, htmlEntry); | 3368 return _createParseHtmlTask(source, htmlEntry); |
3531 } | 3369 } |
3532 return new AnalysisContextImpl_TaskData( | 3370 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, |
3533 new ResolveHtmlTask( | 3371 htmlEntry.modificationTime, |
3534 this, | 3372 htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), false); |
3535 source, | |
3536 htmlEntry.modificationTime, | |
3537 htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), | |
3538 false); | |
3539 } | 3373 } |
3540 | 3374 |
3541 /** | 3375 /** |
3542 * Create a [ScanDartTask] for the given source, marking the scan errors as be
ing | 3376 * Create a [ScanDartTask] for the given source, marking the scan errors as be
ing |
3543 * in-process. | 3377 * in-process. |
3544 * | 3378 * |
3545 * @param source the source whose content is to be scanned | 3379 * @param source the source whose content is to be scanned |
3546 * @param dartEntry the entry for the source | 3380 * @param dartEntry the entry for the source |
3547 * @return task data representing the created task | 3381 * @return task data representing the created task |
3548 */ | 3382 */ |
3549 AnalysisContextImpl_TaskData _createScanDartTask(Source source, | 3383 AnalysisContextImpl_TaskData _createScanDartTask( |
3550 DartEntry dartEntry) { | 3384 Source source, DartEntry dartEntry) { |
3551 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 3385 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3552 return _createGetContentTask(source, dartEntry); | 3386 return _createGetContentTask(source, dartEntry); |
3553 } | 3387 } |
3554 String content = dartEntry.getValue(SourceEntry.CONTENT); | 3388 String content = dartEntry.getValue(SourceEntry.CONTENT); |
3555 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 3389 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
3556 return new AnalysisContextImpl_TaskData( | 3390 return new AnalysisContextImpl_TaskData( |
3557 new ScanDartTask(this, source, content), | 3391 new ScanDartTask(this, source, content), false); |
3558 false); | |
3559 } | 3392 } |
3560 | 3393 |
3561 /** | 3394 /** |
3562 * Create a source information object suitable for the given source. Return th
e source information | 3395 * Create a source information object suitable for the given source. Return th
e source information |
3563 * object that was created, or `null` if the source should not be tracked by t
his context. | 3396 * object that was created, or `null` if the source should not be tracked by t
his context. |
3564 * | 3397 * |
3565 * @param source the source for which an information object is being created | 3398 * @param source the source for which an information object is being created |
3566 * @param explicitlyAdded `true` if the source was explicitly added to the con
text | 3399 * @param explicitlyAdded `true` if the source was explicitly added to the con
text |
3567 * @return the source information object that was created | 3400 * @return the source information object that was created |
3568 */ | 3401 */ |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3659 * source if it is not already cached. | 3492 * source if it is not already cached. |
3660 * | 3493 * |
3661 * <b>Note:</b> This method cannot be used in an async environment. | 3494 * <b>Note:</b> This method cannot be used in an async environment. |
3662 * | 3495 * |
3663 * @param source the source representing the Dart file | 3496 * @param source the source representing the Dart file |
3664 * @param dartEntry the cache entry associated with the Dart file | 3497 * @param dartEntry the cache entry associated with the Dart file |
3665 * @param descriptor the descriptor representing the data to be returned | 3498 * @param descriptor the descriptor representing the data to be returned |
3666 * @return the requested data about the given source | 3499 * @return the requested data about the given source |
3667 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 3500 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
3668 */ | 3501 */ |
3669 Object _getDartParseData(Source source, DartEntry dartEntry, | 3502 Object _getDartParseData( |
3670 DataDescriptor descriptor) { | 3503 Source source, DartEntry dartEntry, DataDescriptor descriptor) { |
3671 dartEntry = _cacheDartParseData(source, dartEntry, descriptor); | 3504 dartEntry = _cacheDartParseData(source, dartEntry, descriptor); |
3672 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 3505 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
3673 _accessedAst(source); | 3506 _accessedAst(source); |
3674 return dartEntry.anyParsedCompilationUnit; | 3507 return dartEntry.anyParsedCompilationUnit; |
3675 } | 3508 } |
3676 return dartEntry.getValue(descriptor); | 3509 return dartEntry.getValue(descriptor); |
3677 } | 3510 } |
3678 | 3511 |
3679 /** | 3512 /** |
3680 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 3513 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
3681 * associated with that source, or the given default value if the source is no
t a Dart file. This | 3514 * associated with that source, or the given default value if the source is no
t a Dart file. This |
3682 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 3515 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
3683 * | 3516 * |
3684 * <b>Note:</b> This method cannot be used in an async environment. | 3517 * <b>Note:</b> This method cannot be used in an async environment. |
3685 * | 3518 * |
3686 * @param source the source representing the Dart file | 3519 * @param source the source representing the Dart file |
3687 * @param descriptor the descriptor representing the data to be returned | 3520 * @param descriptor the descriptor representing the data to be returned |
3688 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 3521 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
3689 * @return the requested data about the given source | 3522 * @return the requested data about the given source |
3690 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 3523 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
3691 */ | 3524 */ |
3692 Object _getDartParseData2(Source source, DataDescriptor descriptor, | 3525 Object _getDartParseData2( |
3693 Object defaultValue) { | 3526 Source source, DataDescriptor descriptor, Object defaultValue) { |
3694 DartEntry dartEntry = _getReadableDartEntry(source); | 3527 DartEntry dartEntry = _getReadableDartEntry(source); |
3695 if (dartEntry == null) { | 3528 if (dartEntry == null) { |
3696 return defaultValue; | 3529 return defaultValue; |
3697 } | 3530 } |
3698 try { | 3531 try { |
3699 return _getDartParseData(source, dartEntry, descriptor); | 3532 return _getDartParseData(source, dartEntry, descriptor); |
3700 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 3533 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
3701 AnalysisEngine.instance.logger.logInformation( | 3534 AnalysisEngine.instance.logger.logInformation( |
3702 "Could not compute $descriptor", | 3535 "Could not compute $descriptor", |
3703 new CaughtException(exception, stackTrace)); | 3536 new CaughtException(exception, stackTrace)); |
(...skipping 11 matching lines...) Expand all Loading... |
3715 * @param unitSource the source representing the Dart file | 3548 * @param unitSource the source representing the Dart file |
3716 * @param librarySource the source representing the library containing the Dar
t file | 3549 * @param librarySource the source representing the library containing the Dar
t file |
3717 * @param dartEntry the entry representing the Dart file | 3550 * @param dartEntry the entry representing the Dart file |
3718 * @param descriptor the descriptor representing the data to be returned | 3551 * @param descriptor the descriptor representing the data to be returned |
3719 * @return the requested data about the given source | 3552 * @return the requested data about the given source |
3720 * @throws AnalysisException if data could not be returned because the source
could not be | 3553 * @throws AnalysisException if data could not be returned because the source
could not be |
3721 * resolved | 3554 * resolved |
3722 */ | 3555 */ |
3723 Object _getDartResolutionData(Source unitSource, Source librarySource, | 3556 Object _getDartResolutionData(Source unitSource, Source librarySource, |
3724 DartEntry dartEntry, DataDescriptor descriptor) { | 3557 DartEntry dartEntry, DataDescriptor descriptor) { |
3725 dartEntry = | 3558 dartEntry = _cacheDartResolutionData( |
3726 _cacheDartResolutionData(unitSource, librarySource, dartEntry, descripto
r); | 3559 unitSource, librarySource, dartEntry, descriptor); |
3727 if (identical(descriptor, DartEntry.ELEMENT)) { | 3560 if (identical(descriptor, DartEntry.ELEMENT)) { |
3728 return dartEntry.getValue(descriptor); | 3561 return dartEntry.getValue(descriptor); |
3729 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 3562 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
3730 _accessedAst(unitSource); | 3563 _accessedAst(unitSource); |
3731 } | 3564 } |
3732 return dartEntry.getValueInLibrary(descriptor, librarySource); | 3565 return dartEntry.getValueInLibrary(descriptor, librarySource); |
3733 } | 3566 } |
3734 | 3567 |
3735 /** | 3568 /** |
3736 * Given a source for a Dart file and the library that contains it, return the
data represented by | 3569 * Given a source for a Dart file and the library that contains it, return the
data represented by |
(...skipping 12 matching lines...) Expand all Loading... |
3749 * resolved | 3582 * resolved |
3750 */ | 3583 */ |
3751 Object _getDartResolutionData2(Source unitSource, Source librarySource, | 3584 Object _getDartResolutionData2(Source unitSource, Source librarySource, |
3752 DataDescriptor descriptor, Object defaultValue) { | 3585 DataDescriptor descriptor, Object defaultValue) { |
3753 DartEntry dartEntry = _getReadableDartEntry(unitSource); | 3586 DartEntry dartEntry = _getReadableDartEntry(unitSource); |
3754 if (dartEntry == null) { | 3587 if (dartEntry == null) { |
3755 return defaultValue; | 3588 return defaultValue; |
3756 } | 3589 } |
3757 try { | 3590 try { |
3758 return _getDartResolutionData( | 3591 return _getDartResolutionData( |
3759 unitSource, | 3592 unitSource, librarySource, dartEntry, descriptor); |
3760 librarySource, | |
3761 dartEntry, | |
3762 descriptor); | |
3763 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 3593 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
3764 AnalysisEngine.instance.logger.logInformation( | 3594 AnalysisEngine.instance.logger.logInformation( |
3765 "Could not compute $descriptor", | 3595 "Could not compute $descriptor", |
3766 new CaughtException(exception, stackTrace)); | 3596 new CaughtException(exception, stackTrace)); |
3767 return defaultValue; | 3597 return defaultValue; |
3768 } | 3598 } |
3769 } | 3599 } |
3770 | 3600 |
3771 /** | 3601 /** |
3772 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 3602 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
3773 * associated with that source. This method assumes that the data can be produ
ced by scanning the | 3603 * associated with that source. This method assumes that the data can be produ
ced by scanning the |
3774 * source if it is not already cached. | 3604 * source if it is not already cached. |
3775 * | 3605 * |
3776 * <b>Note:</b> This method cannot be used in an async environment. | 3606 * <b>Note:</b> This method cannot be used in an async environment. |
3777 * | 3607 * |
3778 * @param source the source representing the Dart file | 3608 * @param source the source representing the Dart file |
3779 * @param dartEntry the cache entry associated with the Dart file | 3609 * @param dartEntry the cache entry associated with the Dart file |
3780 * @param descriptor the descriptor representing the data to be returned | 3610 * @param descriptor the descriptor representing the data to be returned |
3781 * @return the requested data about the given source | 3611 * @return the requested data about the given source |
3782 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 3612 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
3783 */ | 3613 */ |
3784 Object _getDartScanData(Source source, DartEntry dartEntry, | 3614 Object _getDartScanData( |
3785 DataDescriptor descriptor) { | 3615 Source source, DartEntry dartEntry, DataDescriptor descriptor) { |
3786 dartEntry = _cacheDartScanData(source, dartEntry, descriptor); | 3616 dartEntry = _cacheDartScanData(source, dartEntry, descriptor); |
3787 return dartEntry.getValue(descriptor); | 3617 return dartEntry.getValue(descriptor); |
3788 } | 3618 } |
3789 | 3619 |
3790 /** | 3620 /** |
3791 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 3621 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
3792 * associated with that source, or the given default value if the source is no
t a Dart file. This | 3622 * associated with that source, or the given default value if the source is no
t a Dart file. This |
3793 * method assumes that the data can be produced by scanning the source if it i
s not already | 3623 * method assumes that the data can be produced by scanning the source if it i
s not already |
3794 * cached. | 3624 * cached. |
3795 * | 3625 * |
3796 * <b>Note:</b> This method cannot be used in an async environment. | 3626 * <b>Note:</b> This method cannot be used in an async environment. |
3797 * | 3627 * |
3798 * @param source the source representing the Dart file | 3628 * @param source the source representing the Dart file |
3799 * @param descriptor the descriptor representing the data to be returned | 3629 * @param descriptor the descriptor representing the data to be returned |
3800 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 3630 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
3801 * @return the requested data about the given source | 3631 * @return the requested data about the given source |
3802 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 3632 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
3803 */ | 3633 */ |
3804 Object _getDartScanData2(Source source, DataDescriptor descriptor, | 3634 Object _getDartScanData2( |
3805 Object defaultValue) { | 3635 Source source, DataDescriptor descriptor, Object defaultValue) { |
3806 DartEntry dartEntry = _getReadableDartEntry(source); | 3636 DartEntry dartEntry = _getReadableDartEntry(source); |
3807 if (dartEntry == null) { | 3637 if (dartEntry == null) { |
3808 return defaultValue; | 3638 return defaultValue; |
3809 } | 3639 } |
3810 try { | 3640 try { |
3811 return _getDartScanData(source, dartEntry, descriptor); | 3641 return _getDartScanData(source, dartEntry, descriptor); |
3812 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 3642 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
3813 AnalysisEngine.instance.logger.logInformation( | 3643 AnalysisEngine.instance.logger.logInformation( |
3814 "Could not compute $descriptor", | 3644 "Could not compute $descriptor", |
3815 new CaughtException(exception, stackTrace)); | 3645 new CaughtException(exception, stackTrace)); |
(...skipping 11 matching lines...) Expand all Loading... |
3827 * @param unitSource the source representing the Dart file | 3657 * @param unitSource the source representing the Dart file |
3828 * @param librarySource the source representing the library containing the Dar
t file | 3658 * @param librarySource the source representing the library containing the Dar
t file |
3829 * @param dartEntry the entry representing the Dart file | 3659 * @param dartEntry the entry representing the Dart file |
3830 * @param descriptor the descriptor representing the data to be returned | 3660 * @param descriptor the descriptor representing the data to be returned |
3831 * @return the requested data about the given source | 3661 * @return the requested data about the given source |
3832 * @throws AnalysisException if data could not be returned because the source
could not be | 3662 * @throws AnalysisException if data could not be returned because the source
could not be |
3833 * resolved | 3663 * resolved |
3834 */ | 3664 */ |
3835 Object _getDartVerificationData(Source unitSource, Source librarySource, | 3665 Object _getDartVerificationData(Source unitSource, Source librarySource, |
3836 DartEntry dartEntry, DataDescriptor descriptor) { | 3666 DartEntry dartEntry, DataDescriptor descriptor) { |
3837 dartEntry = | 3667 dartEntry = _cacheDartVerificationData( |
3838 _cacheDartVerificationData(unitSource, librarySource, dartEntry, descrip
tor); | 3668 unitSource, librarySource, dartEntry, descriptor); |
3839 return dartEntry.getValueInLibrary(descriptor, librarySource); | 3669 return dartEntry.getValueInLibrary(descriptor, librarySource); |
3840 } | 3670 } |
3841 | 3671 |
3842 /** | 3672 /** |
3843 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 3673 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
3844 * associated with that source, or the given default value if the source is no
t an HTML file. This | 3674 * associated with that source, or the given default value if the source is no
t an HTML file. This |
3845 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 3675 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
3846 * | 3676 * |
3847 * <b>Note:</b> This method cannot be used in an async environment. | 3677 * <b>Note:</b> This method cannot be used in an async environment. |
3848 * | 3678 * |
3849 * @param source the source representing the Dart file | 3679 * @param source the source representing the Dart file |
3850 * @param descriptor the descriptor representing the data to be returned | 3680 * @param descriptor the descriptor representing the data to be returned |
3851 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 3681 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
3852 * @return the requested data about the given source | 3682 * @return the requested data about the given source |
3853 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 3683 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
3854 */ | 3684 */ |
3855 Object _getHtmlParseData(Source source, DataDescriptor descriptor, | 3685 Object _getHtmlParseData( |
3856 Object defaultValue) { | 3686 Source source, DataDescriptor descriptor, Object defaultValue) { |
3857 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); | 3687 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); |
3858 if (htmlEntry == null) { | 3688 if (htmlEntry == null) { |
3859 return defaultValue; | 3689 return defaultValue; |
3860 } | 3690 } |
3861 htmlEntry = _cacheHtmlParseData(source, htmlEntry, descriptor); | 3691 htmlEntry = _cacheHtmlParseData(source, htmlEntry, descriptor); |
3862 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 3692 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
3863 _accessedAst(source); | 3693 _accessedAst(source); |
3864 return htmlEntry.anyParsedUnit; | 3694 return htmlEntry.anyParsedUnit; |
3865 } | 3695 } |
3866 return htmlEntry.getValue(descriptor); | 3696 return htmlEntry.getValue(descriptor); |
3867 } | 3697 } |
3868 | 3698 |
3869 /** | 3699 /** |
3870 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 3700 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
3871 * associated with that source, or the given default value if the source is no
t an HTML file. This | 3701 * associated with that source, or the given default value if the source is no
t an HTML file. This |
3872 * method assumes that the data can be produced by resolving the source if it
is not already | 3702 * method assumes that the data can be produced by resolving the source if it
is not already |
3873 * cached. | 3703 * cached. |
3874 * | 3704 * |
3875 * <b>Note:</b> This method cannot be used in an async environment. | 3705 * <b>Note:</b> This method cannot be used in an async environment. |
3876 * | 3706 * |
3877 * @param source the source representing the HTML file | 3707 * @param source the source representing the HTML file |
3878 * @param descriptor the descriptor representing the data to be returned | 3708 * @param descriptor the descriptor representing the data to be returned |
3879 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 3709 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
3880 * @return the requested data about the given source | 3710 * @return the requested data about the given source |
3881 * @throws AnalysisException if data could not be returned because the source
could not be | 3711 * @throws AnalysisException if data could not be returned because the source
could not be |
3882 * resolved | 3712 * resolved |
3883 */ | 3713 */ |
3884 Object _getHtmlResolutionData(Source source, DataDescriptor descriptor, | 3714 Object _getHtmlResolutionData( |
3885 Object defaultValue) { | 3715 Source source, DataDescriptor descriptor, Object defaultValue) { |
3886 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); | 3716 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); |
3887 if (htmlEntry == null) { | 3717 if (htmlEntry == null) { |
3888 return defaultValue; | 3718 return defaultValue; |
3889 } | 3719 } |
3890 try { | 3720 try { |
3891 return _getHtmlResolutionData2(source, htmlEntry, descriptor); | 3721 return _getHtmlResolutionData2(source, htmlEntry, descriptor); |
3892 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 3722 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
3893 AnalysisEngine.instance.logger.logInformation( | 3723 AnalysisEngine.instance.logger.logInformation( |
3894 "Could not compute $descriptor", | 3724 "Could not compute $descriptor", |
3895 new CaughtException(exception, stackTrace)); | 3725 new CaughtException(exception, stackTrace)); |
3896 return defaultValue; | 3726 return defaultValue; |
3897 } | 3727 } |
3898 } | 3728 } |
3899 | 3729 |
3900 /** | 3730 /** |
3901 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 3731 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
3902 * associated with that source. This method assumes that the data can be produ
ced by resolving the | 3732 * associated with that source. This method assumes that the data can be produ
ced by resolving the |
3903 * source if it is not already cached. | 3733 * source if it is not already cached. |
3904 * | 3734 * |
3905 * <b>Note:</b> This method cannot be used in an async environment. | 3735 * <b>Note:</b> This method cannot be used in an async environment. |
3906 * | 3736 * |
3907 * @param source the source representing the HTML file | 3737 * @param source the source representing the HTML file |
3908 * @param htmlEntry the entry representing the HTML file | 3738 * @param htmlEntry the entry representing the HTML file |
3909 * @param descriptor the descriptor representing the data to be returned | 3739 * @param descriptor the descriptor representing the data to be returned |
3910 * @return the requested data about the given source | 3740 * @return the requested data about the given source |
3911 * @throws AnalysisException if data could not be returned because the source
could not be | 3741 * @throws AnalysisException if data could not be returned because the source
could not be |
3912 * resolved | 3742 * resolved |
3913 */ | 3743 */ |
3914 Object _getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, | 3744 Object _getHtmlResolutionData2( |
3915 DataDescriptor descriptor) { | 3745 Source source, HtmlEntry htmlEntry, DataDescriptor descriptor) { |
3916 htmlEntry = _cacheHtmlResolutionData(source, htmlEntry, descriptor); | 3746 htmlEntry = _cacheHtmlResolutionData(source, htmlEntry, descriptor); |
3917 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | 3747 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
3918 _accessedAst(source); | 3748 _accessedAst(source); |
3919 } | 3749 } |
3920 return htmlEntry.getValue(descriptor); | 3750 return htmlEntry.getValue(descriptor); |
3921 } | 3751 } |
3922 | 3752 |
3923 /** | 3753 /** |
3924 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the | 3754 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the |
3925 * task that should be performed, or `null` if there is no more work to be don
e for the | 3755 * task that should be performed, or `null` if there is no more work to be don
e for the |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3987 List<Source> librariesContaining = dartEntry.containingLibraries; | 3817 List<Source> librariesContaining = dartEntry.containingLibraries; |
3988 for (Source librarySource in librariesContaining) { | 3818 for (Source librarySource in librariesContaining) { |
3989 SourceEntry librarySourceEntry = _cache.get(librarySource); | 3819 SourceEntry librarySourceEntry = _cache.get(librarySource); |
3990 if (librarySourceEntry is DartEntry) { | 3820 if (librarySourceEntry is DartEntry) { |
3991 DartEntry libraryEntry = librarySourceEntry; | 3821 DartEntry libraryEntry = librarySourceEntry; |
3992 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 3822 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
3993 if (elementState == CacheState.INVALID || | 3823 if (elementState == CacheState.INVALID || |
3994 (isPriority && elementState == CacheState.FLUSHED)) { | 3824 (isPriority && elementState == CacheState.FLUSHED)) { |
3995 // return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); | 3825 // return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); |
3996 return new AnalysisContextImpl_TaskData( | 3826 return new AnalysisContextImpl_TaskData( |
3997 new ResolveDartLibraryTask(this, source, librarySource), | 3827 new ResolveDartLibraryTask(this, source, librarySource), false); |
3998 false); | |
3999 } | 3828 } |
4000 CacheState resolvedUnitState = | 3829 CacheState resolvedUnitState = dartEntry.getStateInLibrary( |
4001 dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource
); | 3830 DartEntry.RESOLVED_UNIT, librarySource); |
4002 if (resolvedUnitState == CacheState.INVALID || | 3831 if (resolvedUnitState == CacheState.INVALID || |
4003 (isPriority && resolvedUnitState == CacheState.FLUSHED)) { | 3832 (isPriority && resolvedUnitState == CacheState.FLUSHED)) { |
4004 // | 3833 // |
4005 // The commented out lines below are an optimization that doesn't | 3834 // The commented out lines below are an optimization that doesn't |
4006 // quite work yet. The problem is that if the source was not | 3835 // quite work yet. The problem is that if the source was not |
4007 // resolved because it wasn't part of any library, then there won't | 3836 // resolved because it wasn't part of any library, then there won't |
4008 // be any elements in the element model that we can use to resolve | 3837 // be any elements in the element model that we can use to resolve |
4009 // it. | 3838 // it. |
4010 // | 3839 // |
4011 // LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); | 3840 // LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); |
4012 // if (libraryElement != null) { | 3841 // if (libraryElement != null) { |
4013 // return new ResolveDartUnitTask(this, source, libraryElement); | 3842 // return new ResolveDartUnitTask(this, source, libraryElement); |
4014 // } | 3843 // } |
4015 // Possibly replace with: | 3844 // Possibly replace with: |
4016 // return createResolveDartLibraryTask(librarySource, (DartEntry) li
braryEntry); | 3845 // return createResolveDartLibraryTask(librarySource, (DartEntry) li
braryEntry); |
4017 return new AnalysisContextImpl_TaskData( | 3846 return new AnalysisContextImpl_TaskData( |
4018 new ResolveDartLibraryTask(this, source, librarySource), | 3847 new ResolveDartLibraryTask(this, source, librarySource), false); |
4019 false); | |
4020 } | 3848 } |
4021 if (_generateSdkErrors || !source.isInSystemLibrary) { | 3849 if (_generateSdkErrors || !source.isInSystemLibrary) { |
4022 CacheState verificationErrorsState = | 3850 CacheState verificationErrorsState = dartEntry.getStateInLibrary( |
4023 dartEntry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, libra
rySource); | 3851 DartEntry.VERIFICATION_ERRORS, librarySource); |
4024 if (verificationErrorsState == CacheState.INVALID || | 3852 if (verificationErrorsState == CacheState.INVALID || |
4025 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { | 3853 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { |
4026 return _createGenerateDartErrorsTask( | 3854 return _createGenerateDartErrorsTask( |
4027 source, | 3855 source, dartEntry, librarySource, libraryEntry); |
4028 dartEntry, | |
4029 librarySource, | |
4030 libraryEntry); | |
4031 } | 3856 } |
4032 if (hintsEnabled) { | 3857 if (hintsEnabled) { |
4033 CacheState hintsState = | 3858 CacheState hintsState = |
4034 dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource); | 3859 dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource); |
4035 if (hintsState == CacheState.INVALID || | 3860 if (hintsState == CacheState.INVALID || |
4036 (isPriority && hintsState == CacheState.FLUSHED)) { | 3861 (isPriority && hintsState == CacheState.FLUSHED)) { |
4037 return _createGenerateDartHintsTask( | 3862 return _createGenerateDartHintsTask( |
4038 source, | 3863 source, dartEntry, librarySource, libraryEntry); |
4039 dartEntry, | |
4040 librarySource, | |
4041 libraryEntry); | |
4042 } | 3864 } |
4043 } | 3865 } |
4044 if (lintsEnabled) { | 3866 if (lintsEnabled) { |
4045 CacheState lintsState = | 3867 CacheState lintsState = |
4046 dartEntry.getStateInLibrary(DartEntry.LINTS, librarySource); | 3868 dartEntry.getStateInLibrary(DartEntry.LINTS, librarySource); |
4047 if (lintsState == CacheState.INVALID || | 3869 if (lintsState == CacheState.INVALID || |
4048 (isPriority && lintsState == CacheState.FLUSHED)) { | 3870 (isPriority && lintsState == CacheState.FLUSHED)) { |
4049 return _createGenerateDartLintsTask( | 3871 return _createGenerateDartLintsTask( |
4050 source, | 3872 source, dartEntry, librarySource, libraryEntry); |
4051 dartEntry, | |
4052 librarySource, | |
4053 libraryEntry); | |
4054 } | 3873 } |
4055 } | 3874 } |
4056 } | 3875 } |
4057 } | 3876 } |
4058 } | 3877 } |
4059 } else if (sourceEntry is HtmlEntry) { | 3878 } else if (sourceEntry is HtmlEntry) { |
4060 HtmlEntry htmlEntry = sourceEntry; | 3879 HtmlEntry htmlEntry = sourceEntry; |
4061 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); | 3880 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); |
4062 if (parseErrorsState == CacheState.INVALID || | 3881 if (parseErrorsState == CacheState.INVALID || |
4063 (isPriority && parseErrorsState == CacheState.FLUSHED)) { | 3882 (isPriority && parseErrorsState == CacheState.FLUSHED)) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 } | 3964 } |
4146 | 3965 |
4147 /** | 3966 /** |
4148 * Return a resolved compilation unit corresponding to the given element in th
e given library, or | 3967 * Return a resolved compilation unit corresponding to the given element in th
e given library, or |
4149 * `null` if the information is not cached. | 3968 * `null` if the information is not cached. |
4150 * | 3969 * |
4151 * @param element the element representing the compilation unit | 3970 * @param element the element representing the compilation unit |
4152 * @param librarySource the source representing the library containing the uni
t | 3971 * @param librarySource the source representing the library containing the uni
t |
4153 * @return the specified resolved compilation unit | 3972 * @return the specified resolved compilation unit |
4154 */ | 3973 */ |
4155 TimestampedData<CompilationUnit> | 3974 TimestampedData<CompilationUnit> _getResolvedUnit( |
4156 _getResolvedUnit(CompilationUnitElement element, Source librarySource) { | 3975 CompilationUnitElement element, Source librarySource) { |
4157 SourceEntry sourceEntry = _cache.get(element.source); | 3976 SourceEntry sourceEntry = _cache.get(element.source); |
4158 if (sourceEntry is DartEntry) { | 3977 if (sourceEntry is DartEntry) { |
4159 DartEntry dartEntry = sourceEntry; | 3978 DartEntry dartEntry = sourceEntry; |
4160 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) == | 3979 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) == |
4161 CacheState.VALID) { | 3980 CacheState.VALID) { |
4162 return new TimestampedData<CompilationUnit>( | 3981 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, |
4163 dartEntry.modificationTime, | 3982 dartEntry.getValueInLibrary( |
4164 dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource))
; | 3983 DartEntry.RESOLVED_UNIT, librarySource)); |
4165 } | 3984 } |
4166 } | 3985 } |
4167 return null; | 3986 return null; |
4168 } | 3987 } |
4169 | 3988 |
4170 /** | 3989 /** |
4171 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 3990 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
4172 * | 3991 * |
4173 * @param kind the kind of sources to be returned | 3992 * @param kind the kind of sources to be returned |
4174 * @return all of the sources known to this context that have the given kind | 3993 * @return all of the sources known to this context that have the given kind |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4225 } | 4044 } |
4226 for (Source librarySource in getLibrariesContaining(source)) { | 4045 for (Source librarySource in getLibrariesContaining(source)) { |
4227 SourceEntry libraryEntry = _cache.get(librarySource); | 4046 SourceEntry libraryEntry = _cache.get(librarySource); |
4228 if (libraryEntry is DartEntry) { | 4047 if (libraryEntry is DartEntry) { |
4229 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 4048 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
4230 if (elementState == CacheState.INVALID || | 4049 if (elementState == CacheState.INVALID || |
4231 (isPriority && elementState == CacheState.FLUSHED)) { | 4050 (isPriority && elementState == CacheState.FLUSHED)) { |
4232 sources.add(source); | 4051 sources.add(source); |
4233 return; | 4052 return; |
4234 } | 4053 } |
4235 CacheState resolvedUnitState = | 4054 CacheState resolvedUnitState = dartEntry.getStateInLibrary( |
4236 dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource
); | 4055 DartEntry.RESOLVED_UNIT, librarySource); |
4237 if (resolvedUnitState == CacheState.INVALID || | 4056 if (resolvedUnitState == CacheState.INVALID || |
4238 (isPriority && resolvedUnitState == CacheState.FLUSHED)) { | 4057 (isPriority && resolvedUnitState == CacheState.FLUSHED)) { |
4239 LibraryElement libraryElement = | 4058 LibraryElement libraryElement = |
4240 libraryEntry.getValue(DartEntry.ELEMENT); | 4059 libraryEntry.getValue(DartEntry.ELEMENT); |
4241 if (libraryElement != null) { | 4060 if (libraryElement != null) { |
4242 sources.add(source); | 4061 sources.add(source); |
4243 return; | 4062 return; |
4244 } | 4063 } |
4245 } | 4064 } |
4246 if (_generateSdkErrors || !source.isInSystemLibrary) { | 4065 if (_generateSdkErrors || !source.isInSystemLibrary) { |
4247 CacheState verificationErrorsState = | 4066 CacheState verificationErrorsState = dartEntry.getStateInLibrary( |
4248 dartEntry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, libra
rySource); | 4067 DartEntry.VERIFICATION_ERRORS, librarySource); |
4249 if (verificationErrorsState == CacheState.INVALID || | 4068 if (verificationErrorsState == CacheState.INVALID || |
4250 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { | 4069 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { |
4251 LibraryElement libraryElement = | 4070 LibraryElement libraryElement = |
4252 libraryEntry.getValue(DartEntry.ELEMENT); | 4071 libraryEntry.getValue(DartEntry.ELEMENT); |
4253 if (libraryElement != null) { | 4072 if (libraryElement != null) { |
4254 sources.add(source); | 4073 sources.add(source); |
4255 return; | 4074 return; |
4256 } | 4075 } |
4257 } | 4076 } |
4258 if (hintsEnabled) { | 4077 if (hintsEnabled) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4419 } | 4238 } |
4420 | 4239 |
4421 /** | 4240 /** |
4422 * Notify all of the analysis listeners that the errors associated with the gi
ven source has been | 4241 * Notify all of the analysis listeners that the errors associated with the gi
ven source has been |
4423 * updated to the given errors. | 4242 * updated to the given errors. |
4424 * | 4243 * |
4425 * @param source the source containing the errors that were computed | 4244 * @param source the source containing the errors that were computed |
4426 * @param errors the errors that were computed | 4245 * @param errors the errors that were computed |
4427 * @param lineInfo the line information associated with the source | 4246 * @param lineInfo the line information associated with the source |
4428 */ | 4247 */ |
4429 void _notifyErrors(Source source, List<AnalysisError> errors, | 4248 void _notifyErrors( |
4430 LineInfo lineInfo) { | 4249 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
4431 int count = _listeners.length; | 4250 int count = _listeners.length; |
4432 for (int i = 0; i < count; i++) { | 4251 for (int i = 0; i < count; i++) { |
4433 _listeners[i].computedErrors(this, source, errors, lineInfo); | 4252 _listeners[i].computedErrors(this, source, errors, lineInfo); |
4434 } | 4253 } |
4435 } | 4254 } |
4436 | 4255 |
4437 /** | 4256 /** |
4438 * Given that the given [source] (with the corresponding [sourceEntry]) has | 4257 * Given that the given [source] (with the corresponding [sourceEntry]) has |
4439 * been invalidated, invalidate all of the libraries that depend on it. | 4258 * been invalidated, invalidate all of the libraries that depend on it. |
4440 */ | 4259 */ |
4441 void _propagateInvalidation(Source source, SourceEntry sourceEntry) { | 4260 void _propagateInvalidation(Source source, SourceEntry sourceEntry) { |
4442 if (sourceEntry is HtmlEntry) { | 4261 if (sourceEntry is HtmlEntry) { |
4443 HtmlEntry htmlEntry = sourceEntry; | 4262 HtmlEntry htmlEntry = sourceEntry; |
4444 htmlEntry.modificationTime = getModificationStamp(source); | 4263 htmlEntry.modificationTime = getModificationStamp(source); |
4445 htmlEntry.invalidateAllInformation(); | 4264 htmlEntry.invalidateAllInformation(); |
4446 _cache.removedAst(source); | 4265 _cache.removedAst(source); |
4447 _workManager.add(source, SourcePriority.HTML); | 4266 _workManager.add(source, SourcePriority.HTML); |
4448 } else if (sourceEntry is DartEntry) { | 4267 } else if (sourceEntry is DartEntry) { |
4449 List<Source> containingLibraries = getLibrariesContaining(source); | 4268 List<Source> containingLibraries = getLibrariesContaining(source); |
4450 List<Source> dependentLibraries = getLibrariesDependingOn(source); | 4269 List<Source> dependentLibraries = getLibrariesDependingOn(source); |
4451 HashSet<Source> librariesToInvalidate = new HashSet<Source>(); | 4270 HashSet<Source> librariesToInvalidate = new HashSet<Source>(); |
4452 for (Source containingLibrary in containingLibraries) { | 4271 for (Source containingLibrary in containingLibraries) { |
4453 _computeAllLibrariesDependingOn( | 4272 _computeAllLibrariesDependingOn( |
4454 containingLibrary, | 4273 containingLibrary, librariesToInvalidate); |
4455 librariesToInvalidate); | |
4456 } | 4274 } |
4457 for (Source dependentLibrary in dependentLibraries) { | 4275 for (Source dependentLibrary in dependentLibraries) { |
4458 _computeAllLibrariesDependingOn( | 4276 _computeAllLibrariesDependingOn( |
4459 dependentLibrary, | 4277 dependentLibrary, librariesToInvalidate); |
4460 librariesToInvalidate); | |
4461 } | 4278 } |
4462 for (Source library in librariesToInvalidate) { | 4279 for (Source library in librariesToInvalidate) { |
4463 _invalidateLibraryResolution(library); | 4280 _invalidateLibraryResolution(library); |
4464 } | 4281 } |
4465 DartEntry dartEntry = _cache.get(source); | 4282 DartEntry dartEntry = _cache.get(source); |
4466 _removeFromParts(source, dartEntry); | 4283 _removeFromParts(source, dartEntry); |
4467 dartEntry.modificationTime = getModificationStamp(source); | 4284 dartEntry.modificationTime = getModificationStamp(source); |
4468 dartEntry.invalidateAllInformation(); | 4285 dartEntry.invalidateAllInformation(); |
4469 _cache.removedAst(source); | 4286 _cache.removedAst(source); |
4470 _workManager.add(source, SourcePriority.UNKNOWN); | 4287 _workManager.add(source, SourcePriority.UNKNOWN); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4563 Source source = task.source; | 4380 Source source = task.source; |
4564 Source library = task.library; | 4381 Source library = task.library; |
4565 DartEntry dartEntry = _cache.get(source); | 4382 DartEntry dartEntry = _cache.get(source); |
4566 CaughtException thrownException = task.exception; | 4383 CaughtException thrownException = task.exception; |
4567 if (thrownException != null) { | 4384 if (thrownException != null) { |
4568 dartEntry.recordBuildElementErrorInLibrary(library, thrownException); | 4385 dartEntry.recordBuildElementErrorInLibrary(library, thrownException); |
4569 throw new AnalysisException('<rethrow>', thrownException); | 4386 throw new AnalysisException('<rethrow>', thrownException); |
4570 } | 4387 } |
4571 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit); | 4388 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit); |
4572 dartEntry.setValueInLibrary( | 4389 dartEntry.setValueInLibrary( |
4573 DartEntry.BUILT_ELEMENT, | 4390 DartEntry.BUILT_ELEMENT, library, task.unitElement); |
4574 library, | |
4575 task.unitElement); | |
4576 ChangeNoticeImpl notice = _getNotice(source); | 4391 ChangeNoticeImpl notice = _getNotice(source); |
4577 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO); | 4392 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO); |
4578 notice.setErrors(dartEntry.allErrors, lineInfo); | 4393 notice.setErrors(dartEntry.allErrors, lineInfo); |
4579 return dartEntry; | 4394 return dartEntry; |
4580 } | 4395 } |
4581 | 4396 |
4582 /** | 4397 /** |
4583 * Given a cache entry and a library element, record the library element and o
ther information | 4398 * Given a cache entry and a library element, record the library element and o
ther information |
4584 * gleaned from the element in the cache entry. | 4399 * gleaned from the element in the cache entry. |
4585 * | 4400 * |
4586 * @param dartCopy the cache entry in which data is to be recorded | 4401 * @param dartCopy the cache entry in which data is to be recorded |
4587 * @param library the library element used to record information | 4402 * @param library the library element used to record information |
4588 * @param librarySource the source for the library used to record information | 4403 * @param librarySource the source for the library used to record information |
4589 * @param htmlSource the source for the HTML library | 4404 * @param htmlSource the source for the HTML library |
4590 */ | 4405 */ |
4591 void _recordElementData(DartEntry dartEntry, LibraryElement library, | 4406 void _recordElementData(DartEntry dartEntry, LibraryElement library, |
4592 Source librarySource, Source htmlSource) { | 4407 Source librarySource, Source htmlSource) { |
4593 dartEntry.setValue(DartEntry.ELEMENT, library); | 4408 dartEntry.setValue(DartEntry.ELEMENT, library); |
4594 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); | 4409 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); |
4595 dartEntry.setValue( | 4410 dartEntry.setValue(DartEntry.IS_CLIENT, |
4596 DartEntry.IS_CLIENT, | |
4597 _isClient(library, htmlSource, new HashSet<LibraryElement>())); | 4411 _isClient(library, htmlSource, new HashSet<LibraryElement>())); |
4598 } | 4412 } |
4599 | 4413 |
4600 /** | 4414 /** |
4601 * Record the results produced by performing a [task] and return the cache | 4415 * Record the results produced by performing a [task] and return the cache |
4602 * entry associated with the results. | 4416 * entry associated with the results. |
4603 */ | 4417 */ |
4604 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 4418 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
4605 Source source = task.source; | 4419 Source source = task.source; |
4606 DartEntry dartEntry = _cache.get(source); | 4420 DartEntry dartEntry = _cache.get(source); |
4607 Source librarySource = task.libraryElement.source; | 4421 Source librarySource = task.libraryElement.source; |
4608 CaughtException thrownException = task.exception; | 4422 CaughtException thrownException = task.exception; |
4609 if (thrownException != null) { | 4423 if (thrownException != null) { |
4610 dartEntry.recordVerificationErrorInLibrary( | 4424 dartEntry.recordVerificationErrorInLibrary( |
4611 librarySource, | 4425 librarySource, thrownException); |
4612 thrownException); | |
4613 throw new AnalysisException('<rethrow>', thrownException); | 4426 throw new AnalysisException('<rethrow>', thrownException); |
4614 } | 4427 } |
4615 dartEntry.setValueInLibrary( | 4428 dartEntry.setValueInLibrary( |
4616 DartEntry.VERIFICATION_ERRORS, | 4429 DartEntry.VERIFICATION_ERRORS, librarySource, task.errors); |
4617 librarySource, | |
4618 task.errors); | |
4619 ChangeNoticeImpl notice = _getNotice(source); | 4430 ChangeNoticeImpl notice = _getNotice(source); |
4620 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO); | 4431 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO); |
4621 notice.setErrors(dartEntry.allErrors, lineInfo); | 4432 notice.setErrors(dartEntry.allErrors, lineInfo); |
4622 return dartEntry; | 4433 return dartEntry; |
4623 } | 4434 } |
4624 | 4435 |
4625 /** | 4436 /** |
4626 * Record the results produced by performing a [task] and return the cache | 4437 * Record the results produced by performing a [task] and return the cache |
4627 * entry associated with the results. | 4438 * entry associated with the results. |
4628 */ | 4439 */ |
4629 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { | 4440 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { |
4630 Source librarySource = task.libraryElement.source; | 4441 Source librarySource = task.libraryElement.source; |
4631 CaughtException thrownException = task.exception; | 4442 CaughtException thrownException = task.exception; |
4632 DartEntry libraryEntry = null; | 4443 DartEntry libraryEntry = null; |
4633 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; | 4444 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; |
4634 if (hintMap == null) { | 4445 if (hintMap == null) { |
4635 // We don't have any information about which sources to mark as invalid | 4446 // We don't have any information about which sources to mark as invalid |
4636 // other than the library source. | 4447 // other than the library source. |
4637 DartEntry libraryEntry = _cache.get(librarySource); | 4448 DartEntry libraryEntry = _cache.get(librarySource); |
4638 if (thrownException == null) { | 4449 if (thrownException == null) { |
4639 String message = | 4450 String message = "GenerateDartHintsTask returned a null hint map " |
4640 "GenerateDartHintsTask returned a null hint map " | 4451 "without throwing an exception: ${librarySource.fullName}"; |
4641 "without throwing an exception: ${librarySource.fullName}"; | |
4642 thrownException = | 4452 thrownException = |
4643 new CaughtException(new AnalysisException(message), null); | 4453 new CaughtException(new AnalysisException(message), null); |
4644 } | 4454 } |
4645 libraryEntry.recordHintErrorInLibrary(librarySource, thrownException); | 4455 libraryEntry.recordHintErrorInLibrary(librarySource, thrownException); |
4646 throw new AnalysisException('<rethrow>', thrownException); | 4456 throw new AnalysisException('<rethrow>', thrownException); |
4647 } | 4457 } |
4648 hintMap.forEach((Source unitSource, List<AnalysisError> hints) { | 4458 hintMap.forEach((Source unitSource, List<AnalysisError> hints) { |
4649 DartEntry dartEntry = _cache.get(unitSource); | 4459 DartEntry dartEntry = _cache.get(unitSource); |
4650 if (unitSource == librarySource) { | 4460 if (unitSource == librarySource) { |
4651 libraryEntry = dartEntry; | 4461 libraryEntry = dartEntry; |
(...skipping 20 matching lines...) Expand all Loading... |
4672 DartEntry _recordGenerateDartLintsTask(GenerateDartLintsTask task) { | 4482 DartEntry _recordGenerateDartLintsTask(GenerateDartLintsTask task) { |
4673 Source librarySource = task.libraryElement.source; | 4483 Source librarySource = task.libraryElement.source; |
4674 CaughtException thrownException = task.exception; | 4484 CaughtException thrownException = task.exception; |
4675 DartEntry libraryEntry = null; | 4485 DartEntry libraryEntry = null; |
4676 HashMap<Source, List<AnalysisError>> lintMap = task.lintMap; | 4486 HashMap<Source, List<AnalysisError>> lintMap = task.lintMap; |
4677 if (lintMap == null) { | 4487 if (lintMap == null) { |
4678 // We don't have any information about which sources to mark as invalid | 4488 // We don't have any information about which sources to mark as invalid |
4679 // other than the library source. | 4489 // other than the library source. |
4680 DartEntry libraryEntry = _cache.get(librarySource); | 4490 DartEntry libraryEntry = _cache.get(librarySource); |
4681 if (thrownException == null) { | 4491 if (thrownException == null) { |
4682 String message = | 4492 String message = "GenerateDartLintsTask returned a null lint map " |
4683 "GenerateDartLintsTask returned a null lint map " | 4493 "without throwing an exception: ${librarySource.fullName}"; |
4684 "without throwing an exception: ${librarySource.fullName}"; | |
4685 thrownException = | 4494 thrownException = |
4686 new CaughtException(new AnalysisException(message), null); | 4495 new CaughtException(new AnalysisException(message), null); |
4687 } | 4496 } |
4688 libraryEntry.recordLintErrorInLibrary(librarySource, thrownException); | 4497 libraryEntry.recordLintErrorInLibrary(librarySource, thrownException); |
4689 throw new AnalysisException('<rethrow>', thrownException); | 4498 throw new AnalysisException('<rethrow>', thrownException); |
4690 } | 4499 } |
4691 lintMap.forEach((Source unitSource, List<AnalysisError> lints) { | 4500 lintMap.forEach((Source unitSource, List<AnalysisError> lints) { |
4692 DartEntry dartEntry = _cache.get(unitSource); | 4501 DartEntry dartEntry = _cache.get(unitSource); |
4693 if (unitSource == librarySource) { | 4502 if (unitSource == librarySource) { |
4694 libraryEntry = dartEntry; | 4503 libraryEntry = dartEntry; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4734 return sourceEntry; | 4543 return sourceEntry; |
4735 } | 4544 } |
4736 | 4545 |
4737 /** | 4546 /** |
4738 * Record the results produced by performing a [IncrementalAnalysisTask]. | 4547 * Record the results produced by performing a [IncrementalAnalysisTask]. |
4739 * | 4548 * |
4740 * @param task the task that was performed | 4549 * @param task the task that was performed |
4741 * @return an entry containing the computed results | 4550 * @return an entry containing the computed results |
4742 * @throws AnalysisException if the results could not be recorded | 4551 * @throws AnalysisException if the results could not be recorded |
4743 */ | 4552 */ |
4744 DartEntry | 4553 DartEntry _recordIncrementalAnalysisTaskResults( |
4745 _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { | 4554 IncrementalAnalysisTask task) { |
4746 CompilationUnit unit = task.compilationUnit; | 4555 CompilationUnit unit = task.compilationUnit; |
4747 if (unit != null) { | 4556 if (unit != null) { |
4748 ChangeNoticeImpl notice = _getNotice(task.source); | 4557 ChangeNoticeImpl notice = _getNotice(task.source); |
4749 notice.resolvedDartUnit = unit; | 4558 notice.resolvedDartUnit = unit; |
4750 _incrementalAnalysisCache = | 4559 _incrementalAnalysisCache = |
4751 IncrementalAnalysisCache.cacheResult(task.cache, unit); | 4560 IncrementalAnalysisCache.cacheResult(task.cache, unit); |
4752 } | 4561 } |
4753 return null; | 4562 return null; |
4754 } | 4563 } |
4755 | 4564 |
(...skipping 17 matching lines...) Expand all Loading... |
4773 dartEntry.containingLibrary = source; | 4582 dartEntry.containingLibrary = source; |
4774 _workManager.add(source, SourcePriority.LIBRARY); | 4583 _workManager.add(source, SourcePriority.LIBRARY); |
4775 } else if (task.hasPartOfDirective) { | 4584 } else if (task.hasPartOfDirective) { |
4776 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 4585 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
4777 dartEntry.removeContainingLibrary(source); | 4586 dartEntry.removeContainingLibrary(source); |
4778 _workManager.add(source, SourcePriority.NORMAL_PART); | 4587 _workManager.add(source, SourcePriority.NORMAL_PART); |
4779 } else { | 4588 } else { |
4780 // The file contains no directives. | 4589 // The file contains no directives. |
4781 List<Source> containingLibraries = dartEntry.containingLibraries; | 4590 List<Source> containingLibraries = dartEntry.containingLibraries; |
4782 if (containingLibraries.length > 1 || | 4591 if (containingLibraries.length > 1 || |
4783 (containingLibraries.length == 1 && containingLibraries[0] != source))
{ | 4592 (containingLibraries.length == 1 && |
| 4593 containingLibraries[0] != source)) { |
4784 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 4594 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
4785 dartEntry.removeContainingLibrary(source); | 4595 dartEntry.removeContainingLibrary(source); |
4786 _workManager.add(source, SourcePriority.NORMAL_PART); | 4596 _workManager.add(source, SourcePriority.NORMAL_PART); |
4787 } else { | 4597 } else { |
4788 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 4598 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
4789 dartEntry.containingLibrary = source; | 4599 dartEntry.containingLibrary = source; |
4790 _workManager.add(source, SourcePriority.LIBRARY); | 4600 _workManager.add(source, SourcePriority.LIBRARY); |
4791 } | 4601 } |
4792 } | 4602 } |
4793 List<Source> newParts = task.includedSources; | 4603 List<Source> newParts = task.includedSources; |
(...skipping 13 matching lines...) Expand all Loading... |
4807 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts); | 4617 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts); |
4808 _cache.storedAst(source); | 4618 _cache.storedAst(source); |
4809 ChangeNoticeImpl notice = _getNotice(source); | 4619 ChangeNoticeImpl notice = _getNotice(source); |
4810 if (notice.resolvedDartUnit == null) { | 4620 if (notice.resolvedDartUnit == null) { |
4811 notice.parsedDartUnit = task.compilationUnit; | 4621 notice.parsedDartUnit = task.compilationUnit; |
4812 } | 4622 } |
4813 notice.setErrors(dartEntry.allErrors, task.lineInfo); | 4623 notice.setErrors(dartEntry.allErrors, task.lineInfo); |
4814 // Verify that the incrementally parsed and resolved unit in the incremental | 4624 // Verify that the incrementally parsed and resolved unit in the incremental |
4815 // cache is structurally equivalent to the fully parsed unit | 4625 // cache is structurally equivalent to the fully parsed unit |
4816 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure( | 4626 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure( |
4817 _incrementalAnalysisCache, | 4627 _incrementalAnalysisCache, source, task.compilationUnit); |
4818 source, | |
4819 task.compilationUnit); | |
4820 return dartEntry; | 4628 return dartEntry; |
4821 } | 4629 } |
4822 | 4630 |
4823 /** | 4631 /** |
4824 * Record the results produced by performing a [task] and return the cache | 4632 * Record the results produced by performing a [task] and return the cache |
4825 * entry associated with the results. | 4633 * entry associated with the results. |
4826 */ | 4634 */ |
4827 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) { | 4635 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) { |
4828 Source source = task.source; | 4636 Source source = task.source; |
4829 HtmlEntry htmlEntry = _cache.get(source); | 4637 HtmlEntry htmlEntry = _cache.get(source); |
4830 CaughtException thrownException = task.exception; | 4638 CaughtException thrownException = task.exception; |
4831 if (thrownException != null) { | 4639 if (thrownException != null) { |
4832 htmlEntry.recordParseError(thrownException); | 4640 htmlEntry.recordParseError(thrownException); |
4833 _cache.removedAst(source); | 4641 _cache.removedAst(source); |
4834 throw new AnalysisException('<rethrow>', thrownException); | 4642 throw new AnalysisException('<rethrow>', thrownException); |
4835 } | 4643 } |
4836 LineInfo lineInfo = task.lineInfo; | 4644 LineInfo lineInfo = task.lineInfo; |
4837 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 4645 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
4838 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, task.htmlUnit); | 4646 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, task.htmlUnit); |
4839 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors); | 4647 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors); |
4840 htmlEntry.setValue( | 4648 htmlEntry.setValue( |
4841 HtmlEntry.REFERENCED_LIBRARIES, | 4649 HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibraries); |
4842 task.referencedLibraries); | |
4843 _cache.storedAst(source); | 4650 _cache.storedAst(source); |
4844 ChangeNoticeImpl notice = _getNotice(source); | 4651 ChangeNoticeImpl notice = _getNotice(source); |
4845 notice.setErrors(htmlEntry.allErrors, lineInfo); | 4652 notice.setErrors(htmlEntry.allErrors, lineInfo); |
4846 return htmlEntry; | 4653 return htmlEntry; |
4847 } | 4654 } |
4848 | 4655 |
4849 /** | 4656 /** |
4850 * Record the results produced by performing a [task] and return the cache | 4657 * Record the results produced by performing a [task] and return the cache |
4851 * entry associated with the results. | 4658 * entry associated with the results. |
4852 */ | 4659 */ |
4853 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { | 4660 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { |
4854 Source unitSource = task.source; | 4661 Source unitSource = task.source; |
4855 DartEntry dartEntry = _cache.get(unitSource); | 4662 DartEntry dartEntry = _cache.get(unitSource); |
4856 Source librarySource = task.librarySource; | 4663 Source librarySource = task.librarySource; |
4857 CaughtException thrownException = task.exception; | 4664 CaughtException thrownException = task.exception; |
4858 if (thrownException != null) { | 4665 if (thrownException != null) { |
4859 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException); | 4666 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException); |
4860 _cache.removedAst(unitSource); | 4667 _cache.removedAst(unitSource); |
4861 throw new AnalysisException('<rethrow>', thrownException); | 4668 throw new AnalysisException('<rethrow>', thrownException); |
4862 } | 4669 } |
4863 dartEntry.setValueInLibrary( | 4670 dartEntry.setValueInLibrary( |
4864 DartEntry.RESOLVED_UNIT, | 4671 DartEntry.RESOLVED_UNIT, librarySource, task.resolvedUnit); |
4865 librarySource, | |
4866 task.resolvedUnit); | |
4867 _cache.storedAst(unitSource); | 4672 _cache.storedAst(unitSource); |
4868 return dartEntry; | 4673 return dartEntry; |
4869 } | 4674 } |
4870 | 4675 |
4871 /** | 4676 /** |
4872 * Record the results produced by performing a [task] and return the cache | 4677 * Record the results produced by performing a [task] and return the cache |
4873 * entry associated with the results. | 4678 * entry associated with the results. |
4874 */ | 4679 */ |
4875 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { | 4680 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { |
4876 Source source = task.source; | 4681 Source source = task.source; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5021 } | 4826 } |
5022 // Check if the content of the source is the same as it was the last time. | 4827 // Check if the content of the source is the same as it was the last time. |
5023 String sourceContent = sourceEntry.getValue(SourceEntry.CONTENT); | 4828 String sourceContent = sourceEntry.getValue(SourceEntry.CONTENT); |
5024 if (sourceContent != null) { | 4829 if (sourceContent != null) { |
5025 sourceEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 4830 sourceEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
5026 try { | 4831 try { |
5027 TimestampedData<String> fileContents = getContents(source); | 4832 TimestampedData<String> fileContents = getContents(source); |
5028 if (fileContents.data == sourceContent) { | 4833 if (fileContents.data == sourceContent) { |
5029 return; | 4834 return; |
5030 } | 4835 } |
5031 } catch (e) { | 4836 } catch (e) {} |
5032 } | |
5033 } | 4837 } |
5034 // We have to invalidate the cache. | 4838 // We have to invalidate the cache. |
5035 _propagateInvalidation(source, sourceEntry); | 4839 _propagateInvalidation(source, sourceEntry); |
5036 } | 4840 } |
5037 | 4841 |
5038 /** | 4842 /** |
5039 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 4843 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
5040 * | 4844 * |
5041 * @param source the source that has been deleted | 4845 * @param source the source that has been deleted |
5042 */ | 4846 */ |
5043 void _sourceDeleted(Source source) { | 4847 void _sourceDeleted(Source source) { |
5044 SourceEntry sourceEntry = _cache.get(source); | 4848 SourceEntry sourceEntry = _cache.get(source); |
5045 if (sourceEntry is HtmlEntry) { | 4849 if (sourceEntry is HtmlEntry) { |
5046 HtmlEntry htmlEntry = sourceEntry; | 4850 HtmlEntry htmlEntry = sourceEntry; |
5047 htmlEntry.recordContentError( | 4851 htmlEntry.recordContentError(new CaughtException( |
5048 new CaughtException( | 4852 new AnalysisException("This source was marked as being deleted"), |
5049 new AnalysisException("This source was marked as being deleted"), | 4853 null)); |
5050 null)); | |
5051 } else if (sourceEntry is DartEntry) { | 4854 } else if (sourceEntry is DartEntry) { |
5052 DartEntry dartEntry = sourceEntry; | 4855 DartEntry dartEntry = sourceEntry; |
5053 HashSet<Source> libraries = new HashSet<Source>(); | 4856 HashSet<Source> libraries = new HashSet<Source>(); |
5054 for (Source librarySource in getLibrariesContaining(source)) { | 4857 for (Source librarySource in getLibrariesContaining(source)) { |
5055 libraries.add(librarySource); | 4858 libraries.add(librarySource); |
5056 for (Source dependentLibrary in getLibrariesDependingOn( | 4859 for (Source dependentLibrary |
5057 librarySource)) { | 4860 in getLibrariesDependingOn(librarySource)) { |
5058 libraries.add(dependentLibrary); | 4861 libraries.add(dependentLibrary); |
5059 } | 4862 } |
5060 } | 4863 } |
5061 for (Source librarySource in libraries) { | 4864 for (Source librarySource in libraries) { |
5062 _invalidateLibraryResolution(librarySource); | 4865 _invalidateLibraryResolution(librarySource); |
5063 } | 4866 } |
5064 dartEntry.recordContentError( | 4867 dartEntry.recordContentError(new CaughtException( |
5065 new CaughtException( | 4868 new AnalysisException("This source was marked as being deleted"), |
5066 new AnalysisException("This source was marked as being deleted"), | 4869 null)); |
5067 null)); | |
5068 } | 4870 } |
5069 _workManager.remove(source); | 4871 _workManager.remove(source); |
5070 _removeFromPriorityOrder(source); | 4872 _removeFromPriorityOrder(source); |
5071 } | 4873 } |
5072 | 4874 |
5073 /** | 4875 /** |
5074 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 4876 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
5075 * | 4877 * |
5076 * @param source the source that has been removed | 4878 * @param source the source that has been removed |
5077 */ | 4879 */ |
5078 void _sourceRemoved(Source source) { | 4880 void _sourceRemoved(Source source) { |
5079 SourceEntry sourceEntry = _cache.get(source); | 4881 SourceEntry sourceEntry = _cache.get(source); |
5080 if (sourceEntry is HtmlEntry) { | 4882 if (sourceEntry is HtmlEntry) {} else if (sourceEntry is DartEntry) { |
5081 } else if (sourceEntry is DartEntry) { | |
5082 HashSet<Source> libraries = new HashSet<Source>(); | 4883 HashSet<Source> libraries = new HashSet<Source>(); |
5083 for (Source librarySource in getLibrariesContaining(source)) { | 4884 for (Source librarySource in getLibrariesContaining(source)) { |
5084 libraries.add(librarySource); | 4885 libraries.add(librarySource); |
5085 for (Source dependentLibrary in getLibrariesDependingOn( | 4886 for (Source dependentLibrary |
5086 librarySource)) { | 4887 in getLibrariesDependingOn(librarySource)) { |
5087 libraries.add(dependentLibrary); | 4888 libraries.add(dependentLibrary); |
5088 } | 4889 } |
5089 } | 4890 } |
5090 for (Source librarySource in libraries) { | 4891 for (Source librarySource in libraries) { |
5091 _invalidateLibraryResolution(librarySource); | 4892 _invalidateLibraryResolution(librarySource); |
5092 } | 4893 } |
5093 } | 4894 } |
5094 _cache.remove(source); | 4895 _cache.remove(source); |
5095 _workManager.remove(source); | 4896 _workManager.remove(source); |
5096 _removeFromPriorityOrder(source); | 4897 _removeFromPriorityOrder(source); |
(...skipping 25 matching lines...) Expand all Loading... |
5122 } | 4923 } |
5123 // prepare the existing unit | 4924 // prepare the existing unit |
5124 CompilationUnit oldUnit = | 4925 CompilationUnit oldUnit = |
5125 getResolvedCompilationUnit2(unitSource, librarySource); | 4926 getResolvedCompilationUnit2(unitSource, librarySource); |
5126 if (oldUnit == null) { | 4927 if (oldUnit == null) { |
5127 return false; | 4928 return false; |
5128 } | 4929 } |
5129 // do resolution | 4930 // do resolution |
5130 Stopwatch perfCounter = new Stopwatch()..start(); | 4931 Stopwatch perfCounter = new Stopwatch()..start(); |
5131 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( | 4932 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( |
5132 typeProvider, | 4933 typeProvider, unitSource, dartEntry, oldUnit, |
5133 unitSource, | |
5134 dartEntry, | |
5135 oldUnit, | |
5136 analysisOptions.incrementalApi); | 4934 analysisOptions.incrementalApi); |
5137 bool success = resolver.resolve(newCode); | 4935 bool success = resolver.resolve(newCode); |
5138 AnalysisEngine.instance.instrumentationService.logPerformance( | 4936 AnalysisEngine.instance.instrumentationService.logPerformance( |
5139 AnalysisPerformanceKind.INCREMENTAL, | 4937 AnalysisPerformanceKind.INCREMENTAL, perfCounter, |
5140 perfCounter, | |
5141 'success=$success,context_id=$_id,code_length=${newCode.length}'); | 4938 'success=$success,context_id=$_id,code_length=${newCode.length}'); |
5142 if (!success) { | 4939 if (!success) { |
5143 return false; | 4940 return false; |
5144 } | 4941 } |
5145 // if validation, remember the result, but throw it away | 4942 // if validation, remember the result, but throw it away |
5146 if (analysisOptions.incrementalValidation) { | 4943 if (analysisOptions.incrementalValidation) { |
5147 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; | 4944 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; |
5148 incrementalResolutionValidation_lastLibrarySource = | 4945 incrementalResolutionValidation_lastLibrarySource = |
5149 oldUnit.element.library.source; | 4946 oldUnit.element.library.source; |
5150 incrementalResolutionValidation_lastUnit = oldUnit; | 4947 incrementalResolutionValidation_lastUnit = oldUnit; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5229 incrementalResolutionValidation_lastLibrarySource == null || | 5026 incrementalResolutionValidation_lastLibrarySource == null || |
5230 incrementalResolutionValidation_lastUnit == null) { | 5027 incrementalResolutionValidation_lastUnit == null) { |
5231 return; | 5028 return; |
5232 } | 5029 } |
5233 CompilationUnit fullUnit = getResolvedCompilationUnit2( | 5030 CompilationUnit fullUnit = getResolvedCompilationUnit2( |
5234 incrementalResolutionValidation_lastUnitSource, | 5031 incrementalResolutionValidation_lastUnitSource, |
5235 incrementalResolutionValidation_lastLibrarySource); | 5032 incrementalResolutionValidation_lastLibrarySource); |
5236 if (fullUnit != null) { | 5033 if (fullUnit != null) { |
5237 try { | 5034 try { |
5238 assertSameResolution( | 5035 assertSameResolution( |
5239 incrementalResolutionValidation_lastUnit, | 5036 incrementalResolutionValidation_lastUnit, fullUnit); |
5240 fullUnit); | |
5241 } on IncrementalResolutionMismatch catch (mismatch, stack) { | 5037 } on IncrementalResolutionMismatch catch (mismatch, stack) { |
5242 String failure = mismatch.message; | 5038 String failure = mismatch.message; |
5243 String message = | 5039 String message = |
5244 'Incremental resolution mismatch:\n$failure\nat\n$stack'; | 5040 'Incremental resolution mismatch:\n$failure\nat\n$stack'; |
5245 AnalysisEngine.instance.logger.logError(message); | 5041 AnalysisEngine.instance.logger.logError(message); |
5246 } | 5042 } |
5247 } | 5043 } |
5248 incrementalResolutionValidation_lastUnitSource = null; | 5044 incrementalResolutionValidation_lastUnitSource = null; |
5249 incrementalResolutionValidation_lastLibrarySource = null; | 5045 incrementalResolutionValidation_lastLibrarySource = null; |
5250 incrementalResolutionValidation_lastUnit = null; | 5046 incrementalResolutionValidation_lastUnit = null; |
5251 } | 5047 } |
5252 } | 5048 } |
5253 | 5049 |
5254 /** | 5050 /** |
5255 * An `AnalysisTaskResultRecorder` is used by an analysis context to record the | 5051 * An `AnalysisTaskResultRecorder` is used by an analysis context to record the |
5256 * results of a task. | 5052 * results of a task. |
5257 */ | 5053 */ |
5258 class AnalysisContextImpl_AnalysisTaskResultRecorder implements | 5054 class AnalysisContextImpl_AnalysisTaskResultRecorder |
5259 AnalysisTaskVisitor<SourceEntry> { | 5055 implements AnalysisTaskVisitor<SourceEntry> { |
5260 final AnalysisContextImpl AnalysisContextImpl_this; | 5056 final AnalysisContextImpl AnalysisContextImpl_this; |
5261 | 5057 |
5262 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); | 5058 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); |
5263 | 5059 |
5264 @override | 5060 @override |
5265 DartEntry visitBuildUnitElementTask(BuildUnitElementTask task) => | 5061 DartEntry visitBuildUnitElementTask(BuildUnitElementTask task) => |
5266 AnalysisContextImpl_this._recordBuildUnitElementTask(task); | 5062 AnalysisContextImpl_this._recordBuildUnitElementTask(task); |
5267 | 5063 |
5268 @override | 5064 @override |
5269 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => | 5065 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => |
(...skipping 17 matching lines...) Expand all Loading... |
5287 | 5083 |
5288 @override | 5084 @override |
5289 DartEntry visitParseDartTask(ParseDartTask task) => | 5085 DartEntry visitParseDartTask(ParseDartTask task) => |
5290 AnalysisContextImpl_this._recordParseDartTaskResults(task); | 5086 AnalysisContextImpl_this._recordParseDartTaskResults(task); |
5291 | 5087 |
5292 @override | 5088 @override |
5293 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => | 5089 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => |
5294 AnalysisContextImpl_this._recordParseHtmlTaskResults(task); | 5090 AnalysisContextImpl_this._recordParseHtmlTaskResults(task); |
5295 | 5091 |
5296 @override | 5092 @override |
5297 DartEntry | 5093 DartEntry visitResolveDartLibraryCycleTask( |
5298 visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task) => | 5094 ResolveDartLibraryCycleTask task) => |
5299 AnalysisContextImpl_this.recordResolveDartLibraryCycleTaskResults(task); | 5095 AnalysisContextImpl_this.recordResolveDartLibraryCycleTaskResults(task); |
5300 | 5096 |
5301 @override | 5097 @override |
5302 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => | 5098 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => |
5303 AnalysisContextImpl_this.recordResolveDartLibraryTaskResults(task); | 5099 AnalysisContextImpl_this.recordResolveDartLibraryTaskResults(task); |
5304 | 5100 |
5305 @override | 5101 @override |
5306 DartEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => | 5102 DartEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => |
5307 AnalysisContextImpl_this._recordResolveDartUnitTaskResults(task); | 5103 AnalysisContextImpl_this._recordResolveDartUnitTaskResults(task); |
5308 | 5104 |
5309 @override | 5105 @override |
5310 HtmlEntry visitResolveHtmlTask(ResolveHtmlTask task) => | 5106 HtmlEntry visitResolveHtmlTask(ResolveHtmlTask task) => |
5311 AnalysisContextImpl_this._recordResolveHtmlTaskResults(task); | 5107 AnalysisContextImpl_this._recordResolveHtmlTaskResults(task); |
5312 | 5108 |
5313 @override | 5109 @override |
5314 DartEntry visitScanDartTask(ScanDartTask task) => | 5110 DartEntry visitScanDartTask(ScanDartTask task) => |
5315 AnalysisContextImpl_this._recordScanDartTaskResults(task); | 5111 AnalysisContextImpl_this._recordScanDartTaskResults(task); |
5316 } | 5112 } |
5317 | 5113 |
5318 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy | 5114 class AnalysisContextImpl_ContextRetentionPolicy |
5319 { | 5115 implements CacheRetentionPolicy { |
5320 final AnalysisContextImpl AnalysisContextImpl_this; | 5116 final AnalysisContextImpl AnalysisContextImpl_this; |
5321 | 5117 |
5322 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); | 5118 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); |
5323 | 5119 |
5324 @override | 5120 @override |
5325 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { | 5121 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { |
5326 int priorityCount = AnalysisContextImpl_this._priorityOrder.length; | 5122 int priorityCount = AnalysisContextImpl_this._priorityOrder.length; |
5327 for (int i = 0; i < priorityCount; i++) { | 5123 for (int i = 0; i < priorityCount; i++) { |
5328 if (source == AnalysisContextImpl_this._priorityOrder[i]) { | 5124 if (source == AnalysisContextImpl_this._priorityOrder[i]) { |
5329 return RetentionPriority.HIGH; | 5125 return RetentionPriority.HIGH; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5425 // | 5221 // |
5426 // Ensure that all of the data needed to resolve them has been computed. | 5222 // Ensure that all of the data needed to resolve them has been computed. |
5427 // | 5223 // |
5428 _ensureImportsAndExports(); | 5224 _ensureImportsAndExports(); |
5429 if (_taskData != null) { | 5225 if (_taskData != null) { |
5430 // At least one imported library needs to be resolved before the target | 5226 // At least one imported library needs to be resolved before the target |
5431 // library. | 5227 // library. |
5432 AnalysisTask task = _taskData.task; | 5228 AnalysisTask task = _taskData.task; |
5433 if (task is ResolveDartLibraryTask) { | 5229 if (task is ResolveDartLibraryTask) { |
5434 AnalysisContextImpl_this._workManager.addFirst( | 5230 AnalysisContextImpl_this._workManager.addFirst( |
5435 task.librarySource, | 5231 task.librarySource, SourcePriority.LIBRARY); |
5436 SourcePriority.LIBRARY); | |
5437 } | 5232 } |
5438 return; | 5233 return; |
5439 } | 5234 } |
5440 _computePartsInCycle(librarySource); | 5235 _computePartsInCycle(librarySource); |
5441 if (_taskData != null) { | 5236 if (_taskData != null) { |
5442 // At least one part needs to be parsed. | 5237 // At least one part needs to be parsed. |
5443 return; | 5238 return; |
5444 } | 5239 } |
5445 // All of the AST's necessary to perform a resolution of the library cycle | 5240 // All of the AST's necessary to perform a resolution of the library cycle |
5446 // have been gathered, so it is no longer necessary to retain them in the | 5241 // have been gathered, so it is no longer necessary to retain them in the |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5489 _getSources(librarySource, dartEntry, DartEntry.IMPORTED_LIBRARIES); | 5284 _getSources(librarySource, dartEntry, DartEntry.IMPORTED_LIBRARIES); |
5490 if (_taskData != null) { | 5285 if (_taskData != null) { |
5491 return; | 5286 return; |
5492 } | 5287 } |
5493 List<Source> exportedSources = | 5288 List<Source> exportedSources = |
5494 _getSources(librarySource, dartEntry, DartEntry.EXPORTED_LIBRARIES); | 5289 _getSources(librarySource, dartEntry, DartEntry.EXPORTED_LIBRARIES); |
5495 if (_taskData != null) { | 5290 if (_taskData != null) { |
5496 return; | 5291 return; |
5497 } | 5292 } |
5498 _computeLibraryDependenciesFromDirectives( | 5293 _computeLibraryDependenciesFromDirectives( |
5499 library, | 5294 library, importedSources, exportedSources); |
5500 importedSources, | |
5501 exportedSources); | |
5502 } | 5295 } |
5503 | 5296 |
5504 /** | 5297 /** |
5505 * Recursively traverse the libraries reachable from the given library, creati
ng instances of | 5298 * Recursively traverse the libraries reachable from the given library, creati
ng instances of |
5506 * the class [Library] to represent them, and record the references in the lib
rary | 5299 * the class [Library] to represent them, and record the references in the lib
rary |
5507 * objects. | 5300 * objects. |
5508 * | 5301 * |
5509 * @param library the library to be processed to find libraries that have not
yet been traversed | 5302 * @param library the library to be processed to find libraries that have not
yet been traversed |
5510 * @param importedSources an array containing the sources that are imported in
to the given | 5303 * @param importedSources an array containing the sources that are imported in
to the given |
5511 * library | 5304 * library |
(...skipping 13 matching lines...) Expand all Loading... |
5525 } else if (importedSource == | 5318 } else if (importedSource == |
5526 AnalysisContextImpl_this._asyncLibrarySource) { | 5319 AnalysisContextImpl_this._asyncLibrarySource) { |
5527 importsAsync = true; | 5320 importsAsync = true; |
5528 } | 5321 } |
5529 if (!_addDependency(library, importedSource, importedLibraries)) { | 5322 if (!_addDependency(library, importedSource, importedLibraries)) { |
5530 return; | 5323 return; |
5531 } | 5324 } |
5532 } | 5325 } |
5533 library.explicitlyImportsCore = explicitlyImportsCore; | 5326 library.explicitlyImportsCore = explicitlyImportsCore; |
5534 if (!explicitlyImportsCore) { | 5327 if (!explicitlyImportsCore) { |
5535 if (!_addDependency( | 5328 if (!_addDependency(library, AnalysisContextImpl_this._coreLibrarySource, |
5536 library, | |
5537 AnalysisContextImpl_this._coreLibrarySource, | |
5538 importedLibraries)) { | 5329 importedLibraries)) { |
5539 return; | 5330 return; |
5540 } | 5331 } |
5541 } | 5332 } |
5542 if (!importsAsync) { | 5333 if (!importsAsync) { |
5543 // Add a dependency on async to ensure that the Future element will be | 5334 // Add a dependency on async to ensure that the Future element will be |
5544 // built before we generate errors and warnings for async methods. Also | 5335 // built before we generate errors and warnings for async methods. Also |
5545 // include it in importedLibraries, so that it will be picked up by | 5336 // include it in importedLibraries, so that it will be picked up by |
5546 // LibraryResolver2._buildLibraryMap(). | 5337 // LibraryResolver2._buildLibraryMap(). |
5547 // TODO(paulberry): this is a bit of a hack, since the async library | 5338 // TODO(paulberry): this is a bit of a hack, since the async library |
5548 // isn't actually being imported. Also, it's not clear whether it should | 5339 // isn't actually being imported. Also, it's not clear whether it should |
5549 // be necessary: in theory, dart:core already (indirectly) imports | 5340 // be necessary: in theory, dart:core already (indirectly) imports |
5550 // dart:async, so if core has been built, async should have been built | 5341 // dart:async, so if core has been built, async should have been built |
5551 // too. However, removing this code causes unit test failures. | 5342 // too. However, removing this code causes unit test failures. |
5552 if (!_addDependency( | 5343 if (!_addDependency(library, AnalysisContextImpl_this._asyncLibrarySource, |
5553 library, | |
5554 AnalysisContextImpl_this._asyncLibrarySource, | |
5555 importedLibraries)) { | 5344 importedLibraries)) { |
5556 return; | 5345 return; |
5557 } | 5346 } |
5558 } | 5347 } |
5559 library.importedLibraries = importedLibraries; | 5348 library.importedLibraries = importedLibraries; |
5560 int exportCount = exportedSources.length; | 5349 int exportCount = exportedSources.length; |
5561 if (exportCount > 0) { | 5350 if (exportCount > 0) { |
5562 List<ResolvableLibrary> exportedLibraries = new List<ResolvableLibrary>(); | 5351 List<ResolvableLibrary> exportedLibraries = new List<ResolvableLibrary>(); |
5563 for (int i = 0; i < exportCount; i++) { | 5352 for (int i = 0; i < exportCount; i++) { |
5564 Source exportedSource = exportedSources[i]; | 5353 Source exportedSource = exportedSources[i]; |
(...skipping 11 matching lines...) Expand all Loading... |
5576 * AST structure for each compilation unit, then we gather them. We split the
work this way | 5365 * AST structure for each compilation unit, then we gather them. We split the
work this way |
5577 * because getting the AST structures can change the state of the cache in suc
h a way that we | 5366 * because getting the AST structures can change the state of the cache in suc
h a way that we |
5578 * would have more work to do if any compilation unit didn't have a resolvable
AST structure. | 5367 * would have more work to do if any compilation unit didn't have a resolvable
AST structure. |
5579 */ | 5368 */ |
5580 void _computePartsInCycle(Source librarySource) { | 5369 void _computePartsInCycle(Source librarySource) { |
5581 int count = _librariesInCycle.length; | 5370 int count = _librariesInCycle.length; |
5582 List<CycleBuilder_LibraryPair> libraryData = | 5371 List<CycleBuilder_LibraryPair> libraryData = |
5583 new List<CycleBuilder_LibraryPair>(); | 5372 new List<CycleBuilder_LibraryPair>(); |
5584 for (int i = 0; i < count; i++) { | 5373 for (int i = 0; i < count; i++) { |
5585 ResolvableLibrary library = _librariesInCycle[i]; | 5374 ResolvableLibrary library = _librariesInCycle[i]; |
5586 libraryData.add( | 5375 libraryData.add(new CycleBuilder_LibraryPair( |
5587 new CycleBuilder_LibraryPair(library, _ensurePartsInLibrary(library)))
; | 5376 library, _ensurePartsInLibrary(library))); |
5588 } | 5377 } |
5589 AnalysisContextImpl_this._neededForResolution = _gatherSources(libraryData); | 5378 AnalysisContextImpl_this._neededForResolution = _gatherSources(libraryData); |
5590 if (AnalysisContextImpl._TRACE_PERFORM_TASK) { | 5379 if (AnalysisContextImpl._TRACE_PERFORM_TASK) { |
5591 print( | 5380 print( |
5592 " preserve resolution data for ${AnalysisContextImpl_this._neededForR
esolution.length} sources while resolving ${librarySource.fullName}"); | 5381 " preserve resolution data for ${AnalysisContextImpl_this._neededForR
esolution.length} sources while resolving ${librarySource.fullName}"); |
5593 } | 5382 } |
5594 if (_taskData != null) { | 5383 if (_taskData != null) { |
5595 return; | 5384 return; |
5596 } | 5385 } |
5597 for (int i = 0; i < count; i++) { | 5386 for (int i = 0; i < count; i++) { |
(...skipping 11 matching lines...) Expand all Loading... |
5609 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) { | 5398 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) { |
5610 ResolvableLibrary library = libraryPair.library; | 5399 ResolvableLibrary library = libraryPair.library; |
5611 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs; | 5400 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs; |
5612 int count = entryPairs.length; | 5401 int count = entryPairs.length; |
5613 List<ResolvableCompilationUnit> units = | 5402 List<ResolvableCompilationUnit> units = |
5614 new List<ResolvableCompilationUnit>(count); | 5403 new List<ResolvableCompilationUnit>(count); |
5615 for (int i = 0; i < count; i++) { | 5404 for (int i = 0; i < count; i++) { |
5616 CycleBuilder_SourceEntryPair entryPair = entryPairs[i]; | 5405 CycleBuilder_SourceEntryPair entryPair = entryPairs[i]; |
5617 Source source = entryPair.source; | 5406 Source source = entryPair.source; |
5618 DartEntry dartEntry = entryPair.entry; | 5407 DartEntry dartEntry = entryPair.entry; |
5619 units[i] = | 5408 units[i] = new ResolvableCompilationUnit( |
5620 new ResolvableCompilationUnit(source, dartEntry.resolvableCompilationU
nit); | 5409 source, dartEntry.resolvableCompilationUnit); |
5621 } | 5410 } |
5622 library.resolvableCompilationUnits = units; | 5411 library.resolvableCompilationUnits = units; |
5623 } | 5412 } |
5624 | 5413 |
5625 /** | 5414 /** |
5626 * Create an object to represent the information about the library defined by
the compilation | 5415 * Create an object to represent the information about the library defined by
the compilation |
5627 * unit with the given source. | 5416 * unit with the given source. |
5628 * | 5417 * |
5629 * @param librarySource the source of the library's defining compilation unit | 5418 * @param librarySource the source of the library's defining compilation unit |
5630 * @return the library object that was created | 5419 * @return the library object that was created |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5672 * | 5461 * |
5673 * @param library the library which needs an element model. | 5462 * @param library the library which needs an element model. |
5674 */ | 5463 */ |
5675 void _ensureElementModel(ResolvableLibrary library) { | 5464 void _ensureElementModel(ResolvableLibrary library) { |
5676 Source librarySource = library.librarySource; | 5465 Source librarySource = library.librarySource; |
5677 DartEntry libraryEntry = | 5466 DartEntry libraryEntry = |
5678 AnalysisContextImpl_this._getReadableDartEntry(librarySource); | 5467 AnalysisContextImpl_this._getReadableDartEntry(librarySource); |
5679 if (libraryEntry != null && | 5468 if (libraryEntry != null && |
5680 libraryEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) { | 5469 libraryEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) { |
5681 AnalysisContextImpl_this._workManager.addFirst( | 5470 AnalysisContextImpl_this._workManager.addFirst( |
5682 librarySource, | 5471 librarySource, SourcePriority.LIBRARY); |
5683 SourcePriority.LIBRARY); | |
5684 if (_taskData == null) { | 5472 if (_taskData == null) { |
5685 _taskData = AnalysisContextImpl_this._createResolveDartLibraryTask( | 5473 _taskData = AnalysisContextImpl_this._createResolveDartLibraryTask( |
5686 librarySource, | 5474 librarySource, libraryEntry); |
5687 libraryEntry); | |
5688 } | 5475 } |
5689 } | 5476 } |
5690 } | 5477 } |
5691 | 5478 |
5692 /** | 5479 /** |
5693 * Ensure that all of the libraries that are exported by the given library (bu
t are not | 5480 * Ensure that all of the libraries that are exported by the given library (bu
t are not |
5694 * themselves in the cycle) have element models built for them. If another tas
k needs to be | 5481 * themselves in the cycle) have element models built for them. If another tas
k needs to be |
5695 * executed first in order to build the element model, that task is placed in
[taskData]. | 5482 * executed first in order to build the element model, that task is placed in
[taskData]. |
5696 * | 5483 * |
5697 * @param library the library being tested | 5484 * @param library the library being tested |
5698 */ | 5485 */ |
5699 void _ensureExports(ResolvableLibrary library, | 5486 void _ensureExports( |
5700 HashSet<Source> visitedLibraries) { | 5487 ResolvableLibrary library, HashSet<Source> visitedLibraries) { |
5701 List<ResolvableLibrary> dependencies = library.exports; | 5488 List<ResolvableLibrary> dependencies = library.exports; |
5702 int dependencyCount = dependencies.length; | 5489 int dependencyCount = dependencies.length; |
5703 for (int i = 0; i < dependencyCount; i++) { | 5490 for (int i = 0; i < dependencyCount; i++) { |
5704 ResolvableLibrary dependency = dependencies[i]; | 5491 ResolvableLibrary dependency = dependencies[i]; |
5705 if (!_librariesInCycle.contains(dependency) && | 5492 if (!_librariesInCycle.contains(dependency) && |
5706 visitedLibraries.add(dependency.librarySource)) { | 5493 visitedLibraries.add(dependency.librarySource)) { |
5707 if (dependency.libraryElement == null) { | 5494 if (dependency.libraryElement == null) { |
5708 _ensureElementModel(dependency); | 5495 _ensureElementModel(dependency); |
5709 } else { | 5496 } else { |
5710 _ensureExports(dependency, visitedLibraries); | 5497 _ensureExports(dependency, visitedLibraries); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5758 } | 5545 } |
5759 } | 5546 } |
5760 | 5547 |
5761 /** | 5548 /** |
5762 * Ensure that there is a resolvable compilation unit available for all of the
compilation units | 5549 * Ensure that there is a resolvable compilation unit available for all of the
compilation units |
5763 * in the given library. | 5550 * in the given library. |
5764 * | 5551 * |
5765 * @param library the library for which resolvable compilation units must be a
vailable | 5552 * @param library the library for which resolvable compilation units must be a
vailable |
5766 * @return a list of (source, entry) pairs for all of the compilation units in
the library | 5553 * @return a list of (source, entry) pairs for all of the compilation units in
the library |
5767 */ | 5554 */ |
5768 List<CycleBuilder_SourceEntryPair> | 5555 List<CycleBuilder_SourceEntryPair> _ensurePartsInLibrary( |
5769 _ensurePartsInLibrary(ResolvableLibrary library) { | 5556 ResolvableLibrary library) { |
5770 List<CycleBuilder_SourceEntryPair> pairs = | 5557 List<CycleBuilder_SourceEntryPair> pairs = |
5771 new List<CycleBuilder_SourceEntryPair>(); | 5558 new List<CycleBuilder_SourceEntryPair>(); |
5772 Source librarySource = library.librarySource; | 5559 Source librarySource = library.librarySource; |
5773 DartEntry libraryEntry = | 5560 DartEntry libraryEntry = |
5774 AnalysisContextImpl_this._getReadableDartEntry(librarySource); | 5561 AnalysisContextImpl_this._getReadableDartEntry(librarySource); |
5775 if (libraryEntry == null) { | 5562 if (libraryEntry == null) { |
5776 throw new AnalysisException( | 5563 throw new AnalysisException( |
5777 "Cannot find entry for ${librarySource.fullName}"); | 5564 "Cannot find entry for ${librarySource.fullName}"); |
5778 } else if (libraryEntry.getState(DartEntry.PARSED_UNIT) == | 5565 } else if (libraryEntry.getState(DartEntry.PARSED_UNIT) == |
5779 CacheState.ERROR) { | 5566 CacheState.ERROR) { |
5780 String message = | 5567 String message = |
5781 "Cannot compute parsed unit for ${librarySource.fullName}"; | 5568 "Cannot compute parsed unit for ${librarySource.fullName}"; |
5782 CaughtException exception = libraryEntry.exception; | 5569 CaughtException exception = libraryEntry.exception; |
5783 if (exception == null) { | 5570 if (exception == null) { |
5784 throw new AnalysisException(message); | 5571 throw new AnalysisException(message); |
5785 } | 5572 } |
5786 throw new AnalysisException( | 5573 throw new AnalysisException( |
5787 message, | 5574 message, new CaughtException(exception, null)); |
5788 new CaughtException(exception, null)); | |
5789 } | 5575 } |
5790 _ensureResolvableCompilationUnit(librarySource, libraryEntry); | 5576 _ensureResolvableCompilationUnit(librarySource, libraryEntry); |
5791 pairs.add(new CycleBuilder_SourceEntryPair(librarySource, libraryEntry)); | 5577 pairs.add(new CycleBuilder_SourceEntryPair(librarySource, libraryEntry)); |
5792 List<Source> partSources = | 5578 List<Source> partSources = |
5793 _getSources(librarySource, libraryEntry, DartEntry.INCLUDED_PARTS); | 5579 _getSources(librarySource, libraryEntry, DartEntry.INCLUDED_PARTS); |
5794 int count = partSources.length; | 5580 int count = partSources.length; |
5795 for (int i = 0; i < count; i++) { | 5581 for (int i = 0; i < count; i++) { |
5796 Source partSource = partSources[i]; | 5582 Source partSource = partSources[i]; |
5797 DartEntry partEntry = | 5583 DartEntry partEntry = |
5798 AnalysisContextImpl_this._getReadableDartEntry(partSource); | 5584 AnalysisContextImpl_this._getReadableDartEntry(partSource); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5938 } | 5724 } |
5939 | 5725 |
5940 /** | 5726 /** |
5941 * Information about single piece of data in the cache. | 5727 * Information about single piece of data in the cache. |
5942 */ | 5728 */ |
5943 abstract class AnalysisContextStatistics_CacheRow { | 5729 abstract class AnalysisContextStatistics_CacheRow { |
5944 /** | 5730 /** |
5945 * List of possible states which can be queried. | 5731 * List of possible states which can be queried. |
5946 */ | 5732 */ |
5947 static const List<CacheState> STATES = const <CacheState>[ | 5733 static const List<CacheState> STATES = const <CacheState>[ |
5948 CacheState.ERROR, | 5734 CacheState.ERROR, |
5949 CacheState.FLUSHED, | 5735 CacheState.FLUSHED, |
5950 CacheState.IN_PROCESS, | 5736 CacheState.IN_PROCESS, |
5951 CacheState.INVALID, | 5737 CacheState.INVALID, |
5952 CacheState.VALID]; | 5738 CacheState.VALID |
| 5739 ]; |
5953 | 5740 |
5954 /** | 5741 /** |
5955 * Return the number of entries whose state is [CacheState.ERROR]. | 5742 * Return the number of entries whose state is [CacheState.ERROR]. |
5956 */ | 5743 */ |
5957 int get errorCount; | 5744 int get errorCount; |
5958 | 5745 |
5959 /** | 5746 /** |
5960 * Return the number of entries whose state is [CacheState.FLUSHED]. | 5747 * Return the number of entries whose state is [CacheState.FLUSHED]. |
5961 */ | 5748 */ |
5962 int get flushedCount; | 5749 int get flushedCount; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6053 row._incState(state); | 5840 row._incState(state); |
6054 if (state == CacheState.ERROR) { | 5841 if (state == CacheState.ERROR) { |
6055 CaughtException exception = dartEntry.exception; | 5842 CaughtException exception = dartEntry.exception; |
6056 if (exception != null) { | 5843 if (exception != null) { |
6057 _exceptions.add(exception); | 5844 _exceptions.add(exception); |
6058 } | 5845 } |
6059 } | 5846 } |
6060 } | 5847 } |
6061 } | 5848 } |
6062 | 5849 |
6063 class AnalysisContextStatisticsImpl_CacheRowImpl implements | 5850 class AnalysisContextStatisticsImpl_CacheRowImpl |
6064 AnalysisContextStatistics_CacheRow { | 5851 implements AnalysisContextStatistics_CacheRow { |
6065 final String name; | 5852 final String name; |
6066 | 5853 |
6067 Map<CacheState, int> _counts = <CacheState, int>{}; | 5854 Map<CacheState, int> _counts = <CacheState, int>{}; |
6068 | 5855 |
6069 AnalysisContextStatisticsImpl_CacheRowImpl(this.name); | 5856 AnalysisContextStatisticsImpl_CacheRowImpl(this.name); |
6070 | 5857 |
6071 @override | 5858 @override |
6072 int get errorCount => getCount(CacheState.ERROR); | 5859 int get errorCount => getCount(CacheState.ERROR); |
6073 | 5860 |
6074 @override | 5861 @override |
(...skipping 27 matching lines...) Expand all Loading... |
6102 | 5889 |
6103 void _incState(CacheState state) { | 5890 void _incState(CacheState state) { |
6104 if (_counts[state] == null) { | 5891 if (_counts[state] == null) { |
6105 _counts[state] = 1; | 5892 _counts[state] = 1; |
6106 } else { | 5893 } else { |
6107 _counts[state]++; | 5894 _counts[state]++; |
6108 } | 5895 } |
6109 } | 5896 } |
6110 } | 5897 } |
6111 | 5898 |
6112 class AnalysisContextStatisticsImpl_PartitionDataImpl implements | 5899 class AnalysisContextStatisticsImpl_PartitionDataImpl |
6113 AnalysisContextStatistics_PartitionData { | 5900 implements AnalysisContextStatistics_PartitionData { |
6114 final int astCount; | 5901 final int astCount; |
6115 | 5902 |
6116 final int totalCount; | 5903 final int totalCount; |
6117 | 5904 |
6118 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount, | 5905 AnalysisContextStatisticsImpl_PartitionDataImpl( |
6119 this.totalCount); | 5906 this.astCount, this.totalCount); |
6120 } | 5907 } |
6121 | 5908 |
6122 /** | 5909 /** |
6123 * Instances of the class `AnalysisDelta` indicate changes to the types of analy
sis that | 5910 * Instances of the class `AnalysisDelta` indicate changes to the types of analy
sis that |
6124 * should be performed. | 5911 * should be performed. |
6125 */ | 5912 */ |
6126 class AnalysisDelta { | 5913 class AnalysisDelta { |
6127 /** | 5914 /** |
6128 * A mapping from source to what type of analysis should be performed on that
source. | 5915 * A mapping from source to what type of analysis should be performed on that
source. |
6129 */ | 5916 */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6171 needsSeparator = | 5958 needsSeparator = |
6172 _appendSources(buffer, needsSeparator, AnalysisLevel.RESOLVED); | 5959 _appendSources(buffer, needsSeparator, AnalysisLevel.RESOLVED); |
6173 _appendSources(buffer, needsSeparator, AnalysisLevel.NONE); | 5960 _appendSources(buffer, needsSeparator, AnalysisLevel.NONE); |
6174 return buffer.toString(); | 5961 return buffer.toString(); |
6175 } | 5962 } |
6176 | 5963 |
6177 /** | 5964 /** |
6178 * Appendto the given [builder] all sources with the given analysis [level], | 5965 * Appendto the given [builder] all sources with the given analysis [level], |
6179 * prefixed with a label and a separator if [needsSeparator] is `true`. | 5966 * prefixed with a label and a separator if [needsSeparator] is `true`. |
6180 */ | 5967 */ |
6181 bool _appendSources(StringBuffer buffer, bool needsSeparator, | 5968 bool _appendSources( |
6182 AnalysisLevel level) { | 5969 StringBuffer buffer, bool needsSeparator, AnalysisLevel level) { |
6183 bool first = true; | 5970 bool first = true; |
6184 _analysisMap.forEach((Source source, AnalysisLevel sourceLevel) { | 5971 _analysisMap.forEach((Source source, AnalysisLevel sourceLevel) { |
6185 if (sourceLevel == level) { | 5972 if (sourceLevel == level) { |
6186 if (first) { | 5973 if (first) { |
6187 first = false; | 5974 first = false; |
6188 if (needsSeparator) { | 5975 if (needsSeparator) { |
6189 buffer.write("; "); | 5976 buffer.write("; "); |
6190 } | 5977 } |
6191 buffer.write(level); | 5978 buffer.write(level); |
6192 buffer.write(" "); | 5979 buffer.write(" "); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6316 * Return `true` if the given file name is assumed to contain Dart source code
. | 6103 * Return `true` if the given file name is assumed to contain Dart source code
. |
6317 * | 6104 * |
6318 * @param fileName the name of the file being tested | 6105 * @param fileName the name of the file being tested |
6319 * @return `true` if the given file name is assumed to contain Dart source cod
e | 6106 * @return `true` if the given file name is assumed to contain Dart source cod
e |
6320 */ | 6107 */ |
6321 static bool isDartFileName(String fileName) { | 6108 static bool isDartFileName(String fileName) { |
6322 if (fileName == null) { | 6109 if (fileName == null) { |
6323 return false; | 6110 return false; |
6324 } | 6111 } |
6325 return javaStringEqualsIgnoreCase( | 6112 return javaStringEqualsIgnoreCase( |
6326 FileNameUtilities.getExtension(fileName), | 6113 FileNameUtilities.getExtension(fileName), SUFFIX_DART); |
6327 SUFFIX_DART); | |
6328 } | 6114 } |
6329 | 6115 |
6330 /** | 6116 /** |
6331 * Return `true` if the given file name is assumed to contain HTML. | 6117 * Return `true` if the given file name is assumed to contain HTML. |
6332 * | 6118 * |
6333 * @param fileName the name of the file being tested | 6119 * @param fileName the name of the file being tested |
6334 * @return `true` if the given file name is assumed to contain HTML | 6120 * @return `true` if the given file name is assumed to contain HTML |
6335 */ | 6121 */ |
6336 static bool isHtmlFileName(String fileName) { | 6122 static bool isHtmlFileName(String fileName) { |
6337 if (fileName == null) { | 6123 if (fileName == null) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6479 */ | 6265 */ |
6480 void parsedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); | 6266 void parsedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); |
6481 | 6267 |
6482 /** | 6268 /** |
6483 * Reports that the given Dart source was resolved in the given context. | 6269 * Reports that the given Dart source was resolved in the given context. |
6484 * | 6270 * |
6485 * @param context the context in which the source was resolved | 6271 * @param context the context in which the source was resolved |
6486 * @param source the source that was resolved | 6272 * @param source the source that was resolved |
6487 * @param unit the result of resolving the source in the given context | 6273 * @param unit the result of resolving the source in the given context |
6488 */ | 6274 */ |
6489 void resolvedDart(AnalysisContext context, Source source, | 6275 void resolvedDart( |
6490 CompilationUnit unit); | 6276 AnalysisContext context, Source source, CompilationUnit unit); |
6491 | 6277 |
6492 /** | 6278 /** |
6493 * Reports that the given HTML source was resolved in the given context. | 6279 * Reports that the given HTML source was resolved in the given context. |
6494 * | 6280 * |
6495 * @param context the context in which the source was resolved | 6281 * @param context the context in which the source was resolved |
6496 * @param source the source that was resolved | 6282 * @param source the source that was resolved |
6497 * @param unit the result of resolving the source in the given context | 6283 * @param unit the result of resolving the source in the given context |
6498 */ | 6284 */ |
6499 void resolvedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); | 6285 void resolvedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); |
6500 } | 6286 } |
6501 | 6287 |
6502 /** | 6288 /** |
6503 * Futures returned by [AnalysisContext] for pending analysis results will | 6289 * Futures returned by [AnalysisContext] for pending analysis results will |
6504 * complete with this error if it is determined that analysis results will | 6290 * complete with this error if it is determined that analysis results will |
6505 * never become available (e.g. because the requested source is not subject to | 6291 * never become available (e.g. because the requested source is not subject to |
6506 * analysis, or because the requested source is a part file which is not a part | 6292 * analysis, or because the requested source is a part file which is not a part |
6507 * of any known library). | 6293 * of any known library). |
6508 */ | 6294 */ |
6509 class AnalysisNotScheduledError implements Exception { | 6295 class AnalysisNotScheduledError implements Exception {} |
6510 } | |
6511 | 6296 |
6512 /** | 6297 /** |
6513 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a | 6298 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a |
6514 * set of analysis options used to control the behavior of an analysis context. | 6299 * set of analysis options used to control the behavior of an analysis context. |
6515 */ | 6300 */ |
6516 abstract class AnalysisOptions { | 6301 abstract class AnalysisOptions { |
6517 /** | 6302 /** |
6518 * If analysis is to parse and analyze all function bodies, return `true`. | 6303 * If analysis is to parse and analyze all function bodies, return `true`. |
6519 * If analysis is to skip all function bodies, return `false`. If analysis | 6304 * If analysis is to skip all function bodies, return `false`. If analysis |
6520 * is to parse and analyze function bodies in some sources and not in others, | 6305 * is to parse and analyze function bodies in some sources and not in others, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6717 incrementalApi = options.incrementalApi; | 6502 incrementalApi = options.incrementalApi; |
6718 incrementalValidation = options.incrementalValidation; | 6503 incrementalValidation = options.incrementalValidation; |
6719 lint = options.lint; | 6504 lint = options.lint; |
6720 preserveComments = options.preserveComments; | 6505 preserveComments = options.preserveComments; |
6721 } | 6506 } |
6722 | 6507 |
6723 bool get analyzeFunctionBodies { | 6508 bool get analyzeFunctionBodies { |
6724 if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { | 6509 if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { |
6725 return true; | 6510 return true; |
6726 } else if (identical( | 6511 } else if (identical( |
6727 analyzeFunctionBodiesPredicate, | 6512 analyzeFunctionBodiesPredicate, _analyzeNoFunctionBodies)) { |
6728 _analyzeNoFunctionBodies)) { | |
6729 return false; | 6513 return false; |
6730 } else { | 6514 } else { |
6731 throw new StateError('analyzeFunctionBodiesPredicate in use'); | 6515 throw new StateError('analyzeFunctionBodiesPredicate in use'); |
6732 } | 6516 } |
6733 } | 6517 } |
6734 | 6518 |
6735 set analyzeFunctionBodies(bool value) { | 6519 set analyzeFunctionBodies(bool value) { |
6736 if (value) { | 6520 if (value) { |
6737 analyzeFunctionBodiesPredicate = _analyzeAllFunctionBodies; | 6521 analyzeFunctionBodiesPredicate = _analyzeAllFunctionBodies; |
6738 } else { | 6522 } else { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6831 final int performTime; | 6615 final int performTime; |
6832 | 6616 |
6833 /** | 6617 /** |
6834 * Initialize a newly created analysis result to have the given values. | 6618 * Initialize a newly created analysis result to have the given values. |
6835 * | 6619 * |
6836 * @param notices the change notices associated with this result | 6620 * @param notices the change notices associated with this result |
6837 * @param getTime the number of milliseconds required to determine which task
was to be performed | 6621 * @param getTime the number of milliseconds required to determine which task
was to be performed |
6838 * @param taskClassName the name of the class of the task that was performed | 6622 * @param taskClassName the name of the class of the task that was performed |
6839 * @param performTime the number of milliseconds required to perform the task | 6623 * @param performTime the number of milliseconds required to perform the task |
6840 */ | 6624 */ |
6841 AnalysisResult(this._notices, this.getTime, this.taskClassName, | 6625 AnalysisResult( |
6842 this.performTime); | 6626 this._notices, this.getTime, this.taskClassName, this.performTime); |
6843 | 6627 |
6844 /** | 6628 /** |
6845 * Return the change notices associated with this result, or `null` if there w
ere no changes | 6629 * Return the change notices associated with this result, or `null` if there w
ere no changes |
6846 * and there is no more work to be done. | 6630 * and there is no more work to be done. |
6847 * | 6631 * |
6848 * @return the change notices associated with this result | 6632 * @return the change notices associated with this result |
6849 */ | 6633 */ |
6850 List<ChangeNotice> get changeNotices => _notices; | 6634 List<ChangeNotice> get changeNotices => _notices; |
6851 | 6635 |
6852 /** | 6636 /** |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6920 */ | 6704 */ |
6921 Object perform(AnalysisTaskVisitor visitor) { | 6705 Object perform(AnalysisTaskVisitor visitor) { |
6922 try { | 6706 try { |
6923 _safelyPerform(); | 6707 _safelyPerform(); |
6924 } on AnalysisException catch (exception, stackTrace) { | 6708 } on AnalysisException catch (exception, stackTrace) { |
6925 _thrownException = new CaughtException(exception, stackTrace); | 6709 _thrownException = new CaughtException(exception, stackTrace); |
6926 AnalysisEngine.instance.logger.logInformation( | 6710 AnalysisEngine.instance.logger.logInformation( |
6927 "Task failed: $taskDescription", | 6711 "Task failed: $taskDescription", |
6928 new CaughtException(exception, stackTrace)); | 6712 new CaughtException(exception, stackTrace)); |
6929 } | 6713 } |
6930 return PerformanceStatistics.analysisTaskVisitor.makeCurrentWhile( | 6714 return PerformanceStatistics.analysisTaskVisitor |
6931 () => accept(visitor)); | 6715 .makeCurrentWhile(() => accept(visitor)); |
6932 } | 6716 } |
6933 | 6717 |
6934 @override | 6718 @override |
6935 String toString() => taskDescription; | 6719 String toString() => taskDescription; |
6936 | 6720 |
6937 /** | 6721 /** |
6938 * Perform this analysis task, ensuring that all exceptions are wrapped in an | 6722 * Perform this analysis task, ensuring that all exceptions are wrapped in an |
6939 * [AnalysisException]. | 6723 * [AnalysisException]. |
6940 * | 6724 * |
6941 * @throws AnalysisException if any exception occurs while performing the task | 6725 * @throws AnalysisException if any exception occurs while performing the task |
6942 */ | 6726 */ |
6943 void _safelyPerform() { | 6727 void _safelyPerform() { |
6944 try { | 6728 try { |
6945 String contextName = context.name; | 6729 String contextName = context.name; |
6946 if (contextName == null) { | 6730 if (contextName == null) { |
6947 contextName = 'unnamed'; | 6731 contextName = 'unnamed'; |
6948 } | 6732 } |
6949 AnalysisEngine.instance.instrumentationService.logAnalysisTask( | 6733 AnalysisEngine.instance.instrumentationService.logAnalysisTask( |
6950 contextName, | 6734 contextName, taskDescription); |
6951 taskDescription); | |
6952 internalPerform(); | 6735 internalPerform(); |
6953 } on AnalysisException catch (exception) { | 6736 } on AnalysisException catch (exception) { |
6954 rethrow; | 6737 rethrow; |
6955 } catch (exception, stackTrace) { | 6738 } catch (exception, stackTrace) { |
6956 throw new AnalysisException( | 6739 throw new AnalysisException( |
6957 exception.toString(), | 6740 exception.toString(), new CaughtException(exception, stackTrace)); |
6958 new CaughtException(exception, stackTrace)); | |
6959 } | 6741 } |
6960 } | 6742 } |
6961 } | 6743 } |
6962 | 6744 |
6963 /** | 6745 /** |
6964 * An `AnalysisTaskVisitor` visits tasks. While tasks are not structured in any | 6746 * An `AnalysisTaskVisitor` visits tasks. While tasks are not structured in any |
6965 * interesting way, this class provides the ability to dispatch to an | 6747 * interesting way, this class provides the ability to dispatch to an |
6966 * appropriate method. | 6748 * appropriate method. |
6967 */ | 6749 */ |
6968 abstract class AnalysisTaskVisitor<E> { | 6750 abstract class AnalysisTaskVisitor<E> { |
(...skipping 24 matching lines...) Expand all Loading... |
6993 /** | 6775 /** |
6994 * Visit the given [task], returning the result of the visit. This method will | 6776 * Visit the given [task], returning the result of the visit. This method will |
6995 * throw an AnalysisException if the visitor throws an exception. | 6777 * throw an AnalysisException if the visitor throws an exception. |
6996 */ | 6778 */ |
6997 E visitGetContentTask(GetContentTask task); | 6779 E visitGetContentTask(GetContentTask task); |
6998 | 6780 |
6999 /** | 6781 /** |
7000 * Visit the given [task], returning the result of the visit. This method will | 6782 * Visit the given [task], returning the result of the visit. This method will |
7001 * throw an AnalysisException if the visitor throws an exception. | 6783 * throw an AnalysisException if the visitor throws an exception. |
7002 */ | 6784 */ |
7003 E | 6785 E visitIncrementalAnalysisTask( |
7004 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk); | 6786 IncrementalAnalysisTask incrementalAnalysisTask); |
7005 | 6787 |
7006 /** | 6788 /** |
7007 * Visit the given [task], returning the result of the visit. This method will | 6789 * Visit the given [task], returning the result of the visit. This method will |
7008 * throw an AnalysisException if the visitor throws an exception. | 6790 * throw an AnalysisException if the visitor throws an exception. |
7009 */ | 6791 */ |
7010 E visitParseDartTask(ParseDartTask task); | 6792 E visitParseDartTask(ParseDartTask task); |
7011 | 6793 |
7012 /** | 6794 /** |
7013 * Visit the given [task], returning the result of the visit. This method will | 6795 * Visit the given [task], returning the result of the visit. This method will |
7014 * throw an AnalysisException if the visitor throws an exception. | 6796 * throw an AnalysisException if the visitor throws an exception. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7383 * The data is in the cache and up-to-date. | 7165 * The data is in the cache and up-to-date. |
7384 * | 7166 * |
7385 * Valid Transitions: | 7167 * Valid Transitions: |
7386 * * [FLUSHED] if the data is removed in order to manage memory usage | 7168 * * [FLUSHED] if the data is removed in order to manage memory usage |
7387 * * [INVALID] if a source was modified in such a way as to invalidate the | 7169 * * [INVALID] if a source was modified in such a way as to invalidate the |
7388 * previous data | 7170 * previous data |
7389 */ | 7171 */ |
7390 static const CacheState VALID = const CacheState('VALID', 4); | 7172 static const CacheState VALID = const CacheState('VALID', 4); |
7391 | 7173 |
7392 static const List<CacheState> values = const [ | 7174 static const List<CacheState> values = const [ |
7393 ERROR, | 7175 ERROR, |
7394 FLUSHED, | 7176 FLUSHED, |
7395 IN_PROCESS, | 7177 IN_PROCESS, |
7396 INVALID, | 7178 INVALID, |
7397 VALID]; | 7179 VALID |
| 7180 ]; |
7398 | 7181 |
7399 const CacheState(String name, int ordinal) : super(name, ordinal); | 7182 const CacheState(String name, int ordinal) : super(name, ordinal); |
7400 } | 7183 } |
7401 | 7184 |
7402 /** | 7185 /** |
7403 * An object that represents a change to the analysis results associated with a | 7186 * An object that represents a change to the analysis results associated with a |
7404 * given source. | 7187 * given source. |
7405 */ | 7188 */ |
7406 abstract class ChangeNotice implements AnalysisErrorInfo { | 7189 abstract class ChangeNotice implements AnalysisErrorInfo { |
7407 /** | 7190 /** |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7486 LineInfo get lineInfo => _lineInfo; | 7269 LineInfo get lineInfo => _lineInfo; |
7487 | 7270 |
7488 /** | 7271 /** |
7489 * Set the errors that changed as a result of the analysis to the given | 7272 * Set the errors that changed as a result of the analysis to the given |
7490 * [errors] and set the line information to the given [lineInfo]. | 7273 * [errors] and set the line information to the given [lineInfo]. |
7491 */ | 7274 */ |
7492 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { | 7275 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { |
7493 this._errors = errors; | 7276 this._errors = errors; |
7494 this._lineInfo = lineInfo; | 7277 this._lineInfo = lineInfo; |
7495 if (lineInfo == null) { | 7278 if (lineInfo == null) { |
7496 AnalysisEngine.instance.logger.logInformation( | 7279 AnalysisEngine.instance.logger.logInformation("No line info: $source", |
7497 "No line info: $source", | |
7498 new CaughtException(new AnalysisException(), null)); | 7280 new CaughtException(new AnalysisException(), null)); |
7499 } | 7281 } |
7500 } | 7282 } |
7501 | 7283 |
7502 @override | 7284 @override |
7503 String toString() => "Changes for ${source.fullName}"; | 7285 String toString() => "Changes for ${source.fullName}"; |
7504 } | 7286 } |
7505 | 7287 |
7506 /** | 7288 /** |
7507 * Instances of the class `ChangeSet` indicate which sources have been added, ch
anged, | 7289 * Instances of the class `ChangeSet` indicate which sources have been added, ch
anged, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7559 * @return a table mapping the sources whose content has been changed to the c
urrent content of | 7341 * @return a table mapping the sources whose content has been changed to the c
urrent content of |
7560 * those sources | 7342 * those sources |
7561 */ | 7343 */ |
7562 Map<Source, String> get changedContents => _changedContent; | 7344 Map<Source, String> get changedContents => _changedContent; |
7563 | 7345 |
7564 /** | 7346 /** |
7565 * Return `true` if this change set does not contain any changes. | 7347 * Return `true` if this change set does not contain any changes. |
7566 * | 7348 * |
7567 * @return `true` if this change set does not contain any changes | 7349 * @return `true` if this change set does not contain any changes |
7568 */ | 7350 */ |
7569 bool get isEmpty => | 7351 bool get isEmpty => addedSources.isEmpty && |
7570 addedSources.isEmpty && | 7352 changedSources.isEmpty && |
7571 changedSources.isEmpty && | 7353 _changedContent.isEmpty && |
7572 _changedContent.isEmpty && | 7354 changedRanges.isEmpty && |
7573 changedRanges.isEmpty && | 7355 removedSources.isEmpty && |
7574 removedSources.isEmpty && | 7356 removedContainers.isEmpty && |
7575 removedContainers.isEmpty && | 7357 deletedSources.isEmpty; |
7576 deletedSources.isEmpty; | |
7577 | 7358 |
7578 /** | 7359 /** |
7579 * Record that the specified source has been added and that its content is the
default contents of | 7360 * Record that the specified source has been added and that its content is the
default contents of |
7580 * the source. | 7361 * the source. |
7581 * | 7362 * |
7582 * @param source the source that was added | 7363 * @param source the source that was added |
7583 */ | 7364 */ |
7584 void addedSource(Source source) { | 7365 void addedSource(Source source) { |
7585 addedSources.add(source); | 7366 addedSources.add(source); |
7586 } | 7367 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7651 if (source != null) { | 7432 if (source != null) { |
7652 removedSources.add(source); | 7433 removedSources.add(source); |
7653 } | 7434 } |
7654 } | 7435 } |
7655 | 7436 |
7656 @override | 7437 @override |
7657 String toString() { | 7438 String toString() { |
7658 StringBuffer buffer = new StringBuffer(); | 7439 StringBuffer buffer = new StringBuffer(); |
7659 bool needsSeparator = | 7440 bool needsSeparator = |
7660 _appendSources(buffer, addedSources, false, "addedSources"); | 7441 _appendSources(buffer, addedSources, false, "addedSources"); |
7661 needsSeparator = | 7442 needsSeparator = _appendSources( |
7662 _appendSources(buffer, changedSources, needsSeparator, "changedSources")
; | 7443 buffer, changedSources, needsSeparator, "changedSources"); |
7663 needsSeparator = | 7444 needsSeparator = _appendSources2( |
7664 _appendSources2(buffer, _changedContent, needsSeparator, "changedContent
"); | 7445 buffer, _changedContent, needsSeparator, "changedContent"); |
7665 needsSeparator = | 7446 needsSeparator = |
7666 _appendSources2(buffer, changedRanges, needsSeparator, "changedRanges"); | 7447 _appendSources2(buffer, changedRanges, needsSeparator, "changedRanges"); |
7667 needsSeparator = | 7448 needsSeparator = _appendSources( |
7668 _appendSources(buffer, deletedSources, needsSeparator, "deletedSources")
; | 7449 buffer, deletedSources, needsSeparator, "deletedSources"); |
7669 needsSeparator = | 7450 needsSeparator = _appendSources( |
7670 _appendSources(buffer, removedSources, needsSeparator, "removedSources")
; | 7451 buffer, removedSources, needsSeparator, "removedSources"); |
7671 int count = removedContainers.length; | 7452 int count = removedContainers.length; |
7672 if (count > 0) { | 7453 if (count > 0) { |
7673 if (removedSources.isEmpty) { | 7454 if (removedSources.isEmpty) { |
7674 if (needsSeparator) { | 7455 if (needsSeparator) { |
7675 buffer.write("; "); | 7456 buffer.write("; "); |
7676 } | 7457 } |
7677 buffer.write("removed: from "); | 7458 buffer.write("removed: from "); |
7678 buffer.write(count); | 7459 buffer.write(count); |
7679 buffer.write(" containers"); | 7460 buffer.write(" containers"); |
7680 } else { | 7461 } else { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7768 final int newLength; | 7549 final int newLength; |
7769 | 7550 |
7770 /** | 7551 /** |
7771 * Initialize a newly created change object to represent a change to the conte
nt of a source. | 7552 * Initialize a newly created change object to represent a change to the conte
nt of a source. |
7772 * | 7553 * |
7773 * @param contents the new contents of the source | 7554 * @param contents the new contents of the source |
7774 * @param offset the offset into the current contents | 7555 * @param offset the offset into the current contents |
7775 * @param oldLength the number of characters in the original contents that wer
e replaced | 7556 * @param oldLength the number of characters in the original contents that wer
e replaced |
7776 * @param newLength the number of characters in the replacement text | 7557 * @param newLength the number of characters in the replacement text |
7777 */ | 7558 */ |
7778 ChangeSet_ContentChange(this.contents, this.offset, this.oldLength, | 7559 ChangeSet_ContentChange( |
7779 this.newLength); | 7560 this.contents, this.offset, this.oldLength, this.newLength); |
7780 } | 7561 } |
7781 | 7562 |
7782 /** | 7563 /** |
7783 * Instances of the class `LibraryPair` hold a library and a list of the (source
, entry) | 7564 * Instances of the class `LibraryPair` hold a library and a list of the (source
, entry) |
7784 * pairs for compilation units in the library. | 7565 * pairs for compilation units in the library. |
7785 */ | 7566 */ |
7786 class CycleBuilder_LibraryPair { | 7567 class CycleBuilder_LibraryPair { |
7787 /** | 7568 /** |
7788 * The library containing the compilation units. | 7569 * The library containing the compilation units. |
7789 */ | 7570 */ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7856 */ | 7637 */ |
7857 static final DataDescriptor<CompilationUnit> BUILT_UNIT = | 7638 static final DataDescriptor<CompilationUnit> BUILT_UNIT = |
7858 new DataDescriptor<CompilationUnit>("DartEntry.BUILT_UNIT"); | 7639 new DataDescriptor<CompilationUnit>("DartEntry.BUILT_UNIT"); |
7859 | 7640 |
7860 /** | 7641 /** |
7861 * The data descriptor representing the list of libraries that contain this | 7642 * The data descriptor representing the list of libraries that contain this |
7862 * compilation unit. | 7643 * compilation unit. |
7863 */ | 7644 */ |
7864 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = | 7645 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = |
7865 new DataDescriptor<List<Source>>( | 7646 new DataDescriptor<List<Source>>( |
7866 "DartEntry.CONTAINING_LIBRARIES", | 7647 "DartEntry.CONTAINING_LIBRARIES", Source.EMPTY_ARRAY); |
7867 Source.EMPTY_ARRAY); | |
7868 | 7648 |
7869 /** | 7649 /** |
7870 * The data descriptor representing the library element for the library. This | 7650 * The data descriptor representing the library element for the library. This |
7871 * data is only available for Dart files that are the defining compilation | 7651 * data is only available for Dart files that are the defining compilation |
7872 * unit of a library. | 7652 * unit of a library. |
7873 */ | 7653 */ |
7874 static final DataDescriptor<LibraryElement> ELEMENT = | 7654 static final DataDescriptor<LibraryElement> ELEMENT = |
7875 new DataDescriptor<LibraryElement>("DartEntry.ELEMENT"); | 7655 new DataDescriptor<LibraryElement>("DartEntry.ELEMENT"); |
7876 | 7656 |
7877 /** | 7657 /** |
7878 * The data descriptor representing the list of exported libraries. This data | 7658 * The data descriptor representing the list of exported libraries. This data |
7879 * is only available for Dart files that are the defining compilation unit of | 7659 * is only available for Dart files that are the defining compilation unit of |
7880 * a library. | 7660 * a library. |
7881 */ | 7661 */ |
7882 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES = | 7662 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES = |
7883 new DataDescriptor<List<Source>>( | 7663 new DataDescriptor<List<Source>>( |
7884 "DartEntry.EXPORTED_LIBRARIES", | 7664 "DartEntry.EXPORTED_LIBRARIES", Source.EMPTY_ARRAY); |
7885 Source.EMPTY_ARRAY); | |
7886 | 7665 |
7887 /** | 7666 /** |
7888 * The data descriptor representing the hints resulting from auditing the | 7667 * The data descriptor representing the hints resulting from auditing the |
7889 * source. | 7668 * source. |
7890 */ | 7669 */ |
7891 static final DataDescriptor<List<AnalysisError>> HINTS = | 7670 static final DataDescriptor<List<AnalysisError>> HINTS = |
7892 new DataDescriptor<List<AnalysisError>>( | 7671 new DataDescriptor<List<AnalysisError>>( |
7893 "DartEntry.HINTS", | 7672 "DartEntry.HINTS", AnalysisError.NO_ERRORS); |
7894 AnalysisError.NO_ERRORS); | |
7895 | 7673 |
7896 /** | 7674 /** |
7897 * The data descriptor representing the list of imported libraries. This data | 7675 * The data descriptor representing the list of imported libraries. This data |
7898 * is only available for Dart files that are the defining compilation unit of | 7676 * is only available for Dart files that are the defining compilation unit of |
7899 * a library. | 7677 * a library. |
7900 */ | 7678 */ |
7901 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES = | 7679 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES = |
7902 new DataDescriptor<List<Source>>( | 7680 new DataDescriptor<List<Source>>( |
7903 "DartEntry.IMPORTED_LIBRARIES", | 7681 "DartEntry.IMPORTED_LIBRARIES", Source.EMPTY_ARRAY); |
7904 Source.EMPTY_ARRAY); | |
7905 | 7682 |
7906 /** | 7683 /** |
7907 * The data descriptor representing the list of included parts. This data is | 7684 * The data descriptor representing the list of included parts. This data is |
7908 * only available for Dart files that are the defining compilation unit of a | 7685 * only available for Dart files that are the defining compilation unit of a |
7909 * library. | 7686 * library. |
7910 */ | 7687 */ |
7911 static final DataDescriptor<List<Source>> INCLUDED_PARTS = | 7688 static final DataDescriptor<List<Source>> INCLUDED_PARTS = |
7912 new DataDescriptor<List<Source>>( | 7689 new DataDescriptor<List<Source>>( |
7913 "DartEntry.INCLUDED_PARTS", | 7690 "DartEntry.INCLUDED_PARTS", Source.EMPTY_ARRAY); |
7914 Source.EMPTY_ARRAY); | |
7915 | 7691 |
7916 /** | 7692 /** |
7917 * The data descriptor representing the client flag. This data is only | 7693 * The data descriptor representing the client flag. This data is only |
7918 * available for Dart files that are the defining compilation unit of a | 7694 * available for Dart files that are the defining compilation unit of a |
7919 * library. | 7695 * library. |
7920 */ | 7696 */ |
7921 static final DataDescriptor<bool> IS_CLIENT = | 7697 static final DataDescriptor<bool> IS_CLIENT = |
7922 new DataDescriptor<bool>("DartEntry.IS_CLIENT", false); | 7698 new DataDescriptor<bool>("DartEntry.IS_CLIENT", false); |
7923 | 7699 |
7924 /** | 7700 /** |
7925 * The data descriptor representing the launchable flag. This data is only | 7701 * The data descriptor representing the launchable flag. This data is only |
7926 * available for Dart files that are the defining compilation unit of a | 7702 * available for Dart files that are the defining compilation unit of a |
7927 * library. | 7703 * library. |
7928 */ | 7704 */ |
7929 static final DataDescriptor<bool> IS_LAUNCHABLE = | 7705 static final DataDescriptor<bool> IS_LAUNCHABLE = |
7930 new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE", false); | 7706 new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE", false); |
7931 | 7707 |
7932 /** | 7708 /** |
7933 * The data descriptor representing lint warnings resulting from auditing the | 7709 * The data descriptor representing lint warnings resulting from auditing the |
7934 * source. | 7710 * source. |
7935 */ | 7711 */ |
7936 static final DataDescriptor<List<AnalysisError>> LINTS = | 7712 static final DataDescriptor<List<AnalysisError>> LINTS = |
7937 new DataDescriptor<List<AnalysisError>>( | 7713 new DataDescriptor<List<AnalysisError>>( |
7938 "DartEntry.LINTS", | 7714 "DartEntry.LINTS", AnalysisError.NO_ERRORS); |
7939 AnalysisError.NO_ERRORS); | |
7940 | 7715 |
7941 /** | 7716 /** |
7942 * The data descriptor representing the errors resulting from parsing the | 7717 * The data descriptor representing the errors resulting from parsing the |
7943 * source. | 7718 * source. |
7944 */ | 7719 */ |
7945 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = | 7720 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = |
7946 new DataDescriptor<List<AnalysisError>>( | 7721 new DataDescriptor<List<AnalysisError>>( |
7947 "DartEntry.PARSE_ERRORS", | 7722 "DartEntry.PARSE_ERRORS", AnalysisError.NO_ERRORS); |
7948 AnalysisError.NO_ERRORS); | |
7949 | 7723 |
7950 /** | 7724 /** |
7951 * The data descriptor representing the parsed AST structure. | 7725 * The data descriptor representing the parsed AST structure. |
7952 */ | 7726 */ |
7953 static final DataDescriptor<CompilationUnit> PARSED_UNIT = | 7727 static final DataDescriptor<CompilationUnit> PARSED_UNIT = |
7954 new DataDescriptor<CompilationUnit>("DartEntry.PARSED_UNIT"); | 7728 new DataDescriptor<CompilationUnit>("DartEntry.PARSED_UNIT"); |
7955 | 7729 |
7956 /** | 7730 /** |
7957 * The data descriptor representing the public namespace of the library. This | 7731 * The data descriptor representing the public namespace of the library. This |
7958 * data is only available for Dart files that are the defining compilation | 7732 * data is only available for Dart files that are the defining compilation |
7959 * unit of a library. | 7733 * unit of a library. |
7960 */ | 7734 */ |
7961 static final DataDescriptor<Namespace> PUBLIC_NAMESPACE = | 7735 static final DataDescriptor<Namespace> PUBLIC_NAMESPACE = |
7962 new DataDescriptor<Namespace>("DartEntry.PUBLIC_NAMESPACE"); | 7736 new DataDescriptor<Namespace>("DartEntry.PUBLIC_NAMESPACE"); |
7963 | 7737 |
7964 /** | 7738 /** |
7965 * The data descriptor representing the errors resulting from resolving the | 7739 * The data descriptor representing the errors resulting from resolving the |
7966 * source. | 7740 * source. |
7967 */ | 7741 */ |
7968 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = | 7742 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = |
7969 new DataDescriptor<List<AnalysisError>>( | 7743 new DataDescriptor<List<AnalysisError>>( |
7970 "DartEntry.RESOLUTION_ERRORS", | 7744 "DartEntry.RESOLUTION_ERRORS", AnalysisError.NO_ERRORS); |
7971 AnalysisError.NO_ERRORS); | |
7972 | 7745 |
7973 /** | 7746 /** |
7974 * The data descriptor representing the resolved AST structure. | 7747 * The data descriptor representing the resolved AST structure. |
7975 */ | 7748 */ |
7976 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = | 7749 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = |
7977 new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT"); | 7750 new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT"); |
7978 | 7751 |
7979 /** | 7752 /** |
7980 * The data descriptor representing the errors resulting from scanning the | 7753 * The data descriptor representing the errors resulting from scanning the |
7981 * source. | 7754 * source. |
7982 */ | 7755 */ |
7983 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS = | 7756 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS = |
7984 new DataDescriptor<List<AnalysisError>>( | 7757 new DataDescriptor<List<AnalysisError>>( |
7985 "DartEntry.SCAN_ERRORS", | 7758 "DartEntry.SCAN_ERRORS", AnalysisError.NO_ERRORS); |
7986 AnalysisError.NO_ERRORS); | |
7987 | 7759 |
7988 /** | 7760 /** |
7989 * The data descriptor representing the source kind. | 7761 * The data descriptor representing the source kind. |
7990 */ | 7762 */ |
7991 static final DataDescriptor<SourceKind> SOURCE_KIND = | 7763 static final DataDescriptor<SourceKind> SOURCE_KIND = |
7992 new DataDescriptor<SourceKind>("DartEntry.SOURCE_KIND", SourceKind.UNKNOWN
); | 7764 new DataDescriptor<SourceKind>( |
| 7765 "DartEntry.SOURCE_KIND", SourceKind.UNKNOWN); |
7993 | 7766 |
7994 /** | 7767 /** |
7995 * The data descriptor representing the token stream. | 7768 * The data descriptor representing the token stream. |
7996 */ | 7769 */ |
7997 static final DataDescriptor<Token> TOKEN_STREAM = | 7770 static final DataDescriptor<Token> TOKEN_STREAM = |
7998 new DataDescriptor<Token>("DartEntry.TOKEN_STREAM"); | 7771 new DataDescriptor<Token>("DartEntry.TOKEN_STREAM"); |
7999 | 7772 |
8000 /** | 7773 /** |
8001 * The data descriptor representing the errors resulting from verifying the | 7774 * The data descriptor representing the errors resulting from verifying the |
8002 * source. | 7775 * source. |
8003 */ | 7776 */ |
8004 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS = | 7777 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS = |
8005 new DataDescriptor<List<AnalysisError>>( | 7778 new DataDescriptor<List<AnalysisError>>( |
8006 "DartEntry.VERIFICATION_ERRORS", | 7779 "DartEntry.VERIFICATION_ERRORS", AnalysisError.NO_ERRORS); |
8007 AnalysisError.NO_ERRORS); | |
8008 | 7780 |
8009 /** | 7781 /** |
8010 * The list of libraries that contain this compilation unit. The list will be | 7782 * The list of libraries that contain this compilation unit. The list will be |
8011 * empty if there are no known libraries that contain this compilation unit. | 7783 * empty if there are no known libraries that contain this compilation unit. |
8012 */ | 7784 */ |
8013 List<Source> _containingLibraries = new List<Source>(); | 7785 List<Source> _containingLibraries = new List<Source>(); |
8014 | 7786 |
8015 /** | 7787 /** |
8016 * The information known as a result of resolving this compilation unit as | 7788 * The information known as a result of resolving this compilation unit as |
8017 * part of the library that contains this unit. This field will never be | 7789 * part of the library that contains this unit. This field will never be |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8090 * @param librarySource the source of the single library that the list should
contain | 7862 * @param librarySource the source of the single library that the list should
contain |
8091 */ | 7863 */ |
8092 void set containingLibrary(Source librarySource) { | 7864 void set containingLibrary(Source librarySource) { |
8093 _containingLibraries.clear(); | 7865 _containingLibraries.clear(); |
8094 _containingLibraries.add(librarySource); | 7866 _containingLibraries.add(librarySource); |
8095 } | 7867 } |
8096 | 7868 |
8097 @override | 7869 @override |
8098 List<DataDescriptor> get descriptors { | 7870 List<DataDescriptor> get descriptors { |
8099 List<DataDescriptor> result = super.descriptors; | 7871 List<DataDescriptor> result = super.descriptors; |
8100 result.addAll( | 7872 result.addAll(<DataDescriptor>[ |
8101 <DataDescriptor>[ | 7873 DartEntry.SOURCE_KIND, |
8102 DartEntry.SOURCE_KIND, | 7874 DartEntry.CONTAINING_LIBRARIES, |
8103 DartEntry.CONTAINING_LIBRARIES, | 7875 DartEntry.PARSE_ERRORS, |
8104 DartEntry.PARSE_ERRORS, | 7876 DartEntry.PARSED_UNIT, |
8105 DartEntry.PARSED_UNIT, | 7877 DartEntry.SCAN_ERRORS, |
8106 DartEntry.SCAN_ERRORS, | 7878 DartEntry.SOURCE_KIND, |
8107 DartEntry.SOURCE_KIND, | 7879 DartEntry.TOKEN_STREAM |
8108 DartEntry.TOKEN_STREAM]); | 7880 ]); |
8109 SourceKind kind = getValue(DartEntry.SOURCE_KIND); | 7881 SourceKind kind = getValue(DartEntry.SOURCE_KIND); |
8110 if (kind == SourceKind.LIBRARY) { | 7882 if (kind == SourceKind.LIBRARY) { |
8111 result.addAll( | 7883 result.addAll(<DataDescriptor>[ |
8112 <DataDescriptor>[ | 7884 DartEntry.ELEMENT, |
8113 DartEntry.ELEMENT, | 7885 DartEntry.EXPORTED_LIBRARIES, |
8114 DartEntry.EXPORTED_LIBRARIES, | 7886 DartEntry.IMPORTED_LIBRARIES, |
8115 DartEntry.IMPORTED_LIBRARIES, | 7887 DartEntry.INCLUDED_PARTS, |
8116 DartEntry.INCLUDED_PARTS, | 7888 DartEntry.IS_CLIENT, |
8117 DartEntry.IS_CLIENT, | 7889 DartEntry.IS_LAUNCHABLE, |
8118 DartEntry.IS_LAUNCHABLE, | 7890 DartEntry.PUBLIC_NAMESPACE |
8119 DartEntry.PUBLIC_NAMESPACE]); | 7891 ]); |
8120 } | 7892 } |
8121 return result; | 7893 return result; |
8122 } | 7894 } |
8123 | 7895 |
8124 /** | 7896 /** |
8125 * Return `true` if this entry has an AST structure that can be resolved, even | 7897 * Return `true` if this entry has an AST structure that can be resolved, even |
8126 * if it needs to be copied. Returning `true` implies that the method | 7898 * if it needs to be copied. Returning `true` implies that the method |
8127 * [resolvableCompilationUnit] will return a non-`null` result. | 7899 * [resolvableCompilationUnit] will return a non-`null` result. |
8128 */ | 7900 */ |
8129 bool get hasResolvableCompilationUnit { | 7901 bool get hasResolvableCompilationUnit { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8175 } | 7947 } |
8176 return result; | 7948 return result; |
8177 } | 7949 } |
8178 | 7950 |
8179 /** | 7951 /** |
8180 * Get a list of all the library-dependent descriptors for which values may | 7952 * Get a list of all the library-dependent descriptors for which values may |
8181 * be stored in this SourceEntry. | 7953 * be stored in this SourceEntry. |
8182 */ | 7954 */ |
8183 List<DataDescriptor> get libraryDescriptors { | 7955 List<DataDescriptor> get libraryDescriptors { |
8184 return <DataDescriptor>[ | 7956 return <DataDescriptor>[ |
8185 DartEntry.BUILT_ELEMENT, | 7957 DartEntry.BUILT_ELEMENT, |
8186 DartEntry.BUILT_UNIT, | 7958 DartEntry.BUILT_UNIT, |
8187 DartEntry.RESOLUTION_ERRORS, | 7959 DartEntry.RESOLUTION_ERRORS, |
8188 DartEntry.RESOLVED_UNIT, | 7960 DartEntry.RESOLVED_UNIT, |
8189 DartEntry.VERIFICATION_ERRORS, | 7961 DartEntry.VERIFICATION_ERRORS, |
8190 DartEntry.HINTS, | 7962 DartEntry.HINTS, |
8191 DartEntry.LINTS]; | 7963 DartEntry.LINTS |
| 7964 ]; |
8192 } | 7965 } |
8193 | 7966 |
8194 /** | 7967 /** |
8195 * A compilation unit that has not been accessed by any other client and can | 7968 * A compilation unit that has not been accessed by any other client and can |
8196 * therefore safely be modified by the reconciler, or `null` if the source has | 7969 * therefore safely be modified by the reconciler, or `null` if the source has |
8197 * not been parsed. | 7970 * not been parsed. |
8198 */ | 7971 */ |
8199 CompilationUnit get resolvableCompilationUnit { | 7972 CompilationUnit get resolvableCompilationUnit { |
8200 if (getState(PARSED_UNIT) == CacheState.VALID) { | 7973 if (getState(PARSED_UNIT) == CacheState.VALID) { |
8201 CompilationUnit unit = getValue(PARSED_UNIT); | 7974 CompilationUnit unit = getValue(PARSED_UNIT); |
(...skipping 29 matching lines...) Expand all Loading... |
8231 void flushAstStructures() { | 8004 void flushAstStructures() { |
8232 _flush(TOKEN_STREAM); | 8005 _flush(TOKEN_STREAM); |
8233 _flush(PARSED_UNIT); | 8006 _flush(PARSED_UNIT); |
8234 _resolutionState.flushAstStructures(); | 8007 _resolutionState.flushAstStructures(); |
8235 } | 8008 } |
8236 | 8009 |
8237 /** | 8010 /** |
8238 * Return the state of the data represented by the given [descriptor] in the | 8011 * Return the state of the data represented by the given [descriptor] in the |
8239 * context of the given [librarySource]. | 8012 * context of the given [librarySource]. |
8240 */ | 8013 */ |
8241 CacheState getStateInLibrary(DataDescriptor descriptor, | 8014 CacheState getStateInLibrary( |
8242 Source librarySource) { | 8015 DataDescriptor descriptor, Source librarySource) { |
8243 if (!_isValidLibraryDescriptor(descriptor)) { | 8016 if (!_isValidLibraryDescriptor(descriptor)) { |
8244 throw new ArgumentError("Invalid descriptor: $descriptor"); | 8017 throw new ArgumentError("Invalid descriptor: $descriptor"); |
8245 } | 8018 } |
8246 ResolutionState state = _resolutionState; | 8019 ResolutionState state = _resolutionState; |
8247 while (state != null) { | 8020 while (state != null) { |
8248 if (librarySource == state._librarySource) { | 8021 if (librarySource == state._librarySource) { |
8249 return state.getState(descriptor); | 8022 return state.getState(descriptor); |
8250 } | 8023 } |
8251 state = state._nextState; | 8024 state = state._nextState; |
8252 } | 8025 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8339 _containingLibraries.clear(); | 8112 _containingLibraries.clear(); |
8340 _discardCachedResolutionInformation(true); | 8113 _discardCachedResolutionInformation(true); |
8341 } | 8114 } |
8342 | 8115 |
8343 /** | 8116 /** |
8344 * Record that an [exception] occurred while attempting to build the element | 8117 * Record that an [exception] occurred while attempting to build the element |
8345 * model for the source represented by this entry in the context of the given | 8118 * model for the source represented by this entry in the context of the given |
8346 * [library]. This will set the state of all resolution-based information as | 8119 * [library]. This will set the state of all resolution-based information as |
8347 * being in error, but will not change the state of any parse results. | 8120 * being in error, but will not change the state of any parse results. |
8348 */ | 8121 */ |
8349 void recordBuildElementErrorInLibrary(Source librarySource, | 8122 void recordBuildElementErrorInLibrary( |
8350 CaughtException exception) { | 8123 Source librarySource, CaughtException exception) { |
8351 setStateInLibrary(BUILT_ELEMENT, librarySource, CacheState.ERROR); | 8124 setStateInLibrary(BUILT_ELEMENT, librarySource, CacheState.ERROR); |
8352 setStateInLibrary(BUILT_UNIT, librarySource, CacheState.ERROR); | 8125 setStateInLibrary(BUILT_UNIT, librarySource, CacheState.ERROR); |
8353 recordResolutionErrorInLibrary(librarySource, exception); | 8126 recordResolutionErrorInLibrary(librarySource, exception); |
8354 } | 8127 } |
8355 | 8128 |
8356 @override | 8129 @override |
8357 void recordContentError(CaughtException exception) { | 8130 void recordContentError(CaughtException exception) { |
8358 super.recordContentError(exception); | 8131 super.recordContentError(exception); |
8359 recordScanError(exception); | 8132 recordScanError(exception); |
8360 } | 8133 } |
8361 | 8134 |
8362 /** | 8135 /** |
8363 * Record that an error occurred while attempting to generate hints for the | 8136 * Record that an error occurred while attempting to generate hints for the |
8364 * source represented by this entry. This will set the state of all | 8137 * source represented by this entry. This will set the state of all |
8365 * verification information as being in error. | 8138 * verification information as being in error. |
8366 * | 8139 * |
8367 * @param librarySource the source of the library in which hints were being ge
nerated | 8140 * @param librarySource the source of the library in which hints were being ge
nerated |
8368 * @param exception the exception that shows where the error occurred | 8141 * @param exception the exception that shows where the error occurred |
8369 */ | 8142 */ |
8370 void recordHintErrorInLibrary(Source librarySource, | 8143 void recordHintErrorInLibrary( |
8371 CaughtException exception) { | 8144 Source librarySource, CaughtException exception) { |
8372 this.exception = exception; | 8145 this.exception = exception; |
8373 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8146 ResolutionState state = _getOrCreateResolutionState(librarySource); |
8374 state.recordHintError(); | 8147 state.recordHintError(); |
8375 } | 8148 } |
8376 | 8149 |
8377 /** | 8150 /** |
8378 * Record that an error occurred while attempting to generate lints for the | 8151 * Record that an error occurred while attempting to generate lints for the |
8379 * source represented by this entry. This will set the state of all | 8152 * source represented by this entry. This will set the state of all |
8380 * verification information as being in error. | 8153 * verification information as being in error. |
8381 * | 8154 * |
8382 * @param librarySource the source of the library in which lints were being ge
nerated | 8155 * @param librarySource the source of the library in which lints were being ge
nerated |
8383 * @param exception the exception that shows where the error occurred | 8156 * @param exception the exception that shows where the error occurred |
8384 */ | 8157 */ |
8385 void recordLintErrorInLibrary(Source librarySource, | 8158 void recordLintErrorInLibrary( |
8386 CaughtException exception) { | 8159 Source librarySource, CaughtException exception) { |
8387 this.exception = exception; | 8160 this.exception = exception; |
8388 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8161 ResolutionState state = _getOrCreateResolutionState(librarySource); |
8389 state.recordLintError(); | 8162 state.recordLintError(); |
8390 } | 8163 } |
8391 | 8164 |
8392 /** | 8165 /** |
8393 * Record that an [exception] occurred while attempting to scan or parse the | 8166 * Record that an [exception] occurred while attempting to scan or parse the |
8394 * entry represented by this entry. This will set the state of all information
, | 8167 * entry represented by this entry. This will set the state of all information
, |
8395 * including any resolution-based information, as being in error. | 8168 * including any resolution-based information, as being in error. |
8396 */ | 8169 */ |
(...skipping 25 matching lines...) Expand all Loading... |
8422 } | 8195 } |
8423 | 8196 |
8424 /** | 8197 /** |
8425 * Record that an error occurred while attempting to resolve the source repres
ented by this entry. | 8198 * Record that an error occurred while attempting to resolve the source repres
ented by this entry. |
8426 * This will set the state of all resolution-based information as being in err
or, but will not | 8199 * This will set the state of all resolution-based information as being in err
or, but will not |
8427 * change the state of any parse results. | 8200 * change the state of any parse results. |
8428 * | 8201 * |
8429 * @param librarySource the source of the library in which resolution was bein
g performed | 8202 * @param librarySource the source of the library in which resolution was bein
g performed |
8430 * @param exception the exception that shows where the error occurred | 8203 * @param exception the exception that shows where the error occurred |
8431 */ | 8204 */ |
8432 void recordResolutionErrorInLibrary(Source librarySource, | 8205 void recordResolutionErrorInLibrary( |
8433 CaughtException exception) { | 8206 Source librarySource, CaughtException exception) { |
8434 this.exception = exception; | 8207 this.exception = exception; |
8435 setState(ELEMENT, CacheState.ERROR); | 8208 setState(ELEMENT, CacheState.ERROR); |
8436 setState(IS_CLIENT, CacheState.ERROR); | 8209 setState(IS_CLIENT, CacheState.ERROR); |
8437 setState(IS_LAUNCHABLE, CacheState.ERROR); | 8210 setState(IS_LAUNCHABLE, CacheState.ERROR); |
8438 setState(PUBLIC_NAMESPACE, CacheState.ERROR); | 8211 setState(PUBLIC_NAMESPACE, CacheState.ERROR); |
8439 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8212 ResolutionState state = _getOrCreateResolutionState(librarySource); |
8440 state.recordResolutionError(); | 8213 state.recordResolutionError(); |
8441 } | 8214 } |
8442 | 8215 |
8443 /** | 8216 /** |
(...skipping 10 matching lines...) Expand all Loading... |
8454 } | 8227 } |
8455 | 8228 |
8456 /** | 8229 /** |
8457 * Record that an [exception] occurred while attempting to generate errors and | 8230 * Record that an [exception] occurred while attempting to generate errors and |
8458 * warnings for the source represented by this entry. This will set the state | 8231 * warnings for the source represented by this entry. This will set the state |
8459 * of all verification information as being in error. | 8232 * of all verification information as being in error. |
8460 * | 8233 * |
8461 * @param librarySource the source of the library in which verification was be
ing performed | 8234 * @param librarySource the source of the library in which verification was be
ing performed |
8462 * @param exception the exception that shows where the error occurred | 8235 * @param exception the exception that shows where the error occurred |
8463 */ | 8236 */ |
8464 void recordVerificationErrorInLibrary(Source librarySource, | 8237 void recordVerificationErrorInLibrary( |
8465 CaughtException exception) { | 8238 Source librarySource, CaughtException exception) { |
8466 this.exception = exception; | 8239 this.exception = exception; |
8467 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8240 ResolutionState state = _getOrCreateResolutionState(librarySource); |
8468 state.recordVerificationError(); | 8241 state.recordVerificationError(); |
8469 } | 8242 } |
8470 | 8243 |
8471 /** | 8244 /** |
8472 * Remove the given [library] from the list of libraries that contain this | 8245 * Remove the given [library] from the list of libraries that contain this |
8473 * part. This method should only be invoked on entries that represent a part. | 8246 * part. This method should only be invoked on entries that represent a part. |
8474 * | 8247 * |
8475 * @param librarySource the source of the library to be removed | 8248 * @param librarySource the source of the library to be removed |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8508 | 8281 |
8509 /** | 8282 /** |
8510 * Set the state of the data represented by the given descriptor in the contex
t of the given | 8283 * Set the state of the data represented by the given descriptor in the contex
t of the given |
8511 * library to the given state. | 8284 * library to the given state. |
8512 * | 8285 * |
8513 * @param descriptor the descriptor representing the data whose state is to be
set | 8286 * @param descriptor the descriptor representing the data whose state is to be
set |
8514 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 8287 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
8515 * context for the data | 8288 * context for the data |
8516 * @param cacheState the new state of the data represented by the given descri
ptor | 8289 * @param cacheState the new state of the data represented by the given descri
ptor |
8517 */ | 8290 */ |
8518 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, | 8291 void setStateInLibrary( |
8519 CacheState cacheState) { | 8292 DataDescriptor descriptor, Source librarySource, CacheState cacheState) { |
8520 if (!_isValidLibraryDescriptor(descriptor)) { | 8293 if (!_isValidLibraryDescriptor(descriptor)) { |
8521 throw new ArgumentError("Invalid descriptor: $descriptor"); | 8294 throw new ArgumentError("Invalid descriptor: $descriptor"); |
8522 } | 8295 } |
8523 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8296 ResolutionState state = _getOrCreateResolutionState(librarySource); |
8524 state.setState(descriptor, cacheState); | 8297 state.setState(descriptor, cacheState); |
8525 } | 8298 } |
8526 | 8299 |
8527 /** | 8300 /** |
8528 * Set the value of the data represented by the given descriptor in the contex
t of the given | 8301 * Set the value of the data represented by the given descriptor in the contex
t of the given |
8529 * library to the given value, and set the state of that data to [CacheState.V
ALID]. | 8302 * library to the given value, and set the state of that data to [CacheState.V
ALID]. |
8530 * | 8303 * |
8531 * @param descriptor the descriptor representing which data is to have its val
ue set | 8304 * @param descriptor the descriptor representing which data is to have its val
ue set |
8532 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 8305 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
8533 * context for the data | 8306 * context for the data |
8534 * @param value the new value of the data represented by the given descriptor
and library | 8307 * @param value the new value of the data represented by the given descriptor
and library |
8535 */ | 8308 */ |
8536 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, | 8309 void setValueInLibrary( |
8537 Object value) { | 8310 DataDescriptor descriptor, Source librarySource, Object value) { |
8538 if (!_isValidLibraryDescriptor(descriptor)) { | 8311 if (!_isValidLibraryDescriptor(descriptor)) { |
8539 throw new ArgumentError("Invalid descriptor: $descriptor"); | 8312 throw new ArgumentError("Invalid descriptor: $descriptor"); |
8540 } | 8313 } |
8541 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8314 ResolutionState state = _getOrCreateResolutionState(librarySource); |
8542 state.setValue(descriptor, value); | 8315 state.setValue(descriptor, value); |
8543 } | 8316 } |
8544 | 8317 |
8545 /** | 8318 /** |
8546 * Invalidate all of the resolution information associated with the compilatio
n unit. | 8319 * Invalidate all of the resolution information associated with the compilatio
n unit. |
8547 * | 8320 * |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8621 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { | 8394 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { |
8622 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); | 8395 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); |
8623 if (oldEntry is! DartEntry) { | 8396 if (oldEntry is! DartEntry) { |
8624 if (needsSeparator) { | 8397 if (needsSeparator) { |
8625 buffer.write("; "); | 8398 buffer.write("; "); |
8626 } | 8399 } |
8627 buffer.write("entry type changed; was "); | 8400 buffer.write("entry type changed; was "); |
8628 buffer.write(oldEntry.runtimeType.toString()); | 8401 buffer.write(oldEntry.runtimeType.toString()); |
8629 return true; | 8402 return true; |
8630 } | 8403 } |
| 8404 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "tokenStream", |
| 8405 DartEntry.TOKEN_STREAM, oldEntry); |
8631 needsSeparator = _writeStateDiffOn( | 8406 needsSeparator = _writeStateDiffOn( |
8632 buffer, | 8407 buffer, needsSeparator, "scanErrors", DartEntry.SCAN_ERRORS, oldEntry); |
8633 needsSeparator, | |
8634 "tokenStream", | |
8635 DartEntry.TOKEN_STREAM, | |
8636 oldEntry); | |
8637 needsSeparator = _writeStateDiffOn( | 8408 needsSeparator = _writeStateDiffOn( |
8638 buffer, | 8409 buffer, needsSeparator, "sourceKind", DartEntry.SOURCE_KIND, oldEntry); |
8639 needsSeparator, | |
8640 "scanErrors", | |
8641 DartEntry.SCAN_ERRORS, | |
8642 oldEntry); | |
8643 needsSeparator = _writeStateDiffOn( | 8410 needsSeparator = _writeStateDiffOn( |
8644 buffer, | 8411 buffer, needsSeparator, "parsedUnit", DartEntry.PARSED_UNIT, oldEntry); |
8645 needsSeparator, | 8412 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "parseErrors", |
8646 "sourceKind", | 8413 DartEntry.PARSE_ERRORS, oldEntry); |
8647 DartEntry.SOURCE_KIND, | 8414 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
8648 oldEntry); | 8415 "importedLibraries", DartEntry.IMPORTED_LIBRARIES, oldEntry); |
| 8416 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
| 8417 "exportedLibraries", DartEntry.EXPORTED_LIBRARIES, oldEntry); |
| 8418 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "includedParts", |
| 8419 DartEntry.INCLUDED_PARTS, oldEntry); |
8649 needsSeparator = _writeStateDiffOn( | 8420 needsSeparator = _writeStateDiffOn( |
8650 buffer, | 8421 buffer, needsSeparator, "element", DartEntry.ELEMENT, oldEntry); |
8651 needsSeparator, | 8422 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
8652 "parsedUnit", | 8423 "publicNamespace", DartEntry.PUBLIC_NAMESPACE, oldEntry); |
8653 DartEntry.PARSED_UNIT, | |
8654 oldEntry); | |
8655 needsSeparator = _writeStateDiffOn( | 8424 needsSeparator = _writeStateDiffOn( |
8656 buffer, | 8425 buffer, needsSeparator, "clientServer", DartEntry.IS_CLIENT, oldEntry); |
8657 needsSeparator, | 8426 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "launchable", |
8658 "parseErrors", | 8427 DartEntry.IS_LAUNCHABLE, oldEntry); |
8659 DartEntry.PARSE_ERRORS, | |
8660 oldEntry); | |
8661 needsSeparator = _writeStateDiffOn( | |
8662 buffer, | |
8663 needsSeparator, | |
8664 "importedLibraries", | |
8665 DartEntry.IMPORTED_LIBRARIES, | |
8666 oldEntry); | |
8667 needsSeparator = _writeStateDiffOn( | |
8668 buffer, | |
8669 needsSeparator, | |
8670 "exportedLibraries", | |
8671 DartEntry.EXPORTED_LIBRARIES, | |
8672 oldEntry); | |
8673 needsSeparator = _writeStateDiffOn( | |
8674 buffer, | |
8675 needsSeparator, | |
8676 "includedParts", | |
8677 DartEntry.INCLUDED_PARTS, | |
8678 oldEntry); | |
8679 needsSeparator = _writeStateDiffOn( | |
8680 buffer, | |
8681 needsSeparator, | |
8682 "element", | |
8683 DartEntry.ELEMENT, | |
8684 oldEntry); | |
8685 needsSeparator = _writeStateDiffOn( | |
8686 buffer, | |
8687 needsSeparator, | |
8688 "publicNamespace", | |
8689 DartEntry.PUBLIC_NAMESPACE, | |
8690 oldEntry); | |
8691 needsSeparator = _writeStateDiffOn( | |
8692 buffer, | |
8693 needsSeparator, | |
8694 "clientServer", | |
8695 DartEntry.IS_CLIENT, | |
8696 oldEntry); | |
8697 needsSeparator = _writeStateDiffOn( | |
8698 buffer, | |
8699 needsSeparator, | |
8700 "launchable", | |
8701 DartEntry.IS_LAUNCHABLE, | |
8702 oldEntry); | |
8703 // TODO(brianwilkerson) Add better support for containingLibraries. | 8428 // TODO(brianwilkerson) Add better support for containingLibraries. |
8704 // It would be nice to be able to report on size-preserving changes. | 8429 // It would be nice to be able to report on size-preserving changes. |
8705 int oldLibraryCount = (oldEntry as DartEntry)._containingLibraries.length; | 8430 int oldLibraryCount = (oldEntry as DartEntry)._containingLibraries.length; |
8706 int libraryCount = _containingLibraries.length; | 8431 int libraryCount = _containingLibraries.length; |
8707 if (oldLibraryCount != libraryCount) { | 8432 if (oldLibraryCount != libraryCount) { |
8708 if (needsSeparator) { | 8433 if (needsSeparator) { |
8709 buffer.write("; "); | 8434 buffer.write("; "); |
8710 } | 8435 } |
8711 buffer.write("containingLibraryCount = "); | 8436 buffer.write("containingLibraryCount = "); |
8712 buffer.write(oldLibraryCount); | 8437 buffer.write(oldLibraryCount); |
(...skipping 20 matching lines...) Expand all Loading... |
8733 if (librarySource != null) { | 8458 if (librarySource != null) { |
8734 ResolutionState oldState = oldStateMap.remove(librarySource); | 8459 ResolutionState oldState = oldStateMap.remove(librarySource); |
8735 if (oldState == null) { | 8460 if (oldState == null) { |
8736 if (needsSeparator) { | 8461 if (needsSeparator) { |
8737 buffer.write("; "); | 8462 buffer.write("; "); |
8738 } | 8463 } |
8739 buffer.write("added resolution for "); | 8464 buffer.write("added resolution for "); |
8740 buffer.write(librarySource.fullName); | 8465 buffer.write(librarySource.fullName); |
8741 needsSeparator = true; | 8466 needsSeparator = true; |
8742 } else { | 8467 } else { |
8743 needsSeparator = | 8468 needsSeparator = oldState._writeDiffOn( |
8744 oldState._writeDiffOn(buffer, needsSeparator, oldEntry as DartEntr
y); | 8469 buffer, needsSeparator, oldEntry as DartEntry); |
8745 } | 8470 } |
8746 } | 8471 } |
8747 state = state._nextState; | 8472 state = state._nextState; |
8748 } | 8473 } |
8749 for (Source librarySource in oldStateMap.keys.toSet()) { | 8474 for (Source librarySource in oldStateMap.keys.toSet()) { |
8750 if (needsSeparator) { | 8475 if (needsSeparator) { |
8751 buffer.write("; "); | 8476 buffer.write("; "); |
8752 } | 8477 } |
8753 buffer.write("removed resolution for "); | 8478 buffer.write("removed resolution for "); |
8754 buffer.write(librarySource.fullName); | 8479 buffer.write(librarySource.fullName); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8920 // | 8645 // |
8921 // TODO(paulberry): as a temporary workaround for issue 21572, | 8646 // TODO(paulberry): as a temporary workaround for issue 21572, |
8922 // ConstantVerifier is being run right after ConstantValueComputer, so we | 8647 // ConstantVerifier is being run right after ConstantValueComputer, so we |
8923 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 8648 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
8924 // call to ConstantVerifier. | 8649 // call to ConstantVerifier. |
8925 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); | 8650 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); |
8926 // _unit.accept(constantVerifier); | 8651 // _unit.accept(constantVerifier); |
8927 // | 8652 // |
8928 // Use the ErrorVerifier to compute the rest of the errors. | 8653 // Use the ErrorVerifier to compute the rest of the errors. |
8929 // | 8654 // |
8930 ErrorVerifier errorVerifier = new ErrorVerifier( | 8655 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, |
8931 errorReporter, | 8656 libraryElement, typeProvider, new InheritanceManager(libraryElement)); |
8932 libraryElement, | |
8933 typeProvider, | |
8934 new InheritanceManager(libraryElement)); | |
8935 _unit.accept(errorVerifier); | 8657 _unit.accept(errorVerifier); |
8936 _errors = errorListener.getErrorsForSource(source); | 8658 _errors = errorListener.getErrorsForSource(source); |
8937 }); | 8659 }); |
8938 } | 8660 } |
8939 | 8661 |
8940 /** | 8662 /** |
8941 * Check each directive in the given compilation unit to see if the referenced
source exists and | 8663 * Check each directive in the given compilation unit to see if the referenced
source exists and |
8942 * report an error if it does not. | 8664 * report an error if it does not. |
8943 * | 8665 * |
8944 * @param context the context in which the library exists | 8666 * @param context the context in which the library exists |
8945 * @param librarySource the source representing the library containing the dir
ectives | 8667 * @param librarySource the source representing the library containing the dir
ectives |
8946 * @param unit the compilation unit containing the directives to be validated | 8668 * @param unit the compilation unit containing the directives to be validated |
8947 * @param errorListener the error listener to which errors should be reported | 8669 * @param errorListener the error listener to which errors should be reported |
8948 */ | 8670 */ |
8949 static void validateDirectives(AnalysisContext context, Source librarySource, | 8671 static void validateDirectives(AnalysisContext context, Source librarySource, |
8950 CompilationUnit unit, AnalysisErrorListener errorListener) { | 8672 CompilationUnit unit, AnalysisErrorListener errorListener) { |
8951 for (Directive directive in unit.directives) { | 8673 for (Directive directive in unit.directives) { |
8952 if (directive is UriBasedDirective) { | 8674 if (directive is UriBasedDirective) { |
8953 validateReferencedSource( | 8675 validateReferencedSource( |
8954 context, | 8676 context, librarySource, directive, errorListener); |
8955 librarySource, | |
8956 directive, | |
8957 errorListener); | |
8958 } | 8677 } |
8959 } | 8678 } |
8960 } | 8679 } |
8961 | 8680 |
8962 /** | 8681 /** |
8963 * Check the given directive to see if the referenced source exists and report
an error if it does | 8682 * Check the given directive to see if the referenced source exists and report
an error if it does |
8964 * not. | 8683 * not. |
8965 * | 8684 * |
8966 * @param context the context in which the library exists | 8685 * @param context the context in which the library exists |
8967 * @param librarySource the source representing the library containing the dir
ective | 8686 * @param librarySource the source representing the library containing the dir
ective |
8968 * @param directive the directive to be verified | 8687 * @param directive the directive to be verified |
8969 * @param errorListener the error listener to which errors should be reported | 8688 * @param errorListener the error listener to which errors should be reported |
8970 */ | 8689 */ |
8971 static void validateReferencedSource(AnalysisContext context, | 8690 static void validateReferencedSource(AnalysisContext context, |
8972 Source librarySource, UriBasedDirective directive, | 8691 Source librarySource, UriBasedDirective directive, |
8973 AnalysisErrorListener errorListener) { | 8692 AnalysisErrorListener errorListener) { |
8974 Source source = directive.source; | 8693 Source source = directive.source; |
8975 if (source != null) { | 8694 if (source != null) { |
8976 if (context.exists(source)) { | 8695 if (context.exists(source)) { |
8977 return; | 8696 return; |
8978 } | 8697 } |
8979 } else { | 8698 } else { |
8980 // Don't report errors already reported by ParseDartTask.resolveDirective | 8699 // Don't report errors already reported by ParseDartTask.resolveDirective |
8981 if (directive.validate() != null) { | 8700 if (directive.validate() != null) { |
8982 return; | 8701 return; |
8983 } | 8702 } |
8984 } | 8703 } |
8985 StringLiteral uriLiteral = directive.uri; | 8704 StringLiteral uriLiteral = directive.uri; |
8986 errorListener.onError( | 8705 errorListener.onError(new AnalysisError.con2(librarySource, |
8987 new AnalysisError.con2( | 8706 uriLiteral.offset, uriLiteral.length, |
8988 librarySource, | 8707 CompileTimeErrorCode.URI_DOES_NOT_EXIST, [directive.uriContent])); |
8989 uriLiteral.offset, | |
8990 uriLiteral.length, | |
8991 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | |
8992 [directive.uriContent])); | |
8993 } | 8708 } |
8994 } | 8709 } |
8995 | 8710 |
8996 /** | 8711 /** |
8997 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. | 8712 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. |
8998 */ | 8713 */ |
8999 class GenerateDartHintsTask extends AnalysisTask { | 8714 class GenerateDartHintsTask extends AnalysisTask { |
9000 /** | 8715 /** |
9001 * The compilation units that comprise the library, with the defining compilat
ion unit appearing | 8716 * The compilation units that comprise the library, with the defining compilat
ion unit appearing |
9002 * first in the array. | 8717 * first in the array. |
(...skipping 12 matching lines...) Expand all Loading... |
9015 HashMap<Source, List<AnalysisError>> _hintMap; | 8730 HashMap<Source, List<AnalysisError>> _hintMap; |
9016 | 8731 |
9017 /** | 8732 /** |
9018 * Initialize a newly created task to perform analysis within the given contex
t. | 8733 * Initialize a newly created task to perform analysis within the given contex
t. |
9019 * | 8734 * |
9020 * @param context the context in which the task is to be performed | 8735 * @param context the context in which the task is to be performed |
9021 * @param units the compilation units that comprise the library, with the defi
ning compilation | 8736 * @param units the compilation units that comprise the library, with the defi
ning compilation |
9022 * unit appearing first in the array | 8737 * unit appearing first in the array |
9023 * @param libraryElement the element model for the library being analyzed | 8738 * @param libraryElement the element model for the library being analyzed |
9024 */ | 8739 */ |
9025 GenerateDartHintsTask(InternalAnalysisContext context, this._units, | 8740 GenerateDartHintsTask( |
9026 this.libraryElement) | 8741 InternalAnalysisContext context, this._units, this.libraryElement) |
9027 : super(context); | 8742 : super(context); |
9028 | 8743 |
9029 /** | 8744 /** |
9030 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the | 8745 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the |
9031 * sources, or `null` if the task has not been performed or if the analysis di
d not complete | 8746 * sources, or `null` if the task has not been performed or if the analysis di
d not complete |
9032 * normally. | 8747 * normally. |
9033 * | 8748 * |
9034 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the | 8749 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the |
9035 * sources | 8750 * sources |
9036 */ | 8751 */ |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9094 HashMap<Source, List<AnalysisError>> lintMap; | 8809 HashMap<Source, List<AnalysisError>> lintMap; |
9095 | 8810 |
9096 /// Initialize a newly created task to perform lint checking over these | 8811 /// Initialize a newly created task to perform lint checking over these |
9097 /// [_units] belonging to this [libraryElement] within the given [context]. | 8812 /// [_units] belonging to this [libraryElement] within the given [context]. |
9098 GenerateDartLintsTask(context, this._units, this.libraryElement) | 8813 GenerateDartLintsTask(context, this._units, this.libraryElement) |
9099 : super(context); | 8814 : super(context); |
9100 | 8815 |
9101 @override | 8816 @override |
9102 String get taskDescription { | 8817 String get taskDescription { |
9103 Source librarySource = libraryElement.source; | 8818 Source librarySource = libraryElement.source; |
9104 return (librarySource == null) ? | 8819 return (librarySource == null) |
9105 "generate Dart lints for library without source" : | 8820 ? "generate Dart lints for library without source" |
9106 "generate Dart lints for ${librarySource.fullName}"; | 8821 : "generate Dart lints for ${librarySource.fullName}"; |
9107 } | 8822 } |
9108 | 8823 |
9109 @override | 8824 @override |
9110 accept(AnalysisTaskVisitor visitor) => | 8825 accept(AnalysisTaskVisitor visitor) => |
9111 visitor.visitGenerateDartLintsTask(this); | 8826 visitor.visitGenerateDartLintsTask(this); |
9112 | 8827 |
9113 @override | 8828 @override |
9114 void internalPerform() { | 8829 void internalPerform() { |
9115 | |
9116 Iterable<CompilationUnit> compilationUnits = | 8830 Iterable<CompilationUnit> compilationUnits = |
9117 _units.map((TimestampedData<CompilationUnit> unit) => unit.data); | 8831 _units.map((TimestampedData<CompilationUnit> unit) => unit.data); |
9118 RecordingErrorListener errorListener = new RecordingErrorListener(); | 8832 RecordingErrorListener errorListener = new RecordingErrorListener(); |
9119 LintGenerator lintGenerator = | 8833 LintGenerator lintGenerator = |
9120 new LintGenerator(compilationUnits, errorListener); | 8834 new LintGenerator(compilationUnits, errorListener); |
9121 lintGenerator.generate(); | 8835 lintGenerator.generate(); |
9122 | 8836 |
9123 lintMap = new HashMap<Source, List<AnalysisError>>(); | 8837 lintMap = new HashMap<Source, List<AnalysisError>>(); |
9124 compilationUnits.forEach((CompilationUnit unit) { | 8838 compilationUnits.forEach((CompilationUnit unit) { |
9125 Source source = unit.element.source; | 8839 Source source = unit.element.source; |
9126 lintMap[source] = errorListener.getErrorsForSource(source); | 8840 lintMap[source] = errorListener.getErrorsForSource(source); |
9127 }); | 8841 }); |
9128 } | 8842 } |
9129 } | 8843 } |
9130 | 8844 |
9131 | |
9132 /** | 8845 /** |
9133 * Instances of the class `GetContentTask` get the contents of a source. | 8846 * Instances of the class `GetContentTask` get the contents of a source. |
9134 */ | 8847 */ |
9135 class GetContentTask extends AnalysisTask { | 8848 class GetContentTask extends AnalysisTask { |
9136 /** | 8849 /** |
9137 * The source to be read. | 8850 * The source to be read. |
9138 */ | 8851 */ |
9139 final Source source; | 8852 final Source source; |
9140 | 8853 |
9141 /** | 8854 /** |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9205 @override | 8918 @override |
9206 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); | 8919 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); |
9207 | 8920 |
9208 @override | 8921 @override |
9209 void internalPerform() { | 8922 void internalPerform() { |
9210 _complete = true; | 8923 _complete = true; |
9211 try { | 8924 try { |
9212 TimestampedData<String> data = context.getContents(source); | 8925 TimestampedData<String> data = context.getContents(source); |
9213 _content = data.data; | 8926 _content = data.data; |
9214 _modificationTime = data.modificationTime; | 8927 _modificationTime = data.modificationTime; |
9215 AnalysisEngine.instance.instrumentationService.logFileRead( | 8928 AnalysisEngine.instance.instrumentationService |
9216 source.fullName, | 8929 .logFileRead(source.fullName, _modificationTime, _content); |
9217 _modificationTime, | |
9218 _content); | |
9219 } catch (exception, stackTrace) { | 8930 } catch (exception, stackTrace) { |
9220 errors.add( | 8931 errors.add(new AnalysisError.con1( |
9221 new AnalysisError.con1( | 8932 source, ScannerErrorCode.UNABLE_GET_CONTENT, [exception])); |
9222 source, | 8933 throw new AnalysisException("Could not get contents of $source", |
9223 ScannerErrorCode.UNABLE_GET_CONTENT, | |
9224 [exception])); | |
9225 throw new AnalysisException( | |
9226 "Could not get contents of $source", | |
9227 new CaughtException(exception, stackTrace)); | 8934 new CaughtException(exception, stackTrace)); |
9228 } | 8935 } |
9229 } | 8936 } |
9230 } | 8937 } |
9231 | 8938 |
9232 /** | 8939 /** |
9233 * An `HtmlEntry` maintains the information cached by an analysis context about | 8940 * An `HtmlEntry` maintains the information cached by an analysis context about |
9234 * an individual HTML file. | 8941 * an individual HTML file. |
9235 */ | 8942 */ |
9236 class HtmlEntry extends SourceEntry { | 8943 class HtmlEntry extends SourceEntry { |
9237 /** | 8944 /** |
9238 * The data descriptor representing the HTML element. | 8945 * The data descriptor representing the HTML element. |
9239 */ | 8946 */ |
9240 static final DataDescriptor<HtmlElement> ELEMENT = | 8947 static final DataDescriptor<HtmlElement> ELEMENT = |
9241 new DataDescriptor<HtmlElement>("HtmlEntry.ELEMENT"); | 8948 new DataDescriptor<HtmlElement>("HtmlEntry.ELEMENT"); |
9242 | 8949 |
9243 /** | 8950 /** |
9244 * The data descriptor representing the hints resulting from auditing the | 8951 * The data descriptor representing the hints resulting from auditing the |
9245 * source. | 8952 * source. |
9246 */ | 8953 */ |
9247 static final DataDescriptor<List<AnalysisError>> HINTS = | 8954 static final DataDescriptor<List<AnalysisError>> HINTS = |
9248 new DataDescriptor<List<AnalysisError>>( | 8955 new DataDescriptor<List<AnalysisError>>( |
9249 "HtmlEntry.HINTS", | 8956 "HtmlEntry.HINTS", AnalysisError.NO_ERRORS); |
9250 AnalysisError.NO_ERRORS); | |
9251 | 8957 |
9252 /** | 8958 /** |
9253 * The data descriptor representing the errors resulting from parsing the | 8959 * The data descriptor representing the errors resulting from parsing the |
9254 * source. | 8960 * source. |
9255 */ | 8961 */ |
9256 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = | 8962 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = |
9257 new DataDescriptor<List<AnalysisError>>( | 8963 new DataDescriptor<List<AnalysisError>>( |
9258 "HtmlEntry.PARSE_ERRORS", | 8964 "HtmlEntry.PARSE_ERRORS", AnalysisError.NO_ERRORS); |
9259 AnalysisError.NO_ERRORS); | |
9260 | 8965 |
9261 /** | 8966 /** |
9262 * The data descriptor representing the parsed AST structure. | 8967 * The data descriptor representing the parsed AST structure. |
9263 */ | 8968 */ |
9264 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT = | 8969 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT = |
9265 new DataDescriptor<ht.HtmlUnit>("HtmlEntry.PARSED_UNIT"); | 8970 new DataDescriptor<ht.HtmlUnit>("HtmlEntry.PARSED_UNIT"); |
9266 | 8971 |
9267 /** | 8972 /** |
9268 * The data descriptor representing the resolved AST structure. | 8973 * The data descriptor representing the resolved AST structure. |
9269 */ | 8974 */ |
9270 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT = | 8975 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT = |
9271 new DataDescriptor<ht.HtmlUnit>("HtmlEntry.RESOLVED_UNIT"); | 8976 new DataDescriptor<ht.HtmlUnit>("HtmlEntry.RESOLVED_UNIT"); |
9272 | 8977 |
9273 /** | 8978 /** |
9274 * The data descriptor representing the list of referenced libraries. | 8979 * The data descriptor representing the list of referenced libraries. |
9275 */ | 8980 */ |
9276 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = | 8981 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = |
9277 new DataDescriptor<List<Source>>( | 8982 new DataDescriptor<List<Source>>( |
9278 "HtmlEntry.REFERENCED_LIBRARIES", | 8983 "HtmlEntry.REFERENCED_LIBRARIES", Source.EMPTY_ARRAY); |
9279 Source.EMPTY_ARRAY); | |
9280 | 8984 |
9281 /** | 8985 /** |
9282 * The data descriptor representing the errors resulting from resolving the | 8986 * The data descriptor representing the errors resulting from resolving the |
9283 * source. | 8987 * source. |
9284 */ | 8988 */ |
9285 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = | 8989 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = |
9286 new DataDescriptor<List<AnalysisError>>( | 8990 new DataDescriptor<List<AnalysisError>>( |
9287 "HtmlEntry.RESOLUTION_ERRORS", | 8991 "HtmlEntry.RESOLUTION_ERRORS", AnalysisError.NO_ERRORS); |
9288 AnalysisError.NO_ERRORS); | |
9289 | 8992 |
9290 /** | 8993 /** |
9291 * Return all of the errors associated with the HTML file that are currently | 8994 * Return all of the errors associated with the HTML file that are currently |
9292 * cached. | 8995 * cached. |
9293 */ | 8996 */ |
9294 List<AnalysisError> get allErrors { | 8997 List<AnalysisError> get allErrors { |
9295 List<AnalysisError> errors = new List<AnalysisError>(); | 8998 List<AnalysisError> errors = new List<AnalysisError>(); |
9296 errors.addAll(super.allErrors); | 8999 errors.addAll(super.allErrors); |
9297 errors.addAll(getValue(PARSE_ERRORS)); | 9000 errors.addAll(getValue(PARSE_ERRORS)); |
9298 errors.addAll(getValue(RESOLUTION_ERRORS)); | 9001 errors.addAll(getValue(RESOLUTION_ERRORS)); |
(...skipping 15 matching lines...) Expand all Loading... |
9314 } | 9017 } |
9315 if (getState(RESOLVED_UNIT) == CacheState.VALID) { | 9018 if (getState(RESOLVED_UNIT) == CacheState.VALID) { |
9316 return getValue(RESOLVED_UNIT); | 9019 return getValue(RESOLVED_UNIT); |
9317 } | 9020 } |
9318 return null; | 9021 return null; |
9319 } | 9022 } |
9320 | 9023 |
9321 @override | 9024 @override |
9322 List<DataDescriptor> get descriptors { | 9025 List<DataDescriptor> get descriptors { |
9323 List<DataDescriptor> result = super.descriptors; | 9026 List<DataDescriptor> result = super.descriptors; |
9324 result.addAll( | 9027 result.addAll([ |
9325 [ | 9028 HtmlEntry.ELEMENT, |
9326 HtmlEntry.ELEMENT, | 9029 HtmlEntry.PARSE_ERRORS, |
9327 HtmlEntry.PARSE_ERRORS, | 9030 HtmlEntry.PARSED_UNIT, |
9328 HtmlEntry.PARSED_UNIT, | 9031 HtmlEntry.RESOLUTION_ERRORS, |
9329 HtmlEntry.RESOLUTION_ERRORS, | 9032 HtmlEntry.RESOLVED_UNIT, |
9330 HtmlEntry.RESOLVED_UNIT, | 9033 HtmlEntry.HINTS |
9331 HtmlEntry.HINTS]); | 9034 ]); |
9332 return result; | 9035 return result; |
9333 } | 9036 } |
9334 | 9037 |
9335 @override | 9038 @override |
9336 SourceKind get kind => SourceKind.HTML; | 9039 SourceKind get kind => SourceKind.HTML; |
9337 | 9040 |
9338 /** | 9041 /** |
9339 * Flush any AST structures being maintained by this entry. | 9042 * Flush any AST structures being maintained by this entry. |
9340 */ | 9043 */ |
9341 void flushAstStructures() { | 9044 void flushAstStructures() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9425 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { | 9128 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { |
9426 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); | 9129 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); |
9427 if (oldEntry is! HtmlEntry) { | 9130 if (oldEntry is! HtmlEntry) { |
9428 if (needsSeparator) { | 9131 if (needsSeparator) { |
9429 buffer.write("; "); | 9132 buffer.write("; "); |
9430 } | 9133 } |
9431 buffer.write("entry type changed; was "); | 9134 buffer.write("entry type changed; was "); |
9432 buffer.write(oldEntry.runtimeType); | 9135 buffer.write(oldEntry.runtimeType); |
9433 return true; | 9136 return true; |
9434 } | 9137 } |
| 9138 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "parseErrors", |
| 9139 HtmlEntry.PARSE_ERRORS, oldEntry); |
9435 needsSeparator = _writeStateDiffOn( | 9140 needsSeparator = _writeStateDiffOn( |
9436 buffer, | 9141 buffer, needsSeparator, "parsedUnit", HtmlEntry.PARSED_UNIT, oldEntry); |
9437 needsSeparator, | 9142 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "resolvedUnit", |
9438 "parseErrors", | 9143 HtmlEntry.RESOLVED_UNIT, oldEntry); |
9439 HtmlEntry.PARSE_ERRORS, | 9144 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
9440 oldEntry); | 9145 "resolutionErrors", HtmlEntry.RESOLUTION_ERRORS, oldEntry); |
| 9146 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
| 9147 "referencedLibraries", HtmlEntry.REFERENCED_LIBRARIES, oldEntry); |
9441 needsSeparator = _writeStateDiffOn( | 9148 needsSeparator = _writeStateDiffOn( |
9442 buffer, | 9149 buffer, needsSeparator, "element", HtmlEntry.ELEMENT, oldEntry); |
9443 needsSeparator, | |
9444 "parsedUnit", | |
9445 HtmlEntry.PARSED_UNIT, | |
9446 oldEntry); | |
9447 needsSeparator = _writeStateDiffOn( | |
9448 buffer, | |
9449 needsSeparator, | |
9450 "resolvedUnit", | |
9451 HtmlEntry.RESOLVED_UNIT, | |
9452 oldEntry); | |
9453 needsSeparator = _writeStateDiffOn( | |
9454 buffer, | |
9455 needsSeparator, | |
9456 "resolutionErrors", | |
9457 HtmlEntry.RESOLUTION_ERRORS, | |
9458 oldEntry); | |
9459 needsSeparator = _writeStateDiffOn( | |
9460 buffer, | |
9461 needsSeparator, | |
9462 "referencedLibraries", | |
9463 HtmlEntry.REFERENCED_LIBRARIES, | |
9464 oldEntry); | |
9465 needsSeparator = _writeStateDiffOn( | |
9466 buffer, | |
9467 needsSeparator, | |
9468 "element", | |
9469 HtmlEntry.ELEMENT, | |
9470 oldEntry); | |
9471 return needsSeparator; | 9150 return needsSeparator; |
9472 } | 9151 } |
9473 | 9152 |
9474 @override | 9153 @override |
9475 void _writeOn(StringBuffer buffer) { | 9154 void _writeOn(StringBuffer buffer) { |
9476 buffer.write("Html: "); | 9155 buffer.write("Html: "); |
9477 super._writeOn(buffer); | 9156 super._writeOn(buffer); |
9478 _writeStateOn(buffer, "parseErrors", PARSE_ERRORS); | 9157 _writeStateOn(buffer, "parseErrors", PARSE_ERRORS); |
9479 _writeStateOn(buffer, "parsedUnit", PARSED_UNIT); | 9158 _writeStateOn(buffer, "parsedUnit", PARSED_UNIT); |
9480 _writeStateOn(buffer, "resolvedUnit", RESOLVED_UNIT); | 9159 _writeStateOn(buffer, "resolvedUnit", RESOLVED_UNIT); |
(...skipping 20 matching lines...) Expand all Loading... |
9501 | 9180 |
9502 String _newContents; | 9181 String _newContents; |
9503 | 9182 |
9504 int _offset = 0; | 9183 int _offset = 0; |
9505 | 9184 |
9506 int _oldLength = 0; | 9185 int _oldLength = 0; |
9507 | 9186 |
9508 int _newLength = 0; | 9187 int _newLength = 0; |
9509 | 9188 |
9510 IncrementalAnalysisCache(this.librarySource, this.source, this.resolvedUnit, | 9189 IncrementalAnalysisCache(this.librarySource, this.source, this.resolvedUnit, |
9511 this.oldContents, String newContents, int offset, int oldLength, int newLe
ngth) | 9190 this.oldContents, String newContents, int offset, int oldLength, |
9512 { | 9191 int newLength) { |
9513 this._newContents = newContents; | 9192 this._newContents = newContents; |
9514 this._offset = offset; | 9193 this._offset = offset; |
9515 this._oldLength = oldLength; | 9194 this._oldLength = oldLength; |
9516 this._newLength = newLength; | 9195 this._newLength = newLength; |
9517 } | 9196 } |
9518 | 9197 |
9519 /** | 9198 /** |
9520 * Determine if the cache contains source changes that need to be analyzed | 9199 * Determine if the cache contains source changes that need to be analyzed |
9521 * | 9200 * |
9522 * @return `true` if the cache contains changes to be analyzed, else `false` | 9201 * @return `true` if the cache contains changes to be analyzed, else `false` |
(...skipping 29 matching lines...) Expand all Loading... |
9552 int get oldLength => _oldLength; | 9231 int get oldLength => _oldLength; |
9553 | 9232 |
9554 /** | 9233 /** |
9555 * Determine if the incremental analysis result can be cached for the next inc
remental analysis. | 9234 * Determine if the incremental analysis result can be cached for the next inc
remental analysis. |
9556 * | 9235 * |
9557 * @param cache the prior incremental analysis cache | 9236 * @param cache the prior incremental analysis cache |
9558 * @param unit the incrementally updated compilation unit | 9237 * @param unit the incrementally updated compilation unit |
9559 * @return the cache used for incremental analysis or `null` if incremental an
alysis results | 9238 * @return the cache used for incremental analysis or `null` if incremental an
alysis results |
9560 * cannot be cached for the next incremental analysis | 9239 * cannot be cached for the next incremental analysis |
9561 */ | 9240 */ |
9562 static IncrementalAnalysisCache cacheResult(IncrementalAnalysisCache cache, | 9241 static IncrementalAnalysisCache cacheResult( |
9563 CompilationUnit unit) { | 9242 IncrementalAnalysisCache cache, CompilationUnit unit) { |
9564 if (cache != null && unit != null) { | 9243 if (cache != null && unit != null) { |
9565 return new IncrementalAnalysisCache( | 9244 return new IncrementalAnalysisCache(cache.librarySource, cache.source, |
9566 cache.librarySource, | 9245 unit, cache._newContents, cache._newContents, 0, 0, 0); |
9567 cache.source, | |
9568 unit, | |
9569 cache._newContents, | |
9570 cache._newContents, | |
9571 0, | |
9572 0, | |
9573 0); | |
9574 } | 9246 } |
9575 return null; | 9247 return null; |
9576 } | 9248 } |
9577 | 9249 |
9578 /** | 9250 /** |
9579 * Determine if the cache should be cleared. | 9251 * Determine if the cache should be cleared. |
9580 * | 9252 * |
9581 * @param cache the prior cache or `null` if none | 9253 * @param cache the prior cache or `null` if none |
9582 * @param source the source being updated (not `null`) | 9254 * @param source the source being updated (not `null`) |
9583 * @return the cache used for incremental analysis or `null` if incremental an
alysis cannot | 9255 * @return the cache used for incremental analysis or `null` if incremental an
alysis cannot |
9584 * be performed | 9256 * be performed |
9585 */ | 9257 */ |
9586 static IncrementalAnalysisCache clear(IncrementalAnalysisCache cache, | 9258 static IncrementalAnalysisCache clear( |
9587 Source source) { | 9259 IncrementalAnalysisCache cache, Source source) { |
9588 if (cache == null || cache.source == source) { | 9260 if (cache == null || cache.source == source) { |
9589 return null; | 9261 return null; |
9590 } | 9262 } |
9591 return cache; | 9263 return cache; |
9592 } | 9264 } |
9593 | 9265 |
9594 /** | 9266 /** |
9595 * Determine if incremental analysis can be performed from the given informati
on. | 9267 * Determine if incremental analysis can be performed from the given informati
on. |
9596 * | 9268 * |
9597 * @param cache the prior cache or `null` if none | 9269 * @param cache the prior cache or `null` if none |
(...skipping 12 matching lines...) Expand all Loading... |
9610 int oldLength, int newLength, SourceEntry sourceEntry) { | 9282 int oldLength, int newLength, SourceEntry sourceEntry) { |
9611 // Determine the cache resolved unit | 9283 // Determine the cache resolved unit |
9612 Source librarySource = null; | 9284 Source librarySource = null; |
9613 CompilationUnit unit = null; | 9285 CompilationUnit unit = null; |
9614 if (sourceEntry is DartEntry) { | 9286 if (sourceEntry is DartEntry) { |
9615 DartEntry dartEntry = sourceEntry; | 9287 DartEntry dartEntry = sourceEntry; |
9616 List<Source> librarySources = dartEntry.librariesContaining; | 9288 List<Source> librarySources = dartEntry.librariesContaining; |
9617 if (librarySources.length == 1) { | 9289 if (librarySources.length == 1) { |
9618 librarySource = librarySources[0]; | 9290 librarySource = librarySources[0]; |
9619 if (librarySource != null) { | 9291 if (librarySource != null) { |
9620 unit = | 9292 unit = dartEntry.getValueInLibrary( |
9621 dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource
); | 9293 DartEntry.RESOLVED_UNIT, librarySource); |
9622 } | 9294 } |
9623 } | 9295 } |
9624 } | 9296 } |
9625 // Create a new cache if there is not an existing cache or the source is | 9297 // Create a new cache if there is not an existing cache or the source is |
9626 // different or a new resolved compilation unit is available. | 9298 // different or a new resolved compilation unit is available. |
9627 if (cache == null || cache.source != source || unit != null) { | 9299 if (cache == null || cache.source != source || unit != null) { |
9628 if (unit == null) { | 9300 if (unit == null) { |
9629 return null; | 9301 return null; |
9630 } | 9302 } |
9631 if (oldContents == null) { | 9303 if (oldContents == null) { |
9632 if (oldLength != 0) { | 9304 if (oldLength != 0) { |
9633 return null; | 9305 return null; |
9634 } | 9306 } |
9635 oldContents = | 9307 oldContents = |
9636 "${newContents.substring(0, offset)}${newContents.substring(offset +
newLength)}"; | 9308 "${newContents.substring(0, offset)}${newContents.substring(offset +
newLength)}"; |
9637 } | 9309 } |
9638 return new IncrementalAnalysisCache( | 9310 return new IncrementalAnalysisCache(librarySource, source, unit, |
9639 librarySource, | 9311 oldContents, newContents, offset, oldLength, newLength); |
9640 source, | |
9641 unit, | |
9642 oldContents, | |
9643 newContents, | |
9644 offset, | |
9645 oldLength, | |
9646 newLength); | |
9647 } | 9312 } |
9648 // Update the existing cache if the change is contiguous | 9313 // Update the existing cache if the change is contiguous |
9649 if (cache._oldLength == 0 && cache._newLength == 0) { | 9314 if (cache._oldLength == 0 && cache._newLength == 0) { |
9650 cache._offset = offset; | 9315 cache._offset = offset; |
9651 cache._oldLength = oldLength; | 9316 cache._oldLength = oldLength; |
9652 cache._newLength = newLength; | 9317 cache._newLength = newLength; |
9653 } else { | 9318 } else { |
9654 if (cache._offset > offset || offset > cache._offset + cache._newLength) { | 9319 if (cache._offset > offset || offset > cache._offset + cache._newLength) { |
9655 return null; | 9320 return null; |
9656 } | 9321 } |
9657 cache._newLength += newLength - oldLength; | 9322 cache._newLength += newLength - oldLength; |
9658 } | 9323 } |
9659 cache._newContents = newContents; | 9324 cache._newContents = newContents; |
9660 return cache; | 9325 return cache; |
9661 } | 9326 } |
9662 | 9327 |
9663 /** | 9328 /** |
9664 * Verify that the incrementally parsed and resolved unit in the incremental c
ache is structurally | 9329 * Verify that the incrementally parsed and resolved unit in the incremental c
ache is structurally |
9665 * equivalent to the fully parsed unit. | 9330 * equivalent to the fully parsed unit. |
9666 * | 9331 * |
9667 * @param cache the prior cache or `null` if none | 9332 * @param cache the prior cache or `null` if none |
9668 * @param source the source of the compilation unit that was parsed (not `null
`) | 9333 * @param source the source of the compilation unit that was parsed (not `null
`) |
9669 * @param unit the compilation unit that was just parsed | 9334 * @param unit the compilation unit that was just parsed |
9670 * @return the cache used for incremental analysis or `null` if incremental an
alysis results | 9335 * @return the cache used for incremental analysis or `null` if incremental an
alysis results |
9671 * cannot be cached for the next incremental analysis | 9336 * cannot be cached for the next incremental analysis |
9672 */ | 9337 */ |
9673 static IncrementalAnalysisCache | 9338 static IncrementalAnalysisCache verifyStructure( |
9674 verifyStructure(IncrementalAnalysisCache cache, Source source, | 9339 IncrementalAnalysisCache cache, Source source, CompilationUnit unit) { |
9675 CompilationUnit unit) { | |
9676 if (cache != null && unit != null && cache.source == source) { | 9340 if (cache != null && unit != null && cache.source == source) { |
9677 if (!AstComparator.equalNodes(cache.resolvedUnit, unit)) { | 9341 if (!AstComparator.equalNodes(cache.resolvedUnit, unit)) { |
9678 return null; | 9342 return null; |
9679 } | 9343 } |
9680 } | 9344 } |
9681 return cache; | 9345 return cache; |
9682 } | 9346 } |
9683 } | 9347 } |
9684 | 9348 |
9685 /** | 9349 /** |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9749 } | 9413 } |
9750 // Only handle small changes | 9414 // Only handle small changes |
9751 if (cache.oldLength > 0 || cache.newLength > 30) { | 9415 if (cache.oldLength > 0 || cache.newLength > 30) { |
9752 return; | 9416 return; |
9753 } | 9417 } |
9754 // Produce an updated token stream | 9418 // Produce an updated token stream |
9755 CharacterReader reader = new CharSequenceReader(cache.newContents); | 9419 CharacterReader reader = new CharSequenceReader(cache.newContents); |
9756 BooleanErrorListener errorListener = new BooleanErrorListener(); | 9420 BooleanErrorListener errorListener = new BooleanErrorListener(); |
9757 IncrementalScanner scanner = | 9421 IncrementalScanner scanner = |
9758 new IncrementalScanner(cache.source, reader, errorListener); | 9422 new IncrementalScanner(cache.source, reader, errorListener); |
9759 scanner.rescan( | 9423 scanner.rescan(cache.resolvedUnit.beginToken, cache.offset, |
9760 cache.resolvedUnit.beginToken, | 9424 cache.oldLength, cache.newLength); |
9761 cache.offset, | |
9762 cache.oldLength, | |
9763 cache.newLength); | |
9764 if (errorListener.errorReported) { | 9425 if (errorListener.errorReported) { |
9765 return; | 9426 return; |
9766 } | 9427 } |
9767 // Produce an updated AST | 9428 // Produce an updated AST |
9768 IncrementalParser parser = new IncrementalParser( | 9429 IncrementalParser parser = new IncrementalParser( |
9769 cache.source, | 9430 cache.source, scanner.tokenMap, AnalysisErrorListener.NULL_LISTENER); |
9770 scanner.tokenMap, | 9431 _updatedUnit = parser.reparse(cache.resolvedUnit, scanner.leftToken, |
9771 AnalysisErrorListener.NULL_LISTENER); | 9432 scanner.rightToken, cache.offset, cache.offset + cache.oldLength); |
9772 _updatedUnit = parser.reparse( | |
9773 cache.resolvedUnit, | |
9774 scanner.leftToken, | |
9775 scanner.rightToken, | |
9776 cache.offset, | |
9777 cache.offset + cache.oldLength); | |
9778 // Update the resolution | 9433 // Update the resolution |
9779 TypeProvider typeProvider = this.typeProvider; | 9434 TypeProvider typeProvider = this.typeProvider; |
9780 if (_updatedUnit != null && typeProvider != null) { | 9435 if (_updatedUnit != null && typeProvider != null) { |
9781 CompilationUnitElement element = _updatedUnit.element; | 9436 CompilationUnitElement element = _updatedUnit.element; |
9782 if (element != null) { | 9437 if (element != null) { |
9783 LibraryElement library = element.library; | 9438 LibraryElement library = element.library; |
9784 if (library != null) { | 9439 if (library != null) { |
9785 IncrementalResolver resolver = new IncrementalResolver( | 9440 IncrementalResolver resolver = new IncrementalResolver( |
9786 element, | 9441 element, cache.offset, cache.oldLength, cache.newLength); |
9787 cache.offset, | |
9788 cache.oldLength, | |
9789 cache.newLength); | |
9790 resolver.resolve(parser.updatedNode); | 9442 resolver.resolve(parser.updatedNode); |
9791 } | 9443 } |
9792 } | 9444 } |
9793 } | 9445 } |
9794 } | 9446 } |
9795 } | 9447 } |
9796 | 9448 |
9797 /** | 9449 /** |
9798 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context | 9450 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context |
9799 * that is required by internal users of the context. | 9451 * that is required by internal users of the context. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9910 * Normally it should not be necessary for clients to call this function, | 9562 * Normally it should not be necessary for clients to call this function, |
9911 * since it will be automatically invoked in response to a call to | 9563 * since it will be automatically invoked in response to a call to |
9912 * [applyChanges] or [setContents]. However, if this analysis context is | 9564 * [applyChanges] or [setContents]. However, if this analysis context is |
9913 * sharing its content cache with other contexts, then the client must | 9565 * sharing its content cache with other contexts, then the client must |
9914 * manually update the content cache and call this function for each context. | 9566 * manually update the content cache and call this function for each context. |
9915 * | 9567 * |
9916 * Return `true` if the change was significant to this context (i.e. [source] | 9568 * Return `true` if the change was significant to this context (i.e. [source] |
9917 * is either implicitly or explicitly analyzed by this context, and a change | 9569 * is either implicitly or explicitly analyzed by this context, and a change |
9918 * actually occurred). | 9570 * actually occurred). |
9919 */ | 9571 */ |
9920 bool handleContentsChanged(Source source, String originalContents, | 9572 bool handleContentsChanged( |
9921 String newContents, bool notify); | 9573 Source source, String originalContents, String newContents, bool notify); |
9922 | 9574 |
9923 /** | 9575 /** |
9924 * Given a table mapping the source for the libraries represented by the corre
sponding elements to | 9576 * Given a table mapping the source for the libraries represented by the corre
sponding elements to |
9925 * the elements representing the libraries, record those mappings. | 9577 * the elements representing the libraries, record those mappings. |
9926 * | 9578 * |
9927 * @param elementMap a table mapping the source for the libraries represented
by the elements to | 9579 * @param elementMap a table mapping the source for the libraries represented
by the elements to |
9928 * the elements representing the libraries | 9580 * the elements representing the libraries |
9929 */ | 9581 */ |
9930 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 9582 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
9931 | 9583 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9980 */ | 9632 */ |
9981 @deprecated | 9633 @deprecated |
9982 void logInformation2(String message, Object exception); | 9634 void logInformation2(String message, Object exception); |
9983 } | 9635 } |
9984 | 9636 |
9985 /** | 9637 /** |
9986 * An implementation of [Logger] that does nothing. | 9638 * An implementation of [Logger] that does nothing. |
9987 */ | 9639 */ |
9988 class NullLogger implements Logger { | 9640 class NullLogger implements Logger { |
9989 @override | 9641 @override |
9990 void logError(String message, [CaughtException exception]) { | 9642 void logError(String message, [CaughtException exception]) {} |
9991 } | |
9992 | 9643 |
9993 @override | 9644 @override |
9994 void logError2(String message, Object exception) { | 9645 void logError2(String message, Object exception) {} |
9995 } | |
9996 | 9646 |
9997 @override | 9647 @override |
9998 void logInformation(String message, [CaughtException exception]) { | 9648 void logInformation(String message, [CaughtException exception]) {} |
9999 } | |
10000 | 9649 |
10001 @override | 9650 @override |
10002 void logInformation2(String message, Object exception) { | 9651 void logInformation2(String message, Object exception) {} |
10003 } | |
10004 } | 9652 } |
10005 | 9653 |
10006 /** | 9654 /** |
10007 * Instances of the class `ObsoleteSourceAnalysisException` represent an analysi
s attempt that | 9655 * Instances of the class `ObsoleteSourceAnalysisException` represent an analysi
s attempt that |
10008 * failed because a source was deleted between the time the analysis started and
the time the | 9656 * failed because a source was deleted between the time the analysis started and
the time the |
10009 * results of the analysis were ready to be recorded. | 9657 * results of the analysis were ready to be recorded. |
10010 */ | 9658 */ |
10011 class ObsoleteSourceAnalysisException extends AnalysisException { | 9659 class ObsoleteSourceAnalysisException extends AnalysisException { |
10012 /** | 9660 /** |
10013 * The source that was removed while it was being analyzed. | 9661 * The source that was removed while it was being analyzed. |
10014 */ | 9662 */ |
10015 Source _source; | 9663 Source _source; |
10016 | 9664 |
10017 /** | 9665 /** |
10018 * Initialize a newly created exception to represent the removal of the given
source. | 9666 * Initialize a newly created exception to represent the removal of the given
source. |
10019 * | 9667 * |
10020 * @param source the source that was removed while it was being analyzed | 9668 * @param source the source that was removed while it was being analyzed |
10021 */ | 9669 */ |
10022 ObsoleteSourceAnalysisException(Source source) | 9670 ObsoleteSourceAnalysisException(Source source) : super( |
10023 : super( | |
10024 "The source '${source.fullName}' was removed while it was being analyz
ed") { | 9671 "The source '${source.fullName}' was removed while it was being analyz
ed") { |
10025 this._source = source; | 9672 this._source = source; |
10026 } | 9673 } |
10027 | 9674 |
10028 /** | 9675 /** |
10029 * Return the source that was removed while it was being analyzed. | 9676 * Return the source that was removed while it was being analyzed. |
10030 * | 9677 * |
10031 * @return the source that was removed | 9678 * @return the source that was removed |
10032 */ | 9679 */ |
10033 Source get source => _source; | 9680 Source get source => _source; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10179 options.analyzeFunctionBodiesPredicate(source); | 9826 options.analyzeFunctionBodiesPredicate(source); |
10180 _unit = parser.parseCompilationUnit(_tokenStream); | 9827 _unit = parser.parseCompilationUnit(_tokenStream); |
10181 _unit.lineInfo = lineInfo; | 9828 _unit.lineInfo = lineInfo; |
10182 AnalysisContext analysisContext = context; | 9829 AnalysisContext analysisContext = context; |
10183 for (Directive directive in _unit.directives) { | 9830 for (Directive directive in _unit.directives) { |
10184 if (directive is PartOfDirective) { | 9831 if (directive is PartOfDirective) { |
10185 _containsPartOfDirective = true; | 9832 _containsPartOfDirective = true; |
10186 } else { | 9833 } else { |
10187 _containsNonPartOfDirective = true; | 9834 _containsNonPartOfDirective = true; |
10188 if (directive is UriBasedDirective) { | 9835 if (directive is UriBasedDirective) { |
10189 Source referencedSource = | 9836 Source referencedSource = resolveDirective( |
10190 resolveDirective(analysisContext, source, directive, errorListen
er); | 9837 analysisContext, source, directive, errorListener); |
10191 if (referencedSource != null) { | 9838 if (referencedSource != null) { |
10192 if (directive is ExportDirective) { | 9839 if (directive is ExportDirective) { |
10193 _exportedSources.add(referencedSource); | 9840 _exportedSources.add(referencedSource); |
10194 } else if (directive is ImportDirective) { | 9841 } else if (directive is ImportDirective) { |
10195 _importedSources.add(referencedSource); | 9842 _importedSources.add(referencedSource); |
10196 } else if (directive is PartDirective) { | 9843 } else if (directive is PartDirective) { |
10197 if (referencedSource != source) { | 9844 if (referencedSource != source) { |
10198 _includedSources.add(referencedSource); | 9845 _includedSources.add(referencedSource); |
10199 } | 9846 } |
10200 } else { | 9847 } else { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10246 String encodedUriContent = Uri.encodeFull(uriContent); | 9893 String encodedUriContent = Uri.encodeFull(uriContent); |
10247 Source source = | 9894 Source source = |
10248 context.sourceFactory.resolveUri(librarySource, encodedUriContent); | 9895 context.sourceFactory.resolveUri(librarySource, encodedUriContent); |
10249 directive.source = source; | 9896 directive.source = source; |
10250 return source; | 9897 return source; |
10251 } | 9898 } |
10252 if (code == UriValidationCode.URI_WITH_DART_EXT_SCHEME) { | 9899 if (code == UriValidationCode.URI_WITH_DART_EXT_SCHEME) { |
10253 return null; | 9900 return null; |
10254 } | 9901 } |
10255 if (code == UriValidationCode.URI_WITH_INTERPOLATION) { | 9902 if (code == UriValidationCode.URI_WITH_INTERPOLATION) { |
10256 errorListener.onError( | 9903 errorListener.onError(new AnalysisError.con2(librarySource, |
10257 new AnalysisError.con2( | 9904 uriLiteral.offset, uriLiteral.length, |
10258 librarySource, | 9905 CompileTimeErrorCode.URI_WITH_INTERPOLATION)); |
10259 uriLiteral.offset, | |
10260 uriLiteral.length, | |
10261 CompileTimeErrorCode.URI_WITH_INTERPOLATION)); | |
10262 return null; | 9906 return null; |
10263 } | 9907 } |
10264 if (code == UriValidationCode.INVALID_URI) { | 9908 if (code == UriValidationCode.INVALID_URI) { |
10265 errorListener.onError( | 9909 errorListener.onError(new AnalysisError.con2(librarySource, |
10266 new AnalysisError.con2( | 9910 uriLiteral.offset, uriLiteral.length, |
10267 librarySource, | 9911 CompileTimeErrorCode.INVALID_URI, [uriContent])); |
10268 uriLiteral.offset, | |
10269 uriLiteral.length, | |
10270 CompileTimeErrorCode.INVALID_URI, | |
10271 [uriContent])); | |
10272 return null; | 9912 return null; |
10273 } | 9913 } |
10274 throw new RuntimeException( | 9914 throw new RuntimeException( |
10275 message: "Failed to handle validation code: $code"); | 9915 message: "Failed to handle validation code: $code"); |
10276 } | 9916 } |
10277 } | 9917 } |
10278 | 9918 |
10279 /** | 9919 /** |
10280 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil
e. | 9920 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil
e. |
10281 */ | 9921 */ |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10387 | 10027 |
10388 @override | 10028 @override |
10389 void internalPerform() { | 10029 void internalPerform() { |
10390 try { | 10030 try { |
10391 ht.AbstractScanner scanner = new ht.StringScanner(source, _content); | 10031 ht.AbstractScanner scanner = new ht.StringScanner(source, _content); |
10392 scanner.passThroughElements = <String>[_TAG_SCRIPT]; | 10032 scanner.passThroughElements = <String>[_TAG_SCRIPT]; |
10393 ht.Token token = scanner.tokenize(); | 10033 ht.Token token = scanner.tokenize(); |
10394 _lineInfo = new LineInfo(scanner.lineStarts); | 10034 _lineInfo = new LineInfo(scanner.lineStarts); |
10395 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10035 RecordingErrorListener errorListener = new RecordingErrorListener(); |
10396 _unit = new ht.HtmlParser(source, errorListener).parse(token, _lineInfo); | 10036 _unit = new ht.HtmlParser(source, errorListener).parse(token, _lineInfo); |
10397 _unit.accept( | 10037 _unit.accept(new RecursiveXmlVisitor_ParseHtmlTask_internalPerform( |
10398 new RecursiveXmlVisitor_ParseHtmlTask_internalPerform(this, errorListe
ner)); | 10038 this, errorListener)); |
10399 _errors = errorListener.getErrorsForSource(source); | 10039 _errors = errorListener.getErrorsForSource(source); |
10400 _referencedLibraries = librarySources; | 10040 _referencedLibraries = librarySources; |
10401 } catch (exception, stackTrace) { | 10041 } catch (exception, stackTrace) { |
10402 throw new AnalysisException( | 10042 throw new AnalysisException( |
10403 "Exception", | 10043 "Exception", new CaughtException(exception, stackTrace)); |
10404 new CaughtException(exception, stackTrace)); | |
10405 } | 10044 } |
10406 } | 10045 } |
10407 | 10046 |
10408 /** | 10047 /** |
10409 * Resolves directives in the given [CompilationUnit]. | 10048 * Resolves directives in the given [CompilationUnit]. |
10410 */ | 10049 */ |
10411 void _resolveScriptDirectives(CompilationUnit script, | 10050 void _resolveScriptDirectives( |
10412 AnalysisErrorListener errorListener) { | 10051 CompilationUnit script, AnalysisErrorListener errorListener) { |
10413 if (script == null) { | 10052 if (script == null) { |
10414 return; | 10053 return; |
10415 } | 10054 } |
10416 AnalysisContext analysisContext = context; | 10055 AnalysisContext analysisContext = context; |
10417 for (Directive directive in script.directives) { | 10056 for (Directive directive in script.directives) { |
10418 if (directive is UriBasedDirective) { | 10057 if (directive is UriBasedDirective) { |
10419 ParseDartTask.resolveDirective( | 10058 ParseDartTask.resolveDirective( |
10420 analysisContext, | 10059 analysisContext, source, directive, errorListener); |
10421 source, | |
10422 directive, | |
10423 errorListener); | |
10424 } | 10060 } |
10425 } | 10061 } |
10426 } | 10062 } |
10427 } | 10063 } |
10428 | 10064 |
10429 class ParseHtmlTask_getLibrarySources extends ht.RecursiveXmlVisitor<Object> { | 10065 class ParseHtmlTask_getLibrarySources extends ht.RecursiveXmlVisitor<Object> { |
10430 final ParseHtmlTask _task; | 10066 final ParseHtmlTask _task; |
10431 | 10067 |
10432 List<Source> libraries; | 10068 List<Source> libraries; |
10433 | 10069 |
10434 ParseHtmlTask_getLibrarySources(this._task, this.libraries) : super(); | 10070 ParseHtmlTask_getLibrarySources(this._task, this.libraries) : super(); |
10435 | 10071 |
10436 @override | 10072 @override |
10437 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { | 10073 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { |
10438 ht.XmlAttributeNode scriptAttribute = null; | 10074 ht.XmlAttributeNode scriptAttribute = null; |
10439 for (ht.XmlAttributeNode attribute in node.attributes) { | 10075 for (ht.XmlAttributeNode attribute in node.attributes) { |
10440 if (javaStringEqualsIgnoreCase( | 10076 if (javaStringEqualsIgnoreCase( |
10441 attribute.name, | 10077 attribute.name, ParseHtmlTask._ATTRIBUTE_SRC)) { |
10442 ParseHtmlTask._ATTRIBUTE_SRC)) { | |
10443 scriptAttribute = attribute; | 10078 scriptAttribute = attribute; |
10444 } | 10079 } |
10445 } | 10080 } |
10446 if (scriptAttribute != null) { | 10081 if (scriptAttribute != null) { |
10447 try { | 10082 try { |
10448 Uri uri = Uri.parse(scriptAttribute.text); | 10083 Uri uri = Uri.parse(scriptAttribute.text); |
10449 String fileName = uri.path; | 10084 String fileName = uri.path; |
10450 Source librarySource = | 10085 Source librarySource = |
10451 _task.context.sourceFactory.resolveUri(_task.source, fileName); | 10086 _task.context.sourceFactory.resolveUri(_task.source, fileName); |
10452 if (_task.context.exists(librarySource)) { | 10087 if (_task.context.exists(librarySource)) { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10718 Source source = error.source; | 10353 Source source = error.source; |
10719 HashSet<AnalysisError> errorsForSource = _errors[source]; | 10354 HashSet<AnalysisError> errorsForSource = _errors[source]; |
10720 if (_errors[source] == null) { | 10355 if (_errors[source] == null) { |
10721 errorsForSource = new HashSet<AnalysisError>(); | 10356 errorsForSource = new HashSet<AnalysisError>(); |
10722 _errors[source] = errorsForSource; | 10357 _errors[source] = errorsForSource; |
10723 } | 10358 } |
10724 errorsForSource.add(error); | 10359 errorsForSource.add(error); |
10725 } | 10360 } |
10726 } | 10361 } |
10727 | 10362 |
10728 class RecursiveXmlVisitor_ParseHtmlTask_internalPerform extends | 10363 class RecursiveXmlVisitor_ParseHtmlTask_internalPerform |
10729 ht.RecursiveXmlVisitor<Object> { | 10364 extends ht.RecursiveXmlVisitor<Object> { |
10730 final ParseHtmlTask ParseHtmlTask_this; | 10365 final ParseHtmlTask ParseHtmlTask_this; |
10731 | 10366 |
10732 RecordingErrorListener errorListener; | 10367 RecordingErrorListener errorListener; |
10733 | 10368 |
10734 RecursiveXmlVisitor_ParseHtmlTask_internalPerform(this.ParseHtmlTask_this, | 10369 RecursiveXmlVisitor_ParseHtmlTask_internalPerform( |
10735 this.errorListener) | 10370 this.ParseHtmlTask_this, this.errorListener) |
10736 : super(); | 10371 : super(); |
10737 | 10372 |
10738 @override | 10373 @override |
10739 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { | 10374 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { |
10740 ParseHtmlTask_this._resolveScriptDirectives(node.script, errorListener); | 10375 ParseHtmlTask_this._resolveScriptDirectives(node.script, errorListener); |
10741 return null; | 10376 return null; |
10742 } | 10377 } |
10743 } | 10378 } |
10744 | 10379 |
10745 class RecursiveXmlVisitor_ResolveHtmlTask_internalPerform extends | 10380 class RecursiveXmlVisitor_ResolveHtmlTask_internalPerform |
10746 ht.RecursiveXmlVisitor<Object> { | 10381 extends ht.RecursiveXmlVisitor<Object> { |
10747 final ResolveHtmlTask ResolveHtmlTask_this; | 10382 final ResolveHtmlTask ResolveHtmlTask_this; |
10748 | 10383 |
10749 RecordingErrorListener errorListener; | 10384 RecordingErrorListener errorListener; |
10750 | 10385 |
10751 RecursiveXmlVisitor_ResolveHtmlTask_internalPerform(this.ResolveHtmlTask_this, | 10386 RecursiveXmlVisitor_ResolveHtmlTask_internalPerform( |
10752 this.errorListener) | 10387 this.ResolveHtmlTask_this, this.errorListener) |
10753 : super(); | 10388 : super(); |
10754 | 10389 |
10755 @override | 10390 @override |
10756 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { | 10391 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { |
10757 CompilationUnit script = node.script; | 10392 CompilationUnit script = node.script; |
10758 if (script != null) { | 10393 if (script != null) { |
10759 GenerateDartErrorsTask.validateDirectives( | 10394 GenerateDartErrorsTask.validateDirectives(ResolveHtmlTask_this.context, |
10760 ResolveHtmlTask_this.context, | 10395 ResolveHtmlTask_this.source, script, errorListener); |
10761 ResolveHtmlTask_this.source, | |
10762 script, | |
10763 errorListener); | |
10764 } | 10396 } |
10765 return null; | 10397 return null; |
10766 } | 10398 } |
10767 } | 10399 } |
10768 | 10400 |
10769 /** | 10401 /** |
10770 * A `ResolutionEraser` removes any resolution information from an AST | 10402 * A `ResolutionEraser` removes any resolution information from an AST |
10771 * structure when used to visit that structure. | 10403 * structure when used to visit that structure. |
10772 */ | 10404 */ |
10773 class ResolutionEraser extends GeneralizingAstVisitor<Object> { | 10405 class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10862 } | 10494 } |
10863 | 10495 |
10864 @override | 10496 @override |
10865 Object visitPrefixExpression(PrefixExpression node) { | 10497 Object visitPrefixExpression(PrefixExpression node) { |
10866 node.staticElement = null; | 10498 node.staticElement = null; |
10867 node.propagatedElement = null; | 10499 node.propagatedElement = null; |
10868 return super.visitPrefixExpression(node); | 10500 return super.visitPrefixExpression(node); |
10869 } | 10501 } |
10870 | 10502 |
10871 @override | 10503 @override |
10872 Object | 10504 Object visitRedirectingConstructorInvocation( |
10873 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation nod
e) { | 10505 RedirectingConstructorInvocation node) { |
10874 node.staticElement = null; | 10506 node.staticElement = null; |
10875 return super.visitRedirectingConstructorInvocation(node); | 10507 return super.visitRedirectingConstructorInvocation(node); |
10876 } | 10508 } |
10877 | 10509 |
10878 @override | 10510 @override |
10879 Object visitSimpleIdentifier(SimpleIdentifier node) { | 10511 Object visitSimpleIdentifier(SimpleIdentifier node) { |
10880 node.staticElement = null; | 10512 node.staticElement = null; |
10881 node.propagatedElement = null; | 10513 node.propagatedElement = null; |
10882 return super.visitSimpleIdentifier(node); | 10514 return super.visitSimpleIdentifier(node); |
10883 } | 10515 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11090 } | 10722 } |
11091 | 10723 |
11092 /** | 10724 /** |
11093 * Write a textual representation of the difference between the old entry and
this entry to the | 10725 * Write a textual representation of the difference between the old entry and
this entry to the |
11094 * given string builder. | 10726 * given string builder. |
11095 * | 10727 * |
11096 * @param builder the string builder to which the difference is to be written | 10728 * @param builder the string builder to which the difference is to be written |
11097 * @param oldEntry the entry that was replaced by this entry | 10729 * @param oldEntry the entry that was replaced by this entry |
11098 * @return `true` if some difference was written | 10730 * @return `true` if some difference was written |
11099 */ | 10731 */ |
11100 bool _writeDiffOn(StringBuffer buffer, bool needsSeparator, | 10732 bool _writeDiffOn( |
11101 DartEntry oldEntry) { | 10733 StringBuffer buffer, bool needsSeparator, DartEntry oldEntry) { |
| 10734 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "resolvedUnit", |
| 10735 DartEntry.RESOLVED_UNIT, oldEntry); |
| 10736 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
| 10737 "resolutionErrors", DartEntry.RESOLUTION_ERRORS, oldEntry); |
| 10738 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, |
| 10739 "verificationErrors", DartEntry.VERIFICATION_ERRORS, oldEntry); |
11102 needsSeparator = _writeStateDiffOn( | 10740 needsSeparator = _writeStateDiffOn( |
11103 buffer, | 10741 buffer, needsSeparator, "hints", DartEntry.HINTS, oldEntry); |
11104 needsSeparator, | |
11105 "resolvedUnit", | |
11106 DartEntry.RESOLVED_UNIT, | |
11107 oldEntry); | |
11108 needsSeparator = _writeStateDiffOn( | 10742 needsSeparator = _writeStateDiffOn( |
11109 buffer, | 10743 buffer, needsSeparator, "lints", DartEntry.LINTS, oldEntry); |
11110 needsSeparator, | |
11111 "resolutionErrors", | |
11112 DartEntry.RESOLUTION_ERRORS, | |
11113 oldEntry); | |
11114 needsSeparator = _writeStateDiffOn( | |
11115 buffer, | |
11116 needsSeparator, | |
11117 "verificationErrors", | |
11118 DartEntry.VERIFICATION_ERRORS, | |
11119 oldEntry); | |
11120 needsSeparator = | |
11121 _writeStateDiffOn(buffer, needsSeparator, "hints", DartEntry.HINTS, oldE
ntry); | |
11122 needsSeparator = | |
11123 _writeStateDiffOn(buffer, needsSeparator, "lints", DartEntry.LINTS, oldE
ntry); | |
11124 return needsSeparator; | 10744 return needsSeparator; |
11125 } | 10745 } |
11126 | 10746 |
11127 /** | 10747 /** |
11128 * Write a textual representation of this state to the given builder. The resu
lt will only be | 10748 * Write a textual representation of this state to the given builder. The resu
lt will only be |
11129 * used for debugging purposes. | 10749 * used for debugging purposes. |
11130 * | 10750 * |
11131 * @param builder the builder to which the text should be written | 10751 * @param builder the builder to which the text should be written |
11132 */ | 10752 */ |
11133 void _writeOn(StringBuffer buffer) { | 10753 void _writeOn(StringBuffer buffer) { |
11134 if (_librarySource != null) { | 10754 if (_librarySource != null) { |
11135 _writeStateOn(buffer, "builtElement", DartEntry.BUILT_ELEMENT); | 10755 _writeStateOn(buffer, "builtElement", DartEntry.BUILT_ELEMENT); |
11136 _writeStateOn(buffer, "builtUnit", DartEntry.BUILT_UNIT); | 10756 _writeStateOn(buffer, "builtUnit", DartEntry.BUILT_UNIT); |
11137 _writeStateOn(buffer, "resolvedUnit", DartEntry.RESOLVED_UNIT); | 10757 _writeStateOn(buffer, "resolvedUnit", DartEntry.RESOLVED_UNIT); |
11138 _writeStateOn(buffer, "resolutionErrors", DartEntry.RESOLUTION_ERRORS); | 10758 _writeStateOn(buffer, "resolutionErrors", DartEntry.RESOLUTION_ERRORS); |
11139 _writeStateOn( | 10759 _writeStateOn( |
11140 buffer, | 10760 buffer, "verificationErrors", DartEntry.VERIFICATION_ERRORS); |
11141 "verificationErrors", | |
11142 DartEntry.VERIFICATION_ERRORS); | |
11143 _writeStateOn(buffer, "hints", DartEntry.HINTS); | 10761 _writeStateOn(buffer, "hints", DartEntry.HINTS); |
11144 _writeStateOn(buffer, "lints", DartEntry.LINTS); | 10762 _writeStateOn(buffer, "lints", DartEntry.LINTS); |
11145 if (_nextState != null) { | 10763 if (_nextState != null) { |
11146 _nextState._writeOn(buffer); | 10764 _nextState._writeOn(buffer); |
11147 } | 10765 } |
11148 } | 10766 } |
11149 } | 10767 } |
11150 | 10768 |
11151 /** | 10769 /** |
11152 * Write a textual representation of the difference between the state of the | 10770 * Write a textual representation of the difference between the state of the |
(...skipping 16 matching lines...) Expand all Loading... |
11169 return true; | 10787 return true; |
11170 } | 10788 } |
11171 return needsSeparator; | 10789 return needsSeparator; |
11172 } | 10790 } |
11173 | 10791 |
11174 /** | 10792 /** |
11175 * Write a textual representation of the state of the value described by the | 10793 * Write a textual representation of the state of the value described by the |
11176 * given [descriptor] to the given bugger, prefixed by the given [label] to | 10794 * given [descriptor] to the given bugger, prefixed by the given [label] to |
11177 * the given [buffer]. | 10795 * the given [buffer]. |
11178 */ | 10796 */ |
11179 void _writeStateOn(StringBuffer buffer, String label, | 10797 void _writeStateOn( |
11180 DataDescriptor descriptor) { | 10798 StringBuffer buffer, String label, DataDescriptor descriptor) { |
11181 CachedResult result = resultMap[descriptor]; | 10799 CachedResult result = resultMap[descriptor]; |
11182 buffer.write("; "); | 10800 buffer.write("; "); |
11183 buffer.write(label); | 10801 buffer.write(label); |
11184 buffer.write(" = "); | 10802 buffer.write(" = "); |
11185 buffer.write(result == null ? CacheState.INVALID : result.state); | 10803 buffer.write(result == null ? CacheState.INVALID : result.state); |
11186 } | 10804 } |
11187 } | 10805 } |
11188 | 10806 |
11189 /** | 10807 /** |
11190 * A `ResolvableCompilationUnit` is a compilation unit that is not referenced by | 10808 * A `ResolvableCompilationUnit` is a compilation unit that is not referenced by |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11293 */ | 10911 */ |
11294 LibraryResolver _resolver; | 10912 LibraryResolver _resolver; |
11295 | 10913 |
11296 /** | 10914 /** |
11297 * Initialize a newly created task to perform analysis within the given contex
t. | 10915 * Initialize a newly created task to perform analysis within the given contex
t. |
11298 * | 10916 * |
11299 * @param context the context in which the task is to be performed | 10917 * @param context the context in which the task is to be performed |
11300 * @param unitSource the source representing the file whose compilation unit i
s to be returned | 10918 * @param unitSource the source representing the file whose compilation unit i
s to be returned |
11301 * @param librarySource the source representing the library to be resolved | 10919 * @param librarySource the source representing the library to be resolved |
11302 */ | 10920 */ |
11303 ResolveDartLibraryTask(InternalAnalysisContext context, this.unitSource, | 10921 ResolveDartLibraryTask( |
11304 this.librarySource) | 10922 InternalAnalysisContext context, this.unitSource, this.librarySource) |
11305 : super(context); | 10923 : super(context); |
11306 | 10924 |
11307 /** | 10925 /** |
11308 * Return the library resolver holding information about the libraries that we
re resolved. | 10926 * Return the library resolver holding information about the libraries that we
re resolved. |
11309 * | 10927 * |
11310 * @return the library resolver holding information about the libraries that w
ere resolved | 10928 * @return the library resolver holding information about the libraries that w
ere resolved |
11311 */ | 10929 */ |
11312 LibraryResolver get libraryResolver => _resolver; | 10930 LibraryResolver get libraryResolver => _resolver; |
11313 | 10931 |
11314 @override | 10932 @override |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11350 */ | 10968 */ |
11351 CompilationUnit _resolvedUnit; | 10969 CompilationUnit _resolvedUnit; |
11352 | 10970 |
11353 /** | 10971 /** |
11354 * Initialize a newly created task to perform analysis within the given contex
t. | 10972 * Initialize a newly created task to perform analysis within the given contex
t. |
11355 * | 10973 * |
11356 * @param context the context in which the task is to be performed | 10974 * @param context the context in which the task is to be performed |
11357 * @param source the source to be parsed | 10975 * @param source the source to be parsed |
11358 * @param libraryElement the element model for the library containing the sour
ce | 10976 * @param libraryElement the element model for the library containing the sour
ce |
11359 */ | 10977 */ |
11360 ResolveDartUnitTask(InternalAnalysisContext context, this.source, | 10978 ResolveDartUnitTask( |
11361 this._libraryElement) | 10979 InternalAnalysisContext context, this.source, this._libraryElement) |
11362 : super(context); | 10980 : super(context); |
11363 | 10981 |
11364 /** | 10982 /** |
11365 * Return the source for the library containing the source that is to be resol
ved. | 10983 * Return the source for the library containing the source that is to be resol
ved. |
11366 * | 10984 * |
11367 * @return the source for the library containing the source that is to be reso
lved | 10985 * @return the source for the library containing the source that is to be reso
lved |
11368 */ | 10986 */ |
11369 Source get librarySource => _libraryElement.source; | 10987 Source get librarySource => _libraryElement.source; |
11370 | 10988 |
11371 /** | 10989 /** |
(...skipping 26 matching lines...) Expand all Loading... |
11398 } | 11016 } |
11399 // | 11017 // |
11400 // Resolve names in declarations. | 11018 // Resolve names in declarations. |
11401 // | 11019 // |
11402 new DeclarationResolver().resolve(unit, _find(_libraryElement, source)); | 11020 new DeclarationResolver().resolve(unit, _find(_libraryElement, source)); |
11403 // | 11021 // |
11404 // Resolve the type names. | 11022 // Resolve the type names. |
11405 // | 11023 // |
11406 RecordingErrorListener errorListener = new RecordingErrorListener(); | 11024 RecordingErrorListener errorListener = new RecordingErrorListener(); |
11407 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.con2( | 11025 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.con2( |
11408 _libraryElement, | 11026 _libraryElement, source, typeProvider, errorListener); |
11409 source, | |
11410 typeProvider, | |
11411 errorListener); | |
11412 unit.accept(typeResolverVisitor); | 11027 unit.accept(typeResolverVisitor); |
11413 // | 11028 // |
11414 // Resolve the rest of the structure | 11029 // Resolve the rest of the structure |
11415 // | 11030 // |
11416 InheritanceManager inheritanceManager = | 11031 InheritanceManager inheritanceManager = |
11417 new InheritanceManager(_libraryElement); | 11032 new InheritanceManager(_libraryElement); |
11418 ResolverVisitor resolverVisitor = new ResolverVisitor.con2( | 11033 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(_libraryElement, |
11419 _libraryElement, | 11034 source, typeProvider, inheritanceManager, errorListener); |
11420 source, | |
11421 typeProvider, | |
11422 inheritanceManager, | |
11423 errorListener); | |
11424 unit.accept(resolverVisitor); | 11035 unit.accept(resolverVisitor); |
11425 // | 11036 // |
11426 // Perform additional error checking. | 11037 // Perform additional error checking. |
11427 // | 11038 // |
11428 PerformanceStatistics.errors.makeCurrentWhile(() { | 11039 PerformanceStatistics.errors.makeCurrentWhile(() { |
11429 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 11040 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
11430 ErrorVerifier errorVerifier = new ErrorVerifier( | 11041 ErrorVerifier errorVerifier = new ErrorVerifier( |
11431 errorReporter, | 11042 errorReporter, _libraryElement, typeProvider, inheritanceManager); |
11432 _libraryElement, | |
11433 typeProvider, | |
11434 inheritanceManager); | |
11435 unit.accept(errorVerifier); | 11043 unit.accept(errorVerifier); |
11436 // TODO(paulberry): as a temporary workaround for issue 21572, | 11044 // TODO(paulberry): as a temporary workaround for issue 21572, |
11437 // ConstantVerifier is being run right after ConstantValueComputer, so we | 11045 // ConstantVerifier is being run right after ConstantValueComputer, so we |
11438 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 11046 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
11439 // call to ConstantVerifier. | 11047 // call to ConstantVerifier. |
11440 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); | 11048 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); |
11441 // unit.accept(constantVerifier); | 11049 // unit.accept(constantVerifier); |
11442 }); | 11050 }); |
11443 // | 11051 // |
11444 // Capture the results. | 11052 // Capture the results. |
11445 // | 11053 // |
11446 _resolvedUnit = unit; | 11054 _resolvedUnit = unit; |
11447 } | 11055 } |
11448 | 11056 |
11449 /** | 11057 /** |
11450 * Search the compilation units that are part of the given library and return
the element | 11058 * Search the compilation units that are part of the given library and return
the element |
11451 * representing the compilation unit with the given source. Return `null` if t
here is no | 11059 * representing the compilation unit with the given source. Return `null` if t
here is no |
11452 * such compilation unit. | 11060 * such compilation unit. |
11453 * | 11061 * |
11454 * @param libraryElement the element representing the library being searched t
hrough | 11062 * @param libraryElement the element representing the library being searched t
hrough |
11455 * @param unitSource the source for the compilation unit whose element is to b
e returned | 11063 * @param unitSource the source for the compilation unit whose element is to b
e returned |
11456 * @return the element representing the compilation unit | 11064 * @return the element representing the compilation unit |
11457 */ | 11065 */ |
11458 CompilationUnitElement _find(LibraryElement libraryElement, | 11066 CompilationUnitElement _find( |
11459 Source unitSource) { | 11067 LibraryElement libraryElement, Source unitSource) { |
11460 CompilationUnitElement element = libraryElement.definingCompilationUnit; | 11068 CompilationUnitElement element = libraryElement.definingCompilationUnit; |
11461 if (element.source == unitSource) { | 11069 if (element.source == unitSource) { |
11462 return element; | 11070 return element; |
11463 } | 11071 } |
11464 for (CompilationUnitElement partElement in libraryElement.parts) { | 11072 for (CompilationUnitElement partElement in libraryElement.parts) { |
11465 if (partElement.source == unitSource) { | 11073 if (partElement.source == unitSource) { |
11466 return partElement; | 11074 return partElement; |
11467 } | 11075 } |
11468 } | 11076 } |
11469 return null; | 11077 return null; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11542 void internalPerform() { | 11150 void internalPerform() { |
11543 // | 11151 // |
11544 // Build the standard HTML element. | 11152 // Build the standard HTML element. |
11545 // | 11153 // |
11546 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); | 11154 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); |
11547 _element = builder.buildHtmlElement(source, _unit); | 11155 _element = builder.buildHtmlElement(source, _unit); |
11548 RecordingErrorListener errorListener = builder.errorListener; | 11156 RecordingErrorListener errorListener = builder.errorListener; |
11549 // | 11157 // |
11550 // Validate the directives | 11158 // Validate the directives |
11551 // | 11159 // |
11552 _unit.accept( | 11160 _unit.accept(new RecursiveXmlVisitor_ResolveHtmlTask_internalPerform( |
11553 new RecursiveXmlVisitor_ResolveHtmlTask_internalPerform(this, errorListe
ner)); | 11161 this, errorListener)); |
11554 // | 11162 // |
11555 // Record all resolution errors. | 11163 // Record all resolution errors. |
11556 // | 11164 // |
11557 _resolutionErrors = errorListener.getErrorsForSource(source); | 11165 _resolutionErrors = errorListener.getErrorsForSource(source); |
11558 // | 11166 // |
11559 // Remember the resolved unit. | 11167 // Remember the resolved unit. |
11560 // | 11168 // |
11561 _resolvedUnit = _unit; | 11169 _resolvedUnit = _unit; |
11562 } | 11170 } |
11563 } | 11171 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11663 Token get tokenStream => _tokenStream; | 11271 Token get tokenStream => _tokenStream; |
11664 | 11272 |
11665 @override | 11273 @override |
11666 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); | 11274 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); |
11667 | 11275 |
11668 @override | 11276 @override |
11669 void internalPerform() { | 11277 void internalPerform() { |
11670 PerformanceStatistics.scan.makeCurrentWhile(() { | 11278 PerformanceStatistics.scan.makeCurrentWhile(() { |
11671 RecordingErrorListener errorListener = new RecordingErrorListener(); | 11279 RecordingErrorListener errorListener = new RecordingErrorListener(); |
11672 try { | 11280 try { |
11673 Scanner scanner = | 11281 Scanner scanner = new Scanner( |
11674 new Scanner(source, new CharSequenceReader(_content), errorListener)
; | 11282 source, new CharSequenceReader(_content), errorListener); |
11675 scanner.preserveComments = context.analysisOptions.preserveComments; | 11283 scanner.preserveComments = context.analysisOptions.preserveComments; |
11676 _tokenStream = scanner.tokenize(); | 11284 _tokenStream = scanner.tokenize(); |
11677 _lineInfo = new LineInfo(scanner.lineStarts); | 11285 _lineInfo = new LineInfo(scanner.lineStarts); |
11678 _errors = errorListener.getErrorsForSource(source); | 11286 _errors = errorListener.getErrorsForSource(source); |
11679 } catch (exception, stackTrace) { | 11287 } catch (exception, stackTrace) { |
11680 throw new AnalysisException( | 11288 throw new AnalysisException( |
11681 "Exception", | 11289 "Exception", new CaughtException(exception, stackTrace)); |
11682 new CaughtException(exception, stackTrace)); | |
11683 } | 11290 } |
11684 }); | 11291 }); |
11685 } | 11292 } |
11686 } | 11293 } |
11687 | 11294 |
11688 /** | 11295 /** |
11689 * Instances of the class `SdkAnalysisContext` implement an [AnalysisContext] th
at only | 11296 * Instances of the class `SdkAnalysisContext` implement an [AnalysisContext] th
at only |
11690 * contains sources for a Dart SDK. | 11297 * contains sources for a Dart SDK. |
11691 */ | 11298 */ |
11692 class SdkAnalysisContext extends AnalysisContextImpl { | 11299 class SdkAnalysisContext extends AnalysisContextImpl { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11734 */ | 11341 */ |
11735 static final DataDescriptor<String> CONTENT = | 11342 static final DataDescriptor<String> CONTENT = |
11736 new DataDescriptor<String>("SourceEntry.CONTENT"); | 11343 new DataDescriptor<String>("SourceEntry.CONTENT"); |
11737 | 11344 |
11738 /** | 11345 /** |
11739 * The data descriptor representing the errors resulting from reading the | 11346 * The data descriptor representing the errors resulting from reading the |
11740 * source content. | 11347 * source content. |
11741 */ | 11348 */ |
11742 static final DataDescriptor<List<AnalysisError>> CONTENT_ERRORS = | 11349 static final DataDescriptor<List<AnalysisError>> CONTENT_ERRORS = |
11743 new DataDescriptor<List<AnalysisError>>( | 11350 new DataDescriptor<List<AnalysisError>>( |
11744 "SourceEntry.CONTENT_ERRORS", | 11351 "SourceEntry.CONTENT_ERRORS", AnalysisError.NO_ERRORS); |
11745 AnalysisError.NO_ERRORS); | |
11746 | 11352 |
11747 /** | 11353 /** |
11748 * The data descriptor representing the line information. | 11354 * The data descriptor representing the line information. |
11749 */ | 11355 */ |
11750 static final DataDescriptor<LineInfo> LINE_INFO = | 11356 static final DataDescriptor<LineInfo> LINE_INFO = |
11751 new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO"); | 11357 new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO"); |
11752 | 11358 |
11753 /** | 11359 /** |
11754 * The index of the flag indicating whether the source was explicitly added to | 11360 * The index of the flag indicating whether the source was explicitly added to |
11755 * the context or whether the source was implicitly added because it was | 11361 * the context or whether the source was implicitly added because it was |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12052 } | 11658 } |
12053 buffer.write("time = "); | 11659 buffer.write("time = "); |
12054 buffer.write(oldModificationTime); | 11660 buffer.write(oldModificationTime); |
12055 buffer.write(" -> "); | 11661 buffer.write(" -> "); |
12056 buffer.write(modificationTime); | 11662 buffer.write(modificationTime); |
12057 needsSeparator = true; | 11663 needsSeparator = true; |
12058 } | 11664 } |
12059 needsSeparator = | 11665 needsSeparator = |
12060 _writeStateDiffOn(buffer, needsSeparator, "content", CONTENT, oldEntry); | 11666 _writeStateDiffOn(buffer, needsSeparator, "content", CONTENT, oldEntry); |
12061 needsSeparator = _writeStateDiffOn( | 11667 needsSeparator = _writeStateDiffOn( |
12062 buffer, | 11668 buffer, needsSeparator, "contentErrors", CONTENT_ERRORS, oldEntry); |
12063 needsSeparator, | 11669 needsSeparator = _writeStateDiffOn( |
12064 "contentErrors", | 11670 buffer, needsSeparator, "lineInfo", LINE_INFO, oldEntry); |
12065 CONTENT_ERRORS, | |
12066 oldEntry); | |
12067 needsSeparator = | |
12068 _writeStateDiffOn(buffer, needsSeparator, "lineInfo", LINE_INFO, oldEntr
y); | |
12069 return needsSeparator; | 11671 return needsSeparator; |
12070 } | 11672 } |
12071 | 11673 |
12072 /** | 11674 /** |
12073 * Write a textual representation of this entry to the given [buffer]. The | 11675 * Write a textual representation of this entry to the given [buffer]. The |
12074 * result should only be used for debugging purposes. | 11676 * result should only be used for debugging purposes. |
12075 */ | 11677 */ |
12076 void _writeOn(StringBuffer buffer) { | 11678 void _writeOn(StringBuffer buffer) { |
12077 buffer.write("time = "); | 11679 buffer.write("time = "); |
12078 buffer.write(modificationTime); | 11680 buffer.write(modificationTime); |
(...skipping 23 matching lines...) Expand all Loading... |
12102 return true; | 11704 return true; |
12103 } | 11705 } |
12104 return needsSeparator; | 11706 return needsSeparator; |
12105 } | 11707 } |
12106 | 11708 |
12107 /** | 11709 /** |
12108 * Write a textual representation of the state of the value described by the | 11710 * Write a textual representation of the state of the value described by the |
12109 * given [descriptor] to the given bugger, prefixed by the given [label] to | 11711 * given [descriptor] to the given bugger, prefixed by the given [label] to |
12110 * the given [buffer]. | 11712 * the given [buffer]. |
12111 */ | 11713 */ |
12112 void _writeStateOn(StringBuffer buffer, String label, | 11714 void _writeStateOn( |
12113 DataDescriptor descriptor) { | 11715 StringBuffer buffer, String label, DataDescriptor descriptor) { |
12114 CachedResult result = resultMap[descriptor]; | 11716 CachedResult result = resultMap[descriptor]; |
12115 buffer.write("; "); | 11717 buffer.write("; "); |
12116 buffer.write(label); | 11718 buffer.write(label); |
12117 buffer.write(" = "); | 11719 buffer.write(" = "); |
12118 buffer.write(result == null ? CacheState.INVALID : result.state); | 11720 buffer.write(result == null ? CacheState.INVALID : result.state); |
12119 } | 11721 } |
12120 | 11722 |
12121 /** | 11723 /** |
12122 * Increment the count of the number of times that data represented by the | 11724 * Increment the count of the number of times that data represented by the |
12123 * given [descriptor] was transitioned from the current state (as found in the | 11725 * given [descriptor] was transitioned from the current state (as found in the |
12124 * given [result] to a valid state. | 11726 * given [result] to a valid state. |
12125 */ | 11727 */ |
12126 static void countTransition(DataDescriptor descriptor, CachedResult result) { | 11728 static void countTransition(DataDescriptor descriptor, CachedResult result) { |
12127 Map<CacheState, int> countMap = | 11729 Map<CacheState, int> countMap = transitionMap.putIfAbsent( |
12128 transitionMap.putIfAbsent(descriptor, () => new HashMap<CacheState, int>
()); | 11730 descriptor, () => new HashMap<CacheState, int>()); |
12129 int count = countMap[result.state]; | 11731 int count = countMap[result.state]; |
12130 countMap[result.state] = count == null ? 1 : count + 1; | 11732 countMap[result.state] = count == null ? 1 : count + 1; |
12131 } | 11733 } |
12132 } | 11734 } |
12133 | 11735 |
12134 /** | 11736 /** |
12135 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an | 11737 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an |
12136 * optimal order. A smaller ordinal value equates to a higher priority. | 11738 * optimal order. A smaller ordinal value equates to a higher priority. |
12137 */ | 11739 */ |
12138 class SourcePriority extends Enum<SourcePriority> { | 11740 class SourcePriority extends Enum<SourcePriority> { |
(...skipping 20 matching lines...) Expand all Loading... |
12159 */ | 11761 */ |
12160 static const SourcePriority NORMAL_PART = | 11762 static const SourcePriority NORMAL_PART = |
12161 const SourcePriority('NORMAL_PART', 3); | 11763 const SourcePriority('NORMAL_PART', 3); |
12162 | 11764 |
12163 /** | 11765 /** |
12164 * Used for an HTML source. | 11766 * Used for an HTML source. |
12165 */ | 11767 */ |
12166 static const SourcePriority HTML = const SourcePriority('HTML', 4); | 11768 static const SourcePriority HTML = const SourcePriority('HTML', 4); |
12167 | 11769 |
12168 static const List<SourcePriority> values = const [ | 11770 static const List<SourcePriority> values = const [ |
12169 PRIORITY_PART, | 11771 PRIORITY_PART, |
12170 LIBRARY, | 11772 LIBRARY, |
12171 UNKNOWN, | 11773 UNKNOWN, |
12172 NORMAL_PART, | 11774 NORMAL_PART, |
12173 HTML]; | 11775 HTML |
| 11776 ]; |
12174 | 11777 |
12175 const SourcePriority(String name, int ordinal) : super(name, ordinal); | 11778 const SourcePriority(String name, int ordinal) : super(name, ordinal); |
12176 } | 11779 } |
12177 | 11780 |
12178 /** | 11781 /** |
12179 * [SourcesChangedEvent] indicates which sources have been added, removed, | 11782 * [SourcesChangedEvent] indicates which sources have been added, removed, |
12180 * or whose contents have changed. | 11783 * or whose contents have changed. |
12181 */ | 11784 */ |
12182 class SourcesChangedEvent { | 11785 class SourcesChangedEvent { |
12183 | 11786 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12518 * exception, the future will fail with that exception. | 12121 * exception, the future will fail with that exception. |
12519 * | 12122 * |
12520 * If the [computeValue] still returns null after there is no further | 12123 * If the [computeValue] still returns null after there is no further |
12521 * analysis to be done for [source], then the future will be completed with | 12124 * analysis to be done for [source], then the future will be completed with |
12522 * the error AnalysisNotScheduledError. | 12125 * the error AnalysisNotScheduledError. |
12523 * | 12126 * |
12524 * Since [computeValue] will be called while the state of analysis is being | 12127 * Since [computeValue] will be called while the state of analysis is being |
12525 * updated, it should be free of side effects so that it doesn't cause | 12128 * updated, it should be free of side effects so that it doesn't cause |
12526 * reentrant changes to the analysis state. | 12129 * reentrant changes to the analysis state. |
12527 */ | 12130 */ |
12528 CancelableFuture<T> computeAsync(Source source, T | 12131 CancelableFuture<T> computeAsync( |
12529 computeValue(SourceEntry sourceEntry)) { | 12132 Source source, T computeValue(SourceEntry sourceEntry)) { |
12530 if (_context.isDisposed) { | 12133 if (_context.isDisposed) { |
12531 // No further analysis is expected, so return a future that completes | 12134 // No further analysis is expected, so return a future that completes |
12532 // immediately with AnalysisNotScheduledError. | 12135 // immediately with AnalysisNotScheduledError. |
12533 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 12136 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
12534 } | 12137 } |
12535 SourceEntry sourceEntry = _context.getReadableSourceEntryOrNull(source); | 12138 SourceEntry sourceEntry = _context.getReadableSourceEntryOrNull(source); |
12536 if (sourceEntry == null) { | 12139 if (sourceEntry == null) { |
12537 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 12140 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
12538 } | 12141 } |
12539 PendingFuture pendingFuture = | 12142 PendingFuture pendingFuture = |
12540 new PendingFuture<T>(_context, source, computeValue); | 12143 new PendingFuture<T>(_context, source, computeValue); |
12541 if (!pendingFuture.evaluate(sourceEntry)) { | 12144 if (!pendingFuture.evaluate(sourceEntry)) { |
12542 _context._pendingFutureSources.putIfAbsent( | 12145 _context._pendingFutureSources |
12543 source, | 12146 .putIfAbsent(source, () => <PendingFuture>[]) |
12544 () => <PendingFuture>[]).add(pendingFuture); | 12147 .add(pendingFuture); |
12545 } | 12148 } |
12546 return pendingFuture.future; | 12149 return pendingFuture.future; |
12547 } | 12150 } |
12548 } | 12151 } |
12549 | 12152 |
12550 class _ElementByIdFinder extends GeneralizingElementVisitor { | 12153 class _ElementByIdFinder extends GeneralizingElementVisitor { |
12551 final int _id; | 12154 final int _id; |
12552 Element result; | 12155 Element result; |
12553 | 12156 |
12554 _ElementByIdFinder(this._id); | 12157 _ElementByIdFinder(this._id); |
12555 | 12158 |
12556 @override | 12159 @override |
12557 visitElement(Element element) { | 12160 visitElement(Element element) { |
12558 if (element.id == _id) { | 12161 if (element.id == _id) { |
12559 result = element; | 12162 result = element; |
12560 throw new _ElementByIdFinderException(); | 12163 throw new _ElementByIdFinderException(); |
12561 } | 12164 } |
12562 super.visitElement(element); | 12165 super.visitElement(element); |
12563 } | 12166 } |
12564 } | 12167 } |
12565 | 12168 |
12566 class _ElementByIdFinderException { | 12169 class _ElementByIdFinderException {} |
12567 } | |
OLD | NEW |