| 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:async'; | 10 import 'dart:async'; |
| (...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2498 source, contents, offset, oldLength, newLength)); | 2498 source, contents, offset, oldLength, newLength)); |
| 2499 } | 2499 } |
| 2500 } | 2500 } |
| 2501 | 2501 |
| 2502 @override | 2502 @override |
| 2503 void setContents(Source source, String contents) { | 2503 void setContents(Source source, String contents) { |
| 2504 _contentsChanged(source, contents, true); | 2504 _contentsChanged(source, contents, true); |
| 2505 } | 2505 } |
| 2506 | 2506 |
| 2507 @override | 2507 @override |
| 2508 bool shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) { |
| 2509 if (source.isInSystemLibrary) { |
| 2510 return _generateSdkErrors; |
| 2511 } else if (!dartEntry.explicitlyAdded) { |
| 2512 return _generateImplicitErrors; |
| 2513 } else { |
| 2514 return true; |
| 2515 } |
| 2516 } |
| 2517 |
| 2518 @override |
| 2508 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 2519 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
| 2509 DataDescriptor rowDesc, CacheState state)) { | 2520 DataDescriptor rowDesc, CacheState state)) { |
| 2510 bool hintsEnabled = _options.hint; | 2521 bool hintsEnabled = _options.hint; |
| 2511 bool lintsEnabled = _options.lint; | 2522 bool lintsEnabled = _options.lint; |
| 2512 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 2523 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
| 2513 while (iterator.moveNext()) { | 2524 while (iterator.moveNext()) { |
| 2514 Source source = iterator.key; | 2525 Source source = iterator.key; |
| 2515 SourceEntry sourceEntry = iterator.value; | 2526 SourceEntry sourceEntry = iterator.value; |
| 2516 for (DataDescriptor descriptor in sourceEntry.descriptors) { | 2527 for (DataDescriptor descriptor in sourceEntry.descriptors) { |
| 2517 if (descriptor == DartEntry.SOURCE_KIND) { | 2528 if (descriptor == DartEntry.SOURCE_KIND) { |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3630 // | 3641 // |
| 3631 // LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); | 3642 // LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); |
| 3632 // if (libraryElement != null) { | 3643 // if (libraryElement != null) { |
| 3633 // return new ResolveDartUnitTask(this, source, libraryElement); | 3644 // return new ResolveDartUnitTask(this, source, libraryElement); |
| 3634 // } | 3645 // } |
| 3635 // Possibly replace with: | 3646 // Possibly replace with: |
| 3636 // return createResolveDartLibraryTask(librarySource, (DartEntry) li
braryEntry); | 3647 // return createResolveDartLibraryTask(librarySource, (DartEntry) li
braryEntry); |
| 3637 return new AnalysisContextImpl_TaskData( | 3648 return new AnalysisContextImpl_TaskData( |
| 3638 new ResolveDartLibraryTask(this, source, librarySource), false); | 3649 new ResolveDartLibraryTask(this, source, librarySource), false); |
| 3639 } | 3650 } |
| 3640 if (_shouldErrorsBeAnalyzed(source, dartEntry)) { | 3651 if (shouldErrorsBeAnalyzed(source, dartEntry)) { |
| 3641 CacheState verificationErrorsState = dartEntry.getStateInLibrary( | 3652 CacheState verificationErrorsState = dartEntry.getStateInLibrary( |
| 3642 DartEntry.VERIFICATION_ERRORS, librarySource); | 3653 DartEntry.VERIFICATION_ERRORS, librarySource); |
| 3643 if (verificationErrorsState == CacheState.INVALID || | 3654 if (verificationErrorsState == CacheState.INVALID || |
| 3644 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { | 3655 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { |
| 3645 return _createGenerateDartErrorsTask( | 3656 return _createGenerateDartErrorsTask( |
| 3646 source, dartEntry, librarySource, libraryEntry); | 3657 source, dartEntry, librarySource, libraryEntry); |
| 3647 } | 3658 } |
| 3648 if (hintsEnabled) { | 3659 if (hintsEnabled) { |
| 3649 CacheState hintsState = | 3660 CacheState hintsState = |
| 3650 dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource); | 3661 dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3812 DartEntry.RESOLVED_UNIT, librarySource); | 3823 DartEntry.RESOLVED_UNIT, librarySource); |
| 3813 if (resolvedUnitState == CacheState.INVALID || | 3824 if (resolvedUnitState == CacheState.INVALID || |
| 3814 (isPriority && resolvedUnitState == CacheState.FLUSHED)) { | 3825 (isPriority && resolvedUnitState == CacheState.FLUSHED)) { |
| 3815 LibraryElement libraryElement = | 3826 LibraryElement libraryElement = |
| 3816 libraryEntry.getValue(DartEntry.ELEMENT); | 3827 libraryEntry.getValue(DartEntry.ELEMENT); |
| 3817 if (libraryElement != null) { | 3828 if (libraryElement != null) { |
| 3818 sources.add(source); | 3829 sources.add(source); |
| 3819 return; | 3830 return; |
| 3820 } | 3831 } |
| 3821 } | 3832 } |
| 3822 if (_shouldErrorsBeAnalyzed(source, dartEntry)) { | 3833 if (shouldErrorsBeAnalyzed(source, dartEntry)) { |
| 3823 CacheState verificationErrorsState = dartEntry.getStateInLibrary( | 3834 CacheState verificationErrorsState = dartEntry.getStateInLibrary( |
| 3824 DartEntry.VERIFICATION_ERRORS, librarySource); | 3835 DartEntry.VERIFICATION_ERRORS, librarySource); |
| 3825 if (verificationErrorsState == CacheState.INVALID || | 3836 if (verificationErrorsState == CacheState.INVALID || |
| 3826 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { | 3837 (isPriority && verificationErrorsState == CacheState.FLUSHED)) { |
| 3827 LibraryElement libraryElement = | 3838 LibraryElement libraryElement = |
| 3828 libraryEntry.getValue(DartEntry.ELEMENT); | 3839 libraryEntry.getValue(DartEntry.ELEMENT); |
| 3829 if (libraryElement != null) { | 3840 if (libraryElement != null) { |
| 3830 sources.add(source); | 3841 sources.add(source); |
| 3831 return; | 3842 return; |
| 3832 } | 3843 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3986 * given [source] has been updated to the given [errors]. | 3997 * given [source] has been updated to the given [errors]. |
| 3987 */ | 3998 */ |
| 3988 void _notifyErrors( | 3999 void _notifyErrors( |
| 3989 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 4000 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
| 3990 int count = _listeners.length; | 4001 int count = _listeners.length; |
| 3991 for (int i = 0; i < count; i++) { | 4002 for (int i = 0; i < count; i++) { |
| 3992 _listeners[i].computedErrors(this, source, errors, lineInfo); | 4003 _listeners[i].computedErrors(this, source, errors, lineInfo); |
| 3993 } | 4004 } |
| 3994 } | 4005 } |
| 3995 | 4006 |
| 3996 /** | |
| 3997 * Given that the given [source] (with the corresponding [sourceEntry]) has | |
| 3998 * been invalidated, invalidate all of the libraries that depend on it. | |
| 3999 */ | |
| 4000 void _propagateInvalidation(Source source, SourceEntry sourceEntry) { | |
| 4001 if (sourceEntry is HtmlEntry) { | |
| 4002 HtmlEntry htmlEntry = sourceEntry; | |
| 4003 htmlEntry.modificationTime = getModificationStamp(source); | |
| 4004 htmlEntry.invalidateAllInformation(); | |
| 4005 _cache.removedAst(source); | |
| 4006 _workManager.add(source, SourcePriority.HTML); | |
| 4007 } else if (sourceEntry is DartEntry) { | |
| 4008 List<Source> containingLibraries = getLibrariesContaining(source); | |
| 4009 List<Source> dependentLibraries = getLibrariesDependingOn(source); | |
| 4010 HashSet<Source> librariesToInvalidate = new HashSet<Source>(); | |
| 4011 for (Source containingLibrary in containingLibraries) { | |
| 4012 _computeAllLibrariesDependingOn( | |
| 4013 containingLibrary, librariesToInvalidate); | |
| 4014 } | |
| 4015 for (Source dependentLibrary in dependentLibraries) { | |
| 4016 _computeAllLibrariesDependingOn( | |
| 4017 dependentLibrary, librariesToInvalidate); | |
| 4018 } | |
| 4019 for (Source library in librariesToInvalidate) { | |
| 4020 _invalidateLibraryResolution(library); | |
| 4021 } | |
| 4022 DartEntry dartEntry = _cache.get(source); | |
| 4023 _removeFromParts(source, dartEntry); | |
| 4024 dartEntry.modificationTime = getModificationStamp(source); | |
| 4025 dartEntry.invalidateAllInformation(); | |
| 4026 _cache.removedAst(source); | |
| 4027 _workManager.add(source, SourcePriority.UNKNOWN); | |
| 4028 } | |
| 4029 // reset unit in the notification, it is out of date now | |
| 4030 ChangeNoticeImpl notice = _pendingNotices[source]; | |
| 4031 if (notice != null) { | |
| 4032 notice.resolvedDartUnit = null; | |
| 4033 notice.resolvedHtmlUnit = null; | |
| 4034 } | |
| 4035 } | |
| 4036 | |
| 4037 // /** | 4007 // /** |
| 4038 // * Notify all of the analysis listeners that the given source is no longer i
ncluded in the set of | 4008 // * Notify all of the analysis listeners that the given source is no longer i
ncluded in the set of |
| 4039 // * sources that are being analyzed. | 4009 // * sources that are being analyzed. |
| 4040 // * | 4010 // * |
| 4041 // * @param source the source that is no longer being analyzed | 4011 // * @param source the source that is no longer being analyzed |
| 4042 // */ | 4012 // */ |
| 4043 // void _notifyExcludedSource(Source source) { | 4013 // void _notifyExcludedSource(Source source) { |
| 4044 // int count = _listeners.length; | 4014 // int count = _listeners.length; |
| 4045 // for (int i = 0; i < count; i++) { | 4015 // for (int i = 0; i < count; i++) { |
| 4046 // _listeners[i].excludedSource(this, source); | 4016 // _listeners[i].excludedSource(this, source); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4106 // * @param unit the result of resolving the source | 4076 // * @param unit the result of resolving the source |
| 4107 // */ | 4077 // */ |
| 4108 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { | 4078 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { |
| 4109 // int count = _listeners.length; | 4079 // int count = _listeners.length; |
| 4110 // for (int i = 0; i < count; i++) { | 4080 // for (int i = 0; i < count; i++) { |
| 4111 // _listeners[i].resolvedHtml(this, source, unit); | 4081 // _listeners[i].resolvedHtml(this, source, unit); |
| 4112 // } | 4082 // } |
| 4113 // } | 4083 // } |
| 4114 | 4084 |
| 4115 /** | 4085 /** |
| 4086 * Given that the given [source] (with the corresponding [sourceEntry]) has |
| 4087 * been invalidated, invalidate all of the libraries that depend on it. |
| 4088 */ |
| 4089 void _propagateInvalidation(Source source, SourceEntry sourceEntry) { |
| 4090 if (sourceEntry is HtmlEntry) { |
| 4091 HtmlEntry htmlEntry = sourceEntry; |
| 4092 htmlEntry.modificationTime = getModificationStamp(source); |
| 4093 htmlEntry.invalidateAllInformation(); |
| 4094 _cache.removedAst(source); |
| 4095 _workManager.add(source, SourcePriority.HTML); |
| 4096 } else if (sourceEntry is DartEntry) { |
| 4097 List<Source> containingLibraries = getLibrariesContaining(source); |
| 4098 List<Source> dependentLibraries = getLibrariesDependingOn(source); |
| 4099 HashSet<Source> librariesToInvalidate = new HashSet<Source>(); |
| 4100 for (Source containingLibrary in containingLibraries) { |
| 4101 _computeAllLibrariesDependingOn( |
| 4102 containingLibrary, librariesToInvalidate); |
| 4103 } |
| 4104 for (Source dependentLibrary in dependentLibraries) { |
| 4105 _computeAllLibrariesDependingOn( |
| 4106 dependentLibrary, librariesToInvalidate); |
| 4107 } |
| 4108 for (Source library in librariesToInvalidate) { |
| 4109 _invalidateLibraryResolution(library); |
| 4110 } |
| 4111 DartEntry dartEntry = _cache.get(source); |
| 4112 _removeFromParts(source, dartEntry); |
| 4113 dartEntry.modificationTime = getModificationStamp(source); |
| 4114 dartEntry.invalidateAllInformation(); |
| 4115 _cache.removedAst(source); |
| 4116 _workManager.add(source, SourcePriority.UNKNOWN); |
| 4117 } |
| 4118 // reset unit in the notification, it is out of date now |
| 4119 ChangeNoticeImpl notice = _pendingNotices[source]; |
| 4120 if (notice != null) { |
| 4121 notice.resolvedDartUnit = null; |
| 4122 notice.resolvedHtmlUnit = null; |
| 4123 } |
| 4124 } |
| 4125 |
| 4126 /** |
| 4116 * Record the results produced by performing a [task] and return the cache | 4127 * Record the results produced by performing a [task] and return the cache |
| 4117 * entry associated with the results. | 4128 * entry associated with the results. |
| 4118 */ | 4129 */ |
| 4119 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) { | 4130 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) { |
| 4120 Source source = task.source; | 4131 Source source = task.source; |
| 4121 Source library = task.library; | 4132 Source library = task.library; |
| 4122 DartEntry dartEntry = _cache.get(source); | 4133 DartEntry dartEntry = _cache.get(source); |
| 4123 CaughtException thrownException = task.exception; | 4134 CaughtException thrownException = task.exception; |
| 4124 if (thrownException != null) { | 4135 if (thrownException != null) { |
| 4125 dartEntry.recordBuildElementErrorInLibrary(library, thrownException); | 4136 dartEntry.recordBuildElementErrorInLibrary(library, thrownException); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4504 if (_priorityOrder[i] != source) { | 4515 if (_priorityOrder[i] != source) { |
| 4505 newOrder.add(_priorityOrder[i]); | 4516 newOrder.add(_priorityOrder[i]); |
| 4506 } | 4517 } |
| 4507 } | 4518 } |
| 4508 if (newOrder.length < count) { | 4519 if (newOrder.length < count) { |
| 4509 analysisPriorityOrder = newOrder; | 4520 analysisPriorityOrder = newOrder; |
| 4510 } | 4521 } |
| 4511 } | 4522 } |
| 4512 | 4523 |
| 4513 /** | 4524 /** |
| 4514 * Return `true` if errors should be produced for the given [source]. The | |
| 4515 * [dartEntry] associated with the source is passed in for efficiency. | |
| 4516 */ | |
| 4517 bool _shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) { | |
| 4518 if (source.isInSystemLibrary) { | |
| 4519 return _generateSdkErrors; | |
| 4520 } else if (!dartEntry.explicitlyAdded) { | |
| 4521 return _generateImplicitErrors; | |
| 4522 } else { | |
| 4523 return true; | |
| 4524 } | |
| 4525 } | |
| 4526 | |
| 4527 /** | |
| 4528 * Create an entry for the newly added [source] and invalidate any sources | 4525 * Create an entry for the newly added [source] and invalidate any sources |
| 4529 * that referenced the source before it existed. | 4526 * that referenced the source before it existed. |
| 4530 */ | 4527 */ |
| 4531 void _sourceAvailable(Source source) { | 4528 void _sourceAvailable(Source source) { |
| 4532 SourceEntry sourceEntry = _cache.get(source); | 4529 SourceEntry sourceEntry = _cache.get(source); |
| 4533 if (sourceEntry == null) { | 4530 if (sourceEntry == null) { |
| 4534 sourceEntry = _createSourceEntry(source, true); | 4531 sourceEntry = _createSourceEntry(source, true); |
| 4535 } else { | 4532 } else { |
| 4536 _propagateInvalidation(source, sourceEntry); | 4533 _propagateInvalidation(source, sourceEntry); |
| 4537 sourceEntry = _cache.get(source); | 4534 sourceEntry = _cache.get(source); |
| (...skipping 4623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9161 Source source, String originalContents, String newContents, bool notify); | 9158 Source source, String originalContents, String newContents, bool notify); |
| 9162 | 9159 |
| 9163 /** | 9160 /** |
| 9164 * Given an [elementMap] mapping the source for the libraries represented by | 9161 * Given an [elementMap] mapping the source for the libraries represented by |
| 9165 * the corresponding elements to the elements representing the libraries, | 9162 * the corresponding elements to the elements representing the libraries, |
| 9166 * record those mappings. | 9163 * record those mappings. |
| 9167 */ | 9164 */ |
| 9168 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 9165 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
| 9169 | 9166 |
| 9170 /** | 9167 /** |
| 9168 * Return `true` if errors should be produced for the given [source]. |
| 9169 * The [entry] associated with the source is passed in for efficiency. |
| 9170 * |
| 9171 * TODO(scheglov) remove [entry] after migration to the new task model. |
| 9172 * It is not used there anyway. |
| 9173 */ |
| 9174 bool shouldErrorsBeAnalyzed(Source source, Object entry); |
| 9175 |
| 9176 /** |
| 9171 * Call the given callback function for eache cache item in the context. | 9177 * Call the given callback function for eache cache item in the context. |
| 9172 */ | 9178 */ |
| 9173 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 9179 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
| 9174 DataDescriptor rowDesc, CacheState state)); | 9180 DataDescriptor rowDesc, CacheState state)); |
| 9175 } | 9181 } |
| 9176 | 9182 |
| 9177 /** | 9183 /** |
| 9178 * An object that can be used to receive information about errors within the | 9184 * An object that can be used to receive information about errors within the |
| 9179 * analysis engine. Implementations usually write this information to a file, | 9185 * analysis engine. Implementations usually write this information to a file, |
| 9180 * but can also record the information for later use (such as during testing) or | 9186 * but can also record the information for later use (such as during testing) or |
| (...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11694 PendingFuture pendingFuture = | 11700 PendingFuture pendingFuture = |
| 11695 new PendingFuture<T>(_context, source, computeValue); | 11701 new PendingFuture<T>(_context, source, computeValue); |
| 11696 if (!pendingFuture.evaluate(sourceEntry)) { | 11702 if (!pendingFuture.evaluate(sourceEntry)) { |
| 11697 _context._pendingFutureSources | 11703 _context._pendingFutureSources |
| 11698 .putIfAbsent(source, () => <PendingFuture>[]) | 11704 .putIfAbsent(source, () => <PendingFuture>[]) |
| 11699 .add(pendingFuture); | 11705 .add(pendingFuture); |
| 11700 } | 11706 } |
| 11701 return pendingFuture.future; | 11707 return pendingFuture.future; |
| 11702 } | 11708 } |
| 11703 } | 11709 } |
| OLD | NEW |