| 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:collection'; |
| 10 import 'java_core.dart'; | 11 import 'java_core.dart'; |
| 11 import 'java_engine.dart'; | 12 import 'java_engine.dart'; |
| 12 import 'utilities_collection.dart'; | 13 import 'utilities_collection.dart'; |
| 13 import 'utilities_general.dart'; | 14 import 'utilities_general.dart'; |
| 14 import 'instrumentation.dart'; | 15 import 'instrumentation.dart'; |
| 15 import 'error.dart'; | 16 import 'error.dart'; |
| 16 import 'source.dart'; | 17 import 'source.dart'; |
| 17 import 'scanner.dart'; | 18 import 'scanner.dart'; |
| 18 import 'ast.dart'; | 19 import 'ast.dart'; |
| 19 import 'parser.dart' show Parser, IncrementalParser; | 20 import 'parser.dart' show Parser, IncrementalParser; |
| 20 import 'sdk.dart' show DartSdk; | 21 import 'sdk.dart' show DartSdk; |
| 22 import 'constant.dart'; |
| 21 import 'element.dart'; | 23 import 'element.dart'; |
| 22 import 'resolver.dart'; | 24 import 'resolver.dart'; |
| 23 import 'html.dart' as ht; | 25 import 'html.dart' as ht; |
| 24 import 'package:analyzer/src/generated/constant.dart'; | |
| 25 | 26 |
| 26 /** | 27 /** |
| 27 * Instances of the class `AnalysisCache` implement an LRU cache of information
related to | 28 * Instances of the class `AnalysisCache` implement an LRU cache of information
related to |
| 28 * analysis. | 29 * analysis. |
| 29 */ | 30 */ |
| 30 class AnalysisCache { | 31 class AnalysisCache { |
| 31 /** | 32 /** |
| 32 * An array containing the partitions of which this cache is comprised. | 33 * An array containing the partitions of which this cache is comprised. |
| 33 */ | 34 */ |
| 34 final List<CachePartition> _partitions; | 35 final List<CachePartition> _partitions; |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 /** | 867 /** |
| 867 * An array containing sources whose AST structure is needed in order to resol
ve the next library | 868 * An array containing sources whose AST structure is needed in order to resol
ve the next library |
| 868 * to be resolved. | 869 * to be resolved. |
| 869 */ | 870 */ |
| 870 Set<Source> _neededForResolution = null; | 871 Set<Source> _neededForResolution = null; |
| 871 | 872 |
| 872 /** | 873 /** |
| 873 * A table mapping sources to the change notices that are waiting to be return
ed related to that | 874 * A table mapping sources to the change notices that are waiting to be return
ed related to that |
| 874 * source. | 875 * source. |
| 875 */ | 876 */ |
| 876 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); | 877 HashMap<Source, ChangeNoticeImpl> _pendingNotices = new HashMap<Source, Change
NoticeImpl>(); |
| 877 | 878 |
| 878 /** | 879 /** |
| 879 * A set containing information about the tasks that have been performed since
the last change | 880 * A set containing information about the tasks that have been performed since
the last change |
| 880 * notification. Used to detect infinite loops in [performAnalysisTask]. | 881 * notification. Used to detect infinite loops in [performAnalysisTask]. |
| 881 */ | 882 */ |
| 882 Set<String> _recentTasks = new Set<String>(); | 883 Set<String> _recentTasks = new Set<String>(); |
| 883 | 884 |
| 884 /** | 885 /** |
| 885 * The object used to synchronize access to all of the caches. The rules relat
ed to the use of | 886 * The object used to synchronize access to all of the caches. The rules relat
ed to the use of |
| 886 * this lock object are | 887 * this lock object are |
| (...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3620 } | 3621 } |
| 3621 } | 3622 } |
| 3622 } | 3623 } |
| 3623 | 3624 |
| 3624 /** | 3625 /** |
| 3625 * Invalidate all of the resolution results computed by this context. | 3626 * Invalidate all of the resolution results computed by this context. |
| 3626 * | 3627 * |
| 3627 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 3628 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 3628 */ | 3629 */ |
| 3629 void _invalidateAllLocalResolutionInformation() { | 3630 void _invalidateAllLocalResolutionInformation() { |
| 3630 Map<Source, List<Source>> oldPartMap = new Map<Source, List<Source>>(); | 3631 HashMap<Source, List<Source>> oldPartMap = new HashMap<Source, List<Source>>
(); |
| 3631 MapIterator<Source, SourceEntry> iterator = _privatePartition.iterator(); | 3632 MapIterator<Source, SourceEntry> iterator = _privatePartition.iterator(); |
| 3632 while (iterator.moveNext()) { | 3633 while (iterator.moveNext()) { |
| 3633 Source source = iterator.key; | 3634 Source source = iterator.key; |
| 3634 SourceEntry sourceEntry = iterator.value; | 3635 SourceEntry sourceEntry = iterator.value; |
| 3635 if (sourceEntry is HtmlEntry) { | 3636 if (sourceEntry is HtmlEntry) { |
| 3636 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 3637 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 3637 htmlCopy.invalidateAllResolutionInformation(); | 3638 htmlCopy.invalidateAllResolutionInformation(); |
| 3638 iterator.value = htmlCopy; | 3639 iterator.value = htmlCopy; |
| 3639 } else if (sourceEntry is DartEntry) { | 3640 } else if (sourceEntry is DartEntry) { |
| 3640 DartEntry dartEntry = sourceEntry; | 3641 DartEntry dartEntry = sourceEntry; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4031 * computed from data that is now out-of-date, then the results will not be re
corded. | 4032 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 4032 * | 4033 * |
| 4033 * @param task the task that was performed | 4034 * @param task the task that was performed |
| 4034 * @return an entry containing the computed results | 4035 * @return an entry containing the computed results |
| 4035 * @throws AnalysisException if the results could not be recorded | 4036 * @throws AnalysisException if the results could not be recorded |
| 4036 */ | 4037 */ |
| 4037 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { | 4038 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 4038 Source librarySource = task.libraryElement.source; | 4039 Source librarySource = task.libraryElement.source; |
| 4039 CaughtException thrownException = task.exception; | 4040 CaughtException thrownException = task.exception; |
| 4040 DartEntry libraryEntry = null; | 4041 DartEntry libraryEntry = null; |
| 4041 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; | 4042 HashMap<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap
; |
| 4042 if (hintMap == null) { | 4043 if (hintMap == null) { |
| 4043 // We don't have any information about which sources to mark as invalid ot
her than the library | 4044 // We don't have any information about which sources to mark as invalid ot
her than the library |
| 4044 // source. | 4045 // source. |
| 4045 SourceEntry sourceEntry = _cache.get(librarySource); | 4046 SourceEntry sourceEntry = _cache.get(librarySource); |
| 4046 if (sourceEntry == null) { | 4047 if (sourceEntry == null) { |
| 4047 throw new ObsoleteSourceAnalysisException(librarySource); | 4048 throw new ObsoleteSourceAnalysisException(librarySource); |
| 4048 } else if (sourceEntry is! DartEntry) { | 4049 } else if (sourceEntry is! DartEntry) { |
| 4049 // This shouldn't be possible because we should never have performed the
task if the source | 4050 // This shouldn't be possible because we should never have performed the
task if the source |
| 4050 // didn't represent a Dart file, but check to be safe. | 4051 // didn't represent a Dart file, but check to be safe. |
| 4051 throw new AnalysisException("Internal error: attempting to generate hint
s for non-Dart file as a Dart file: ${librarySource.fullName}"); | 4052 throw new AnalysisException("Internal error: attempting to generate hint
s for non-Dart file as a Dart file: ${librarySource.fullName}"); |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4942 } | 4943 } |
| 4943 | 4944 |
| 4944 /** | 4945 /** |
| 4945 * Remove the given libraries that are keys in the given map from the list of
containing libraries | 4946 * Remove the given libraries that are keys in the given map from the list of
containing libraries |
| 4946 * for each of the parts in the corresponding value. | 4947 * for each of the parts in the corresponding value. |
| 4947 * | 4948 * |
| 4948 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 4949 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 4949 * | 4950 * |
| 4950 * @param oldPartMap the table containing the parts associated with each libra
ry | 4951 * @param oldPartMap the table containing the parts associated with each libra
ry |
| 4951 */ | 4952 */ |
| 4952 void _removeFromPartsUsingMap(Map<Source, List<Source>> oldPartMap) { | 4953 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { |
| 4953 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { | 4954 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { |
| 4954 Source librarySource = entry.getKey(); | 4955 Source librarySource = entry.getKey(); |
| 4955 List<Source> oldParts = entry.getValue(); | 4956 List<Source> oldParts = entry.getValue(); |
| 4956 for (int i = 0; i < oldParts.length; i++) { | 4957 for (int i = 0; i < oldParts.length; i++) { |
| 4957 Source partSource = oldParts[i]; | 4958 Source partSource = oldParts[i]; |
| 4958 if (partSource != librarySource) { | 4959 if (partSource != librarySource) { |
| 4959 DartEntry partEntry = _getReadableDartEntry(partSource); | 4960 DartEntry partEntry = _getReadableDartEntry(partSource); |
| 4960 if (partEntry != null) { | 4961 if (partEntry != null) { |
| 4961 DartEntryImpl partCopy = partEntry.writableCopy; | 4962 DartEntryImpl partCopy = partEntry.writableCopy; |
| 4962 partCopy.removeContainingLibrary(librarySource); | 4963 partCopy.removeContainingLibrary(librarySource); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5254 * Instances of the class `CycleBuilder` are used to construct a list of the lib
raries that | 5255 * Instances of the class `CycleBuilder` are used to construct a list of the lib
raries that |
| 5255 * must be resolved together in order to resolve any one of the libraries. | 5256 * must be resolved together in order to resolve any one of the libraries. |
| 5256 */ | 5257 */ |
| 5257 class AnalysisContextImpl_CycleBuilder { | 5258 class AnalysisContextImpl_CycleBuilder { |
| 5258 final AnalysisContextImpl AnalysisContextImpl_this; | 5259 final AnalysisContextImpl AnalysisContextImpl_this; |
| 5259 | 5260 |
| 5260 /** | 5261 /** |
| 5261 * A table mapping the sources of the defining compilation units of libraries
to the | 5262 * A table mapping the sources of the defining compilation units of libraries
to the |
| 5262 * representation of the library that has the information needed to resolve th
e library. | 5263 * representation of the library that has the information needed to resolve th
e library. |
| 5263 */ | 5264 */ |
| 5264 Map<Source, ResolvableLibrary> _libraryMap = new Map<Source, ResolvableLibrary
>(); | 5265 HashMap<Source, ResolvableLibrary> _libraryMap = new HashMap<Source, Resolvabl
eLibrary>(); |
| 5265 | 5266 |
| 5266 /** | 5267 /** |
| 5267 * The dependency graph used to compute the libraries in the cycle. | 5268 * The dependency graph used to compute the libraries in the cycle. |
| 5268 */ | 5269 */ |
| 5269 DirectedGraph<ResolvableLibrary> _dependencyGraph; | 5270 DirectedGraph<ResolvableLibrary> _dependencyGraph; |
| 5270 | 5271 |
| 5271 /** | 5272 /** |
| 5272 * A list containing the libraries that are ready to be resolved. | 5273 * A list containing the libraries that are ready to be resolved. |
| 5273 */ | 5274 */ |
| 5274 List<ResolvableLibrary> _librariesInCycle; | 5275 List<ResolvableLibrary> _librariesInCycle; |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5777 /** | 5778 /** |
| 5778 * Return an array containing all of the sources in the cache. | 5779 * Return an array containing all of the sources in the cache. |
| 5779 */ | 5780 */ |
| 5780 List<Source> get sources; | 5781 List<Source> get sources; |
| 5781 } | 5782 } |
| 5782 | 5783 |
| 5783 /** | 5784 /** |
| 5784 * Implementation of the [AnalysisContextStatistics]. | 5785 * Implementation of the [AnalysisContextStatistics]. |
| 5785 */ | 5786 */ |
| 5786 class AnalysisContextStatisticsImpl implements AnalysisContextStatistics { | 5787 class AnalysisContextStatisticsImpl implements AnalysisContextStatistics { |
| 5787 Map<String, AnalysisContextStatistics_CacheRow> _dataMap = new Map<String, Ana
lysisContextStatistics_CacheRow>(); | 5788 Map<String, AnalysisContextStatistics_CacheRow> _dataMap = new HashMap<String,
AnalysisContextStatistics_CacheRow>(); |
| 5788 | 5789 |
| 5789 List<Source> _sources = new List<Source>(); | 5790 List<Source> _sources = new List<Source>(); |
| 5790 | 5791 |
| 5791 Set<CaughtException> _exceptions = new Set<CaughtException>(); | 5792 Set<CaughtException> _exceptions = new Set<CaughtException>(); |
| 5792 | 5793 |
| 5793 List<AnalysisContextStatistics_PartitionData> _partitionData; | 5794 List<AnalysisContextStatistics_PartitionData> _partitionData; |
| 5794 | 5795 |
| 5795 void addSource(Source source) { | 5796 void addSource(Source source) { |
| 5796 _sources.add(source); | 5797 _sources.add(source); |
| 5797 } | 5798 } |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5958 } | 5959 } |
| 5959 | 5960 |
| 5960 /** | 5961 /** |
| 5961 * Instances of the class `AnalysisDelta` indicate changes to the types of analy
sis that | 5962 * Instances of the class `AnalysisDelta` indicate changes to the types of analy
sis that |
| 5962 * should be performed. | 5963 * should be performed. |
| 5963 */ | 5964 */ |
| 5964 class AnalysisDelta { | 5965 class AnalysisDelta { |
| 5965 /** | 5966 /** |
| 5966 * A mapping from source to what type of analysis should be performed on that
source. | 5967 * A mapping from source to what type of analysis should be performed on that
source. |
| 5967 */ | 5968 */ |
| 5968 Map<Source, AnalysisLevel> _analysisMap = new Map<Source, AnalysisLevel>(); | 5969 HashMap<Source, AnalysisLevel> _analysisMap = new HashMap<Source, AnalysisLeve
l>(); |
| 5969 | 5970 |
| 5970 /** | 5971 /** |
| 5971 * Return a collection of the sources that have been added. This is equivalent
to calling | 5972 * Return a collection of the sources that have been added. This is equivalent
to calling |
| 5972 * [getAnalysisLevels] and collecting all sources that do not have an analysis
level of | 5973 * [getAnalysisLevels] and collecting all sources that do not have an analysis
level of |
| 5973 * [AnalysisLevel#NONE]. | 5974 * [AnalysisLevel#NONE]. |
| 5974 * | 5975 * |
| 5975 * @return a collection of the sources | 5976 * @return a collection of the sources |
| 5976 */ | 5977 */ |
| 5977 Iterable<Source> get addedSources { | 5978 Iterable<Source> get addedSources { |
| 5978 List<Source> result = new List<Source>(); | 5979 List<Source> result = new List<Source>(); |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7638 Source _coreLibrarySource; | 7639 Source _coreLibrarySource; |
| 7639 | 7640 |
| 7640 /** | 7641 /** |
| 7641 * The object representing the core library. | 7642 * The object representing the core library. |
| 7642 */ | 7643 */ |
| 7643 ResolvableLibrary _coreLibrary; | 7644 ResolvableLibrary _coreLibrary; |
| 7644 | 7645 |
| 7645 /** | 7646 /** |
| 7646 * A table mapping library sources to the information being maintained for tho
se libraries. | 7647 * A table mapping library sources to the information being maintained for tho
se libraries. |
| 7647 */ | 7648 */ |
| 7648 Map<Source, ResolvableLibrary> _libraryMap = new Map<Source, ResolvableLibrary
>(); | 7649 HashMap<Source, ResolvableLibrary> _libraryMap = new HashMap<Source, Resolvabl
eLibrary>(); |
| 7649 | 7650 |
| 7650 /** | 7651 /** |
| 7651 * Initialize a newly created task to perform analysis within the given contex
t. | 7652 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7652 * | 7653 * |
| 7653 * @param context the context in which the task is to be performed | 7654 * @param context the context in which the task is to be performed |
| 7654 * @param targetLibrary the library for which an element model was originally
requested | 7655 * @param targetLibrary the library for which an element model was originally
requested |
| 7655 * @param librariesInCycle the libraries that are part of the cycle to be reso
lved | 7656 * @param librariesInCycle the libraries that are part of the cycle to be reso
lved |
| 7656 */ | 7657 */ |
| 7657 BuildDartElementModelTask(InternalAnalysisContext context, this.targetLibrary,
this.librariesInCycle) : super(context) { | 7658 BuildDartElementModelTask(InternalAnalysisContext context, this.targetLibrary,
this.librariesInCycle) : super(context) { |
| 7658 this._errorListener = new RecordingErrorListener(); | 7659 this._errorListener = new RecordingErrorListener(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7752 /** | 7753 /** |
| 7753 * Every library now has a corresponding [LibraryElement], so it is now possib
le to resolve | 7754 * Every library now has a corresponding [LibraryElement], so it is now possib
le to resolve |
| 7754 * the import and export directives. | 7755 * the import and export directives. |
| 7755 * | 7756 * |
| 7756 * @throws AnalysisException if the defining compilation unit for any of the l
ibraries could not | 7757 * @throws AnalysisException if the defining compilation unit for any of the l
ibraries could not |
| 7757 * be accessed | 7758 * be accessed |
| 7758 */ | 7759 */ |
| 7759 void _buildDirectiveModels() { | 7760 void _buildDirectiveModels() { |
| 7760 AnalysisContext analysisContext = context; | 7761 AnalysisContext analysisContext = context; |
| 7761 for (ResolvableLibrary library in librariesInCycle) { | 7762 for (ResolvableLibrary library in librariesInCycle) { |
| 7762 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle
mentImpl>(); | 7763 HashMap<String, PrefixElementImpl> nameToPrefixMap = new HashMap<String, P
refixElementImpl>(); |
| 7763 List<ImportElement> imports = new List<ImportElement>(); | 7764 List<ImportElement> imports = new List<ImportElement>(); |
| 7764 List<ExportElement> exports = new List<ExportElement>(); | 7765 List<ExportElement> exports = new List<ExportElement>(); |
| 7765 for (Directive directive in library.definingCompilationUnit.directives) { | 7766 for (Directive directive in library.definingCompilationUnit.directives) { |
| 7766 if (directive is ImportDirective) { | 7767 if (directive is ImportDirective) { |
| 7767 ImportDirective importDirective = directive; | 7768 ImportDirective importDirective = directive; |
| 7768 String uriContent = importDirective.uriContent; | 7769 String uriContent = importDirective.uriContent; |
| 7769 if (DartUriResolver.isDartExtUri(uriContent)) { | 7770 if (DartUriResolver.isDartExtUri(uriContent)) { |
| 7770 library.libraryElement.hasExtUri = true; | 7771 library.libraryElement.hasExtUri = true; |
| 7771 } | 7772 } |
| 7772 Source importedSource = importDirective.source; | 7773 Source importedSource = importDirective.source; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7865 LibraryElementImpl libraryElement = builder.buildLibrary2(library); | 7866 LibraryElementImpl libraryElement = builder.buildLibrary2(library); |
| 7866 library.libraryElement = libraryElement; | 7867 library.libraryElement = libraryElement; |
| 7867 } | 7868 } |
| 7868 } | 7869 } |
| 7869 | 7870 |
| 7870 /** | 7871 /** |
| 7871 * Build a table mapping library sources to the resolvable libraries represent
ing those libraries. | 7872 * Build a table mapping library sources to the resolvable libraries represent
ing those libraries. |
| 7872 * | 7873 * |
| 7873 * @return the map that was built | 7874 * @return the map that was built |
| 7874 */ | 7875 */ |
| 7875 Map<Source, ResolvableLibrary> _buildLibraryMap() { | 7876 HashMap<Source, ResolvableLibrary> _buildLibraryMap() { |
| 7876 Map<Source, ResolvableLibrary> libraryMap = new Map<Source, ResolvableLibrar
y>(); | 7877 HashMap<Source, ResolvableLibrary> libraryMap = new HashMap<Source, Resolvab
leLibrary>(); |
| 7877 int libraryCount = librariesInCycle.length; | 7878 int libraryCount = librariesInCycle.length; |
| 7878 for (int i = 0; i < libraryCount; i++) { | 7879 for (int i = 0; i < libraryCount; i++) { |
| 7879 ResolvableLibrary library = librariesInCycle[i]; | 7880 ResolvableLibrary library = librariesInCycle[i]; |
| 7880 library.errorListener = _errorListener; | 7881 library.errorListener = _errorListener; |
| 7881 libraryMap[library.librarySource] = library; | 7882 libraryMap[library.librarySource] = library; |
| 7882 List<ResolvableLibrary> dependencies = library.importsAndExports; | 7883 List<ResolvableLibrary> dependencies = library.importsAndExports; |
| 7883 int dependencyCount = dependencies.length; | 7884 int dependencyCount = dependencies.length; |
| 7884 for (int j = 0; j < dependencyCount; j++) { | 7885 for (int j = 0; j < dependencyCount; j++) { |
| 7885 ResolvableLibrary dependency = dependencies[j]; | 7886 ResolvableLibrary dependency = dependencies[j]; |
| 7886 //dependency.setErrorListener(errorListener); | 7887 //dependency.setErrorListener(errorListener); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7929 } | 7930 } |
| 7930 | 7931 |
| 7931 /** | 7932 /** |
| 7932 * Instances of the class `CachePartition` implement a single partition in an LR
U cache of | 7933 * Instances of the class `CachePartition` implement a single partition in an LR
U cache of |
| 7933 * information related to analysis. | 7934 * information related to analysis. |
| 7934 */ | 7935 */ |
| 7935 abstract class CachePartition { | 7936 abstract class CachePartition { |
| 7936 /** | 7937 /** |
| 7937 * A table mapping the sources known to the context to the information known a
bout the source. | 7938 * A table mapping the sources known to the context to the information known a
bout the source. |
| 7938 */ | 7939 */ |
| 7939 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); | 7940 HashMap<Source, SourceEntry> _sourceMap = new HashMap<Source, SourceEntry>(); |
| 7940 | 7941 |
| 7941 /** | 7942 /** |
| 7942 * The maximum number of sources for which AST structures should be kept in th
e cache. | 7943 * The maximum number of sources for which AST structures should be kept in th
e cache. |
| 7943 */ | 7944 */ |
| 7944 int _maxCacheSize = 0; | 7945 int _maxCacheSize = 0; |
| 7945 | 7946 |
| 7946 /** | 7947 /** |
| 7947 * The policy used to determine which pieces of data to remove from the cache. | 7948 * The policy used to determine which pieces of data to remove from the cache. |
| 7948 */ | 7949 */ |
| 7949 final CacheRetentionPolicy _retentionPolicy; | 7950 final CacheRetentionPolicy _retentionPolicy; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8351 | 8352 |
| 8352 /** | 8353 /** |
| 8353 * A list containing the sources that have been changed. | 8354 * A list containing the sources that have been changed. |
| 8354 */ | 8355 */ |
| 8355 final List<Source> changedSources = new List<Source>(); | 8356 final List<Source> changedSources = new List<Source>(); |
| 8356 | 8357 |
| 8357 /** | 8358 /** |
| 8358 * A table mapping the sources whose content has been changed to the current c
ontent of those | 8359 * A table mapping the sources whose content has been changed to the current c
ontent of those |
| 8359 * sources. | 8360 * sources. |
| 8360 */ | 8361 */ |
| 8361 Map<Source, String> _changedContent = new Map<Source, String>(); | 8362 HashMap<Source, String> _changedContent = new HashMap<Source, String>(); |
| 8362 | 8363 |
| 8363 /** | 8364 /** |
| 8364 * A table mapping the sources whose content has been changed within a single
range to the current | 8365 * A table mapping the sources whose content has been changed within a single
range to the current |
| 8365 * content of those sources and information about the affected range. | 8366 * content of those sources and information about the affected range. |
| 8366 */ | 8367 */ |
| 8367 final Map<Source, ChangeSet_ContentChange> changedRanges = new Map<Source, Cha
ngeSet_ContentChange>(); | 8368 final HashMap<Source, ChangeSet_ContentChange> changedRanges = new HashMap<Sou
rce, ChangeSet_ContentChange>(); |
| 8368 | 8369 |
| 8369 /** | 8370 /** |
| 8370 * A list containing the sources that have been removed. | 8371 * A list containing the sources that have been removed. |
| 8371 */ | 8372 */ |
| 8372 final List<Source> removedSources = new List<Source>(); | 8373 final List<Source> removedSources = new List<Source>(); |
| 8373 | 8374 |
| 8374 /** | 8375 /** |
| 8375 * A list containing the source containers specifying additional sources that
have been removed. | 8376 * A list containing the source containers specifying additional sources that
have been removed. |
| 8376 */ | 8377 */ |
| 8377 final List<SourceContainer> removedContainers = new List<SourceContainer>(); | 8378 final List<SourceContainer> removedContainers = new List<SourceContainer>(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8529 /** | 8530 /** |
| 8530 * Append the given sources to the given builder, prefixed with the given labe
l and possibly a | 8531 * Append the given sources to the given builder, prefixed with the given labe
l and possibly a |
| 8531 * separator. | 8532 * separator. |
| 8532 * | 8533 * |
| 8533 * @param builder the builder to which the sources are to be appended | 8534 * @param builder the builder to which the sources are to be appended |
| 8534 * @param sources the sources to be appended | 8535 * @param sources the sources to be appended |
| 8535 * @param needsSeparator `true` if a separator is needed before the label | 8536 * @param needsSeparator `true` if a separator is needed before the label |
| 8536 * @param label the label used to prefix the sources | 8537 * @param label the label used to prefix the sources |
| 8537 * @return `true` if future lists of sources will need a separator | 8538 * @return `true` if future lists of sources will need a separator |
| 8538 */ | 8539 */ |
| 8539 bool _appendSources2(JavaStringBuilder builder, Map<Source, dynamic> sources,
bool needsSeparator, String label) { | 8540 bool _appendSources2(JavaStringBuilder builder, HashMap<Source, dynamic> sourc
es, bool needsSeparator, String label) { |
| 8540 if (sources.isEmpty) { | 8541 if (sources.isEmpty) { |
| 8541 return needsSeparator; | 8542 return needsSeparator; |
| 8542 } | 8543 } |
| 8543 if (needsSeparator) { | 8544 if (needsSeparator) { |
| 8544 builder.append("; "); | 8545 builder.append("; "); |
| 8545 } | 8546 } |
| 8546 builder.append(label); | 8547 builder.append(label); |
| 8547 String prefix = " "; | 8548 String prefix = " "; |
| 8548 for (Source source in sources.keys.toSet()) { | 8549 for (Source source in sources.keys.toSet()) { |
| 8549 builder.append(prefix); | 8550 builder.append(prefix); |
| (...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10471 | 10472 |
| 10472 /** | 10473 /** |
| 10473 * The element model for the library being analyzed. | 10474 * The element model for the library being analyzed. |
| 10474 */ | 10475 */ |
| 10475 final LibraryElement libraryElement; | 10476 final LibraryElement libraryElement; |
| 10476 | 10477 |
| 10477 /** | 10478 /** |
| 10478 * A table mapping the sources that were analyzed to the hints that were gener
ated for the | 10479 * A table mapping the sources that were analyzed to the hints that were gener
ated for the |
| 10479 * sources. | 10480 * sources. |
| 10480 */ | 10481 */ |
| 10481 Map<Source, TimestampedData<List<AnalysisError>>> _hintMap; | 10482 HashMap<Source, TimestampedData<List<AnalysisError>>> _hintMap; |
| 10482 | 10483 |
| 10483 /** | 10484 /** |
| 10484 * Initialize a newly created task to perform analysis within the given contex
t. | 10485 * Initialize a newly created task to perform analysis within the given contex
t. |
| 10485 * | 10486 * |
| 10486 * @param context the context in which the task is to be performed | 10487 * @param context the context in which the task is to be performed |
| 10487 * @param units the compilation units that comprise the library, with the defi
ning compilation | 10488 * @param units the compilation units that comprise the library, with the defi
ning compilation |
| 10488 * unit appearing first in the array | 10489 * unit appearing first in the array |
| 10489 * @param libraryElement the element model for the library being analyzed | 10490 * @param libraryElement the element model for the library being analyzed |
| 10490 */ | 10491 */ |
| 10491 GenerateDartHintsTask(InternalAnalysisContext context, this._units, this.libra
ryElement) : super(context); | 10492 GenerateDartHintsTask(InternalAnalysisContext context, this._units, this.libra
ryElement) : super(context); |
| 10492 | 10493 |
| 10493 @override | 10494 @override |
| 10494 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); | 10495 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); |
| 10495 | 10496 |
| 10496 /** | 10497 /** |
| 10497 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the | 10498 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the |
| 10498 * sources, or `null` if the task has not been performed or if the analysis di
d not complete | 10499 * sources, or `null` if the task has not been performed or if the analysis di
d not complete |
| 10499 * normally. | 10500 * normally. |
| 10500 * | 10501 * |
| 10501 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the | 10502 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the |
| 10502 * sources | 10503 * sources |
| 10503 */ | 10504 */ |
| 10504 Map<Source, TimestampedData<List<AnalysisError>>> get hintMap => _hintMap; | 10505 HashMap<Source, TimestampedData<List<AnalysisError>>> get hintMap => _hintMap; |
| 10505 | 10506 |
| 10506 @override | 10507 @override |
| 10507 String get taskDescription { | 10508 String get taskDescription { |
| 10508 Source librarySource = libraryElement.source; | 10509 Source librarySource = libraryElement.source; |
| 10509 if (librarySource == null) { | 10510 if (librarySource == null) { |
| 10510 return "generate Dart hints for library without source"; | 10511 return "generate Dart hints for library without source"; |
| 10511 } | 10512 } |
| 10512 return "generate Dart hints for ${librarySource.fullName}"; | 10513 return "generate Dart hints for ${librarySource.fullName}"; |
| 10513 } | 10514 } |
| 10514 | 10515 |
| 10515 @override | 10516 @override |
| 10516 void internalPerform() { | 10517 void internalPerform() { |
| 10517 // | 10518 // |
| 10518 // Gather the compilation units. | 10519 // Gather the compilation units. |
| 10519 // | 10520 // |
| 10520 int unitCount = _units.length; | 10521 int unitCount = _units.length; |
| 10521 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(unitCount
); | 10522 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(unitCount
); |
| 10522 for (int i = 0; i < unitCount; i++) { | 10523 for (int i = 0; i < unitCount; i++) { |
| 10523 compilationUnits[i] = _units[i].data; | 10524 compilationUnits[i] = _units[i].data; |
| 10524 } | 10525 } |
| 10525 // | 10526 // |
| 10526 // Analyze all of the units. | 10527 // Analyze all of the units. |
| 10527 // | 10528 // |
| 10528 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10529 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 10529 HintGenerator hintGenerator = new HintGenerator(compilationUnits, context, e
rrorListener); | 10530 HintGenerator hintGenerator = new HintGenerator(compilationUnits, context, e
rrorListener); |
| 10530 hintGenerator.generateForLibrary(); | 10531 hintGenerator.generateForLibrary(); |
| 10531 // | 10532 // |
| 10532 // Store the results. | 10533 // Store the results. |
| 10533 // | 10534 // |
| 10534 _hintMap = new Map<Source, TimestampedData<List<AnalysisError>>>(); | 10535 _hintMap = new HashMap<Source, TimestampedData<List<AnalysisError>>>(); |
| 10535 for (int i = 0; i < unitCount; i++) { | 10536 for (int i = 0; i < unitCount; i++) { |
| 10536 int modificationTime = _units[i].modificationTime; | 10537 int modificationTime = _units[i].modificationTime; |
| 10537 Source source = _units[i].data.element.source; | 10538 Source source = _units[i].data.element.source; |
| 10538 List<AnalysisError> errors = errorListener.getErrorsForSource(source); | 10539 List<AnalysisError> errors = errorListener.getErrorsForSource(source); |
| 10539 _hintMap[source] = new TimestampedData<List<AnalysisError>>(modificationTi
me, errors); | 10540 _hintMap[source] = new TimestampedData<List<AnalysisError>>(modificationTi
me, errors); |
| 10540 } | 10541 } |
| 10541 } | 10542 } |
| 10542 } | 10543 } |
| 10543 | 10544 |
| 10544 /** | 10545 /** |
| (...skipping 2519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13064 } | 13065 } |
| 13065 | 13066 |
| 13066 /** | 13067 /** |
| 13067 * Instances of the class `PartitionManager` manage the partitions that can be s
hared between | 13068 * Instances of the class `PartitionManager` manage the partitions that can be s
hared between |
| 13068 * analysis contexts. | 13069 * analysis contexts. |
| 13069 */ | 13070 */ |
| 13070 class PartitionManager { | 13071 class PartitionManager { |
| 13071 /** | 13072 /** |
| 13072 * A table mapping SDK's to the partitions used for those SDK's. | 13073 * A table mapping SDK's to the partitions used for those SDK's. |
| 13073 */ | 13074 */ |
| 13074 Map<DartSdk, SdkCachePartition> _sdkPartitions = new Map<DartSdk, SdkCachePart
ition>(); | 13075 HashMap<DartSdk, SdkCachePartition> _sdkPartitions = new HashMap<DartSdk, SdkC
achePartition>(); |
| 13075 | 13076 |
| 13076 /** | 13077 /** |
| 13077 * The default cache size for a Dart SDK partition. | 13078 * The default cache size for a Dart SDK partition. |
| 13078 */ | 13079 */ |
| 13079 static int _DEFAULT_SDK_CACHE_SIZE = 256; | 13080 static int _DEFAULT_SDK_CACHE_SIZE = 256; |
| 13080 | 13081 |
| 13081 /** | 13082 /** |
| 13082 * Return the partition being used for the given SDK, creating the partition i
f necessary. | 13083 * Return the partition being used for the given SDK, creating the partition i
f necessary. |
| 13083 * | 13084 * |
| 13084 * @param sdk the SDK for which a partition is being requested | 13085 * @param sdk the SDK for which a partition is being requested |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13647 | 13648 |
| 13648 /** | 13649 /** |
| 13649 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will | 13650 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will |
| 13650 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors | 13651 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors |
| 13651 * within an analysis context. | 13652 * within an analysis context. |
| 13652 */ | 13653 */ |
| 13653 class RecordingErrorListener implements AnalysisErrorListener { | 13654 class RecordingErrorListener implements AnalysisErrorListener { |
| 13654 /** | 13655 /** |
| 13655 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. | 13656 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. |
| 13656 */ | 13657 */ |
| 13657 Map<Source, Set<AnalysisError>> _errors = new Map<Source, Set<AnalysisError>>(
); | 13658 Map<Source, Set<AnalysisError>> _errors = new HashMap<Source, Set<AnalysisErro
r>>(); |
| 13658 | 13659 |
| 13659 /** | 13660 /** |
| 13660 * Add all of the errors recorded by the given listener to this listener. | 13661 * Add all of the errors recorded by the given listener to this listener. |
| 13661 * | 13662 * |
| 13662 * @param listener the listener that has recorded the errors to be added | 13663 * @param listener the listener that has recorded the errors to be added |
| 13663 */ | 13664 */ |
| 13664 void addAll(RecordingErrorListener listener) { | 13665 void addAll(RecordingErrorListener listener) { |
| 13665 for (AnalysisError error in listener.errors) { | 13666 for (AnalysisError error in listener.errors) { |
| 13666 onError(error); | 13667 onError(error); |
| 13667 } | 13668 } |
| (...skipping 1699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15367 _index++; | 15368 _index++; |
| 15368 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { | 15369 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { |
| 15369 _index = 0; | 15370 _index = 0; |
| 15370 _queueIndex++; | 15371 _queueIndex++; |
| 15371 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th
is._workQueues[_queueIndex].isEmpty) { | 15372 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th
is._workQueues[_queueIndex].isEmpty) { |
| 15372 _queueIndex++; | 15373 _queueIndex++; |
| 15373 } | 15374 } |
| 15374 } | 15375 } |
| 15375 } | 15376 } |
| 15376 } | 15377 } |
| OLD | NEW |