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 'java_core.dart'; | 10 import 'java_core.dart'; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 * @return all of the errors associated with the given source | 232 * @return all of the errors associated with the given source |
233 * @throws AnalysisException if the errors could not be determined because the
analysis could not | 233 * @throws AnalysisException if the errors could not be determined because the
analysis could not |
234 * be performed | 234 * be performed |
235 * @see #getErrors(Source) | 235 * @see #getErrors(Source) |
236 */ | 236 */ |
237 List<AnalysisError> computeErrors(Source source); | 237 List<AnalysisError> computeErrors(Source source); |
238 | 238 |
239 /** | 239 /** |
240 * Return the element model corresponding to the HTML file defined by the give
n source. If the | 240 * Return the element model corresponding to the HTML file defined by the give
n source. If the |
241 * element model does not yet exist it will be created. The process of creatin
g an element model | 241 * element model does not yet exist it will be created. The process of creatin
g an element model |
242 * for an HTML file can long-running, depending on the size of the file and th
e number of | 242 * for an HTML file can be long-running, depending on the size of the file and
the number of |
243 * libraries that are defined in it (via script tags) that also need to have a
model built for | 243 * libraries that are defined in it (via script tags) that also need to have a
model built for |
244 * them. | 244 * them. |
245 * | 245 * |
246 * <b>Note:</b> This method cannot be used in an async environment. | 246 * <b>Note:</b> This method cannot be used in an async environment. |
247 * | 247 * |
248 * @param source the source defining the HTML file whose element model is to b
e returned | 248 * @param source the source defining the HTML file whose element model is to b
e returned |
249 * @return the element model corresponding to the HTML file defined by the giv
en source | 249 * @return the element model corresponding to the HTML file defined by the giv
en source |
250 * @throws AnalysisException if the element model could not be determined beca
use the analysis | 250 * @throws AnalysisException if the element model could not be determined beca
use the analysis |
251 * could not be performed | 251 * could not be performed |
252 * @see #getHtmlElement(Source) | 252 * @see #getHtmlElement(Source) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 /** | 327 /** |
328 * Return the set of analysis options controlling the behavior of this context
. Clients should not | 328 * Return the set of analysis options controlling the behavior of this context
. Clients should not |
329 * modify the returned set of options. The options should only be set by invok
ing the method | 329 * modify the returned set of options. The options should only be set by invok
ing the method |
330 * [setAnalysisOptions]. | 330 * [setAnalysisOptions]. |
331 * | 331 * |
332 * @return the set of analysis options controlling the behavior of this contex
t | 332 * @return the set of analysis options controlling the behavior of this contex
t |
333 */ | 333 */ |
334 AnalysisOptions get analysisOptions; | 334 AnalysisOptions get analysisOptions; |
335 | 335 |
336 /** | 336 /** |
| 337 * Return the Angular application that contains the HTML file defined by the g
iven source, or |
| 338 * `null` if the source does not represent an HTML file, the Angular applicati
on containing |
| 339 * the file has not yet been resolved, or the analysis of the HTML file failed
for some reason. |
| 340 * |
| 341 * @param htmlSource the source defining the HTML file |
| 342 * @return the Angular application that contains the HTML file defined by the
given source |
| 343 */ |
| 344 AngularApplication getAngularApplicationWithHtml(Source htmlSource); |
| 345 |
| 346 /** |
337 * Return the element model corresponding to the compilation unit defined by t
he given source in | 347 * Return the element model corresponding to the compilation unit defined by t
he given source in |
338 * the library defined by the given source, or `null` if the element model doe
s not | 348 * the library defined by the given source, or `null` if the element model doe
s not |
339 * currently exist or if the library cannot be analyzed for some reason. | 349 * currently exist or if the library cannot be analyzed for some reason. |
340 * | 350 * |
341 * @param unitSource the source of the compilation unit | 351 * @param unitSource the source of the compilation unit |
342 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 352 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
343 * compilation unit | 353 * compilation unit |
344 * @return the element model corresponding to the compilation unit defined by
the given source | 354 * @return the element model corresponding to the compilation unit defined by
the given source |
345 */ | 355 */ |
346 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource); | 356 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 * Return the sources for the defining compilation units of any libraries that
depend on the given | 469 * Return the sources for the defining compilation units of any libraries that
depend on the given |
460 * library. One library depends on another if it either imports or exports tha
t library. | 470 * library. One library depends on another if it either imports or exports tha
t library. |
461 * | 471 * |
462 * @param librarySource the source for the defining compilation unit of the li
brary being depended | 472 * @param librarySource the source for the defining compilation unit of the li
brary being depended |
463 * on | 473 * on |
464 * @return the sources for the libraries that depend on the given library | 474 * @return the sources for the libraries that depend on the given library |
465 */ | 475 */ |
466 List<Source> getLibrariesDependingOn(Source librarySource); | 476 List<Source> getLibrariesDependingOn(Source librarySource); |
467 | 477 |
468 /** | 478 /** |
| 479 * Return the sources for the defining compilation units of any libraries that
are referenced from |
| 480 * the given HTML file. |
| 481 * |
| 482 * @param htmlSource the source for the HTML file |
| 483 * @return the sources for the libraries that are referenced by the given HTML
file |
| 484 */ |
| 485 List<Source> getLibrariesReferencedFromHtml(Source htmlSource); |
| 486 |
| 487 /** |
469 * Return the element model corresponding to the library defined by the given
source, or | 488 * Return the element model corresponding to the library defined by the given
source, or |
470 * `null` if the element model does not currently exist or if the library cann
ot be analyzed | 489 * `null` if the element model does not currently exist or if the library cann
ot be analyzed |
471 * for some reason. | 490 * for some reason. |
472 * | 491 * |
473 * @param source the source defining the library whose element model is to be
returned | 492 * @param source the source defining the library whose element model is to be
returned |
474 * @return the element model corresponding to the library defined by the given
source | 493 * @return the element model corresponding to the library defined by the given
source |
475 */ | 494 */ |
476 LibraryElement getLibraryElement(Source source); | 495 LibraryElement getLibraryElement(Source source); |
477 | 496 |
478 /** | 497 /** |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 * information about the consequent changes to the analysis results. This meth
od can be long | 652 * information about the consequent changes to the analysis results. This meth
od can be long |
634 * running. | 653 * running. |
635 * | 654 * |
636 * @return the results of performing the analysis | 655 * @return the results of performing the analysis |
637 */ | 656 */ |
638 AnalysisResult performAnalysisTask(); | 657 AnalysisResult performAnalysisTask(); |
639 | 658 |
640 /** | 659 /** |
641 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 660 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
642 * | 661 * |
| 662 * <b>Note:</b> This method cannot be used in an async environment. |
| 663 * |
643 * @param unitSource the source to be parsed and resolved | 664 * @param unitSource the source to be parsed and resolved |
644 * @param library the library containing the source to be resolved | 665 * @param library the library containing the source to be resolved |
645 * @return the result of resolving the AST structure representing the content
of the source in the | 666 * @return the result of resolving the AST structure representing the content
of the source in the |
646 * context of the given library | 667 * context of the given library |
647 * @throws AnalysisException if the analysis could not be performed | 668 * @throws AnalysisException if the analysis could not be performed |
648 * @see #getResolvedCompilationUnit(Source, LibraryElement) | 669 * @see #getResolvedCompilationUnit(Source, LibraryElement) |
649 */ | 670 */ |
650 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry); | 671 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry); |
651 | 672 |
652 /** | 673 /** |
653 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 674 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
654 * Return the resolved AST structure, or `null` if the source could not be eit
her parsed or | 675 * Return the resolved AST structure, or `null` if the source could not be eit
her parsed or |
655 * resolved. | 676 * resolved. |
656 * | 677 * |
| 678 * <b>Note:</b> This method cannot be used in an async environment. |
| 679 * |
657 * @param unitSource the source to be parsed and resolved | 680 * @param unitSource the source to be parsed and resolved |
658 * @param librarySource the source of the defining compilation unit of the lib
rary containing the | 681 * @param librarySource the source of the defining compilation unit of the lib
rary containing the |
659 * source to be resolved | 682 * source to be resolved |
660 * @return the result of resolving the AST structure representing the content
of the source in the | 683 * @return the result of resolving the AST structure representing the content
of the source in the |
661 * context of the given library | 684 * context of the given library |
662 * @throws AnalysisException if the analysis could not be performed | 685 * @throws AnalysisException if the analysis could not be performed |
663 * @see #getResolvedCompilationUnit(Source, Source) | 686 * @see #getResolvedCompilationUnit(Source, Source) |
664 */ | 687 */ |
665 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e); | 688 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e); |
666 | 689 |
667 /** | 690 /** |
668 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. | 691 * Parse and resolve a single source within the given context to produce a ful
ly resolved AST. |
669 * | 692 * |
| 693 * <b>Note:</b> This method cannot be used in an async environment. |
| 694 * |
670 * @param htmlSource the source to be parsed and resolved | 695 * @param htmlSource the source to be parsed and resolved |
671 * @return the result of resolving the AST structure representing the content
of the source | 696 * @return the result of resolving the AST structure representing the content
of the source |
672 * @throws AnalysisException if the analysis could not be performed | 697 * @throws AnalysisException if the analysis could not be performed |
673 */ | 698 */ |
674 ht.HtmlUnit resolveHtmlUnit(Source htmlSource); | 699 ht.HtmlUnit resolveHtmlUnit(Source htmlSource); |
675 | 700 |
676 /** | 701 /** |
677 * Set the set of analysis options controlling the behavior of this context to
the given options. | 702 * Set the set of analysis options controlling the behavior of this context to
the given options. |
678 * Clients can safely assume that all necessary analysis results have been inv
alidated. | 703 * Clients can safely assume that all necessary analysis results have been inv
alidated. |
679 * | 704 * |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 _sourceMap[removedSource] = dartCopy; | 1296 _sourceMap[removedSource] = dartCopy; |
1272 } | 1297 } |
1273 return true; | 1298 return true; |
1274 } | 1299 } |
1275 | 1300 |
1276 /** | 1301 /** |
1277 * Remove and return one source from the list of recently used sources whose A
ST structure can be | 1302 * Remove and return one source from the list of recently used sources whose A
ST structure can be |
1278 * flushed from the cache. The source that will be returned will be the source
that has been | 1303 * flushed from the cache. The source that will be returned will be the source
that has been |
1279 * unreferenced for the longest period of time but that is not a priority for
analysis. | 1304 * unreferenced for the longest period of time but that is not a priority for
analysis. |
1280 * | 1305 * |
| 1306 * It is possible for there to be no AST that can be flushed, in which case `n
ull` will be |
| 1307 * returned. This happens, for example, if the context is reserving the AST's
needed to resolve a |
| 1308 * cycle of libraries and the number of AST's being reserved is larger than th
e current cache |
| 1309 * size. |
| 1310 * |
1281 * @return the source that was removed | 1311 * @return the source that was removed |
1282 */ | 1312 */ |
1283 Source _removeAstToFlush() { | 1313 Source _removeAstToFlush() { |
1284 int sourceToRemove = -1; | 1314 int sourceToRemove = -1; |
1285 for (int i = 0; i < _recentlyUsed.length; i++) { | 1315 for (int i = 0; i < _recentlyUsed.length; i++) { |
1286 Source source = _recentlyUsed[i]; | 1316 Source source = _recentlyUsed[i]; |
1287 RetentionPriority priority = _retentionPolicy.getAstPriority(source, _sour
ceMap[source]); | 1317 RetentionPriority priority = _retentionPolicy.getAstPriority(source, _sour
ceMap[source]); |
1288 if (identical(priority, RetentionPriority.LOW)) { | 1318 if (identical(priority, RetentionPriority.LOW)) { |
1289 return _recentlyUsed.removeAt(i); | 1319 return _recentlyUsed.removeAt(i); |
1290 } else if (identical(priority, RetentionPriority.MEDIUM) && sourceToRemove
< 0) { | 1320 } else if (identical(priority, RetentionPriority.MEDIUM) && sourceToRemove
< 0) { |
1291 sourceToRemove = i; | 1321 sourceToRemove = i; |
1292 } | 1322 } |
1293 } | 1323 } |
1294 if (sourceToRemove < 0) { | 1324 if (sourceToRemove < 0) { |
1295 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush
data from the cache", new JavaException()); | |
1296 return null; | 1325 return null; |
1297 } | 1326 } |
1298 return _recentlyUsed.removeAt(sourceToRemove); | 1327 return _recentlyUsed.removeAt(sourceToRemove); |
1299 } | 1328 } |
1300 } | 1329 } |
1301 | 1330 |
1302 /** | 1331 /** |
1303 * Instances of the class `CacheRetentionPolicy` define the behavior of objects
that determine | 1332 * Instances of the class `CacheRetentionPolicy` define the behavior of objects
that determine |
1304 * how important it is for data to be retained in the analysis cache. | 1333 * how important it is for data to be retained in the analysis cache. |
1305 */ | 1334 */ |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 */ | 2991 */ |
2963 void flushAstStructures() { | 2992 void flushAstStructures() { |
2964 if (identical(_parsedUnitState, CacheState.VALID)) { | 2993 if (identical(_parsedUnitState, CacheState.VALID)) { |
2965 _parsedUnitState = CacheState.FLUSHED; | 2994 _parsedUnitState = CacheState.FLUSHED; |
2966 _parsedUnit = null; | 2995 _parsedUnit = null; |
2967 } | 2996 } |
2968 if (identical(_resolvedUnitState, CacheState.VALID)) { | 2997 if (identical(_resolvedUnitState, CacheState.VALID)) { |
2969 _resolvedUnitState = CacheState.FLUSHED; | 2998 _resolvedUnitState = CacheState.FLUSHED; |
2970 _resolvedUnit = null; | 2999 _resolvedUnit = null; |
2971 } | 3000 } |
| 3001 if (identical(_angularEntryState, CacheState.VALID)) { |
| 3002 _angularEntryState = CacheState.FLUSHED; |
| 3003 } |
| 3004 if (identical(_angularErrorsState, CacheState.VALID)) { |
| 3005 _angularErrorsState = CacheState.FLUSHED; |
| 3006 } |
2972 } | 3007 } |
2973 | 3008 |
2974 @override | 3009 @override |
2975 List<AnalysisError> get allErrors { | 3010 List<AnalysisError> get allErrors { |
2976 List<AnalysisError> errors = new List<AnalysisError>(); | 3011 List<AnalysisError> errors = new List<AnalysisError>(); |
2977 if (_parseErrors != null) { | 3012 if (_parseErrors != null) { |
2978 for (AnalysisError error in _parseErrors) { | 3013 for (AnalysisError error in _parseErrors) { |
2979 errors.add(error); | 3014 errors.add(error); |
2980 } | 3015 } |
2981 } | 3016 } |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3697 class AnalysisContextImpl implements InternalAnalysisContext { | 3732 class AnalysisContextImpl implements InternalAnalysisContext { |
3698 /** | 3733 /** |
3699 * The difference between the maximum cache size and the maximum priority orde
r size. The priority | 3734 * The difference between the maximum cache size and the maximum priority orde
r size. The priority |
3700 * list must be capped so that it is less than the cache size. Failure to do s
o can result in an | 3735 * list must be capped so that it is less than the cache size. Failure to do s
o can result in an |
3701 * infinite loop in performAnalysisTask() because re-caching one AST structure
can cause another | 3736 * infinite loop in performAnalysisTask() because re-caching one AST structure
can cause another |
3702 * priority source's AST structure to be flushed. | 3737 * priority source's AST structure to be flushed. |
3703 */ | 3738 */ |
3704 static int _PRIORITY_ORDER_SIZE_DELTA = 4; | 3739 static int _PRIORITY_ORDER_SIZE_DELTA = 4; |
3705 | 3740 |
3706 /** | 3741 /** |
| 3742 * A flag indicating whether trace output should be produced as analysis tasks
are performed. Used |
| 3743 * for debugging. |
| 3744 */ |
| 3745 static bool _TRACE_PERFORM_TASK = false; |
| 3746 |
| 3747 /** |
3707 * The set of analysis options controlling the behavior of this context. | 3748 * The set of analysis options controlling the behavior of this context. |
3708 */ | 3749 */ |
3709 AnalysisOptionsImpl _options = new AnalysisOptionsImpl(); | 3750 AnalysisOptionsImpl _options = new AnalysisOptionsImpl(); |
3710 | 3751 |
3711 /** | 3752 /** |
| 3753 * A flag indicating whether errors related to sources in the SDK should be ge
nerated and |
| 3754 * reported. |
| 3755 */ |
| 3756 bool _generateSdkErrors = true; |
| 3757 |
| 3758 /** |
3712 * A flag indicating whether this context is disposed. | 3759 * A flag indicating whether this context is disposed. |
3713 */ | 3760 */ |
3714 bool _disposed = false; | 3761 bool _disposed = false; |
3715 | 3762 |
3716 /** | 3763 /** |
3717 * A cache of content used to override the default content of a source. | 3764 * A cache of content used to override the default content of a source. |
3718 */ | 3765 */ |
3719 ContentCache _contentCache = new ContentCache(); | 3766 ContentCache _contentCache = new ContentCache(); |
3720 | 3767 |
3721 /** | 3768 /** |
3722 * The source factory used to create the sources that can be analyzed in this
context. | 3769 * The source factory used to create the sources that can be analyzed in this
context. |
3723 */ | 3770 */ |
3724 SourceFactory _sourceFactory; | 3771 SourceFactory _sourceFactory; |
3725 | 3772 |
3726 /** | 3773 /** |
| 3774 * A source representing the core library. |
| 3775 */ |
| 3776 Source _coreLibrarySource; |
| 3777 |
| 3778 /** |
3727 * A table mapping the sources known to the context to the information known a
bout the source. | 3779 * A table mapping the sources known to the context to the information known a
bout the source. |
3728 */ | 3780 */ |
3729 AnalysisCache _cache; | 3781 AnalysisCache _cache; |
3730 | 3782 |
3731 /** | 3783 /** |
3732 * An array containing sources for which data should not be flushed. | 3784 * An array containing sources for which data should not be flushed. |
3733 */ | 3785 */ |
3734 List<Source> _priorityOrder = Source.EMPTY_ARRAY; | 3786 List<Source> _priorityOrder = Source.EMPTY_ARRAY; |
3735 | 3787 |
3736 /** | 3788 /** |
| 3789 * An array containing sources whose AST structure is needed in order to resol
ve the next library |
| 3790 * to be resolved. |
| 3791 */ |
| 3792 Set<Source> _neededForResolution = null; |
| 3793 |
| 3794 /** |
3737 * A table mapping sources to the change notices that are waiting to be return
ed related to that | 3795 * A table mapping sources to the change notices that are waiting to be return
ed related to that |
3738 * source. | 3796 * source. |
3739 */ | 3797 */ |
3740 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); | 3798 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); |
3741 | 3799 |
3742 /** | 3800 /** |
3743 * A set containing information about the tasks that have been performed since
the last change | 3801 * A set containing information about the tasks that have been performed since
the last change |
3744 * notification. Used to detect infinite loops in [performAnalysisTask]. | 3802 * notification. Used to detect infinite loops in [performAnalysisTask]. |
3745 */ | 3803 */ |
3746 Set<String> _recentTasks = new Set<String>(); | 3804 Set<String> _recentTasks = new Set<String>(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3817 _sourceChanged(source); | 3875 _sourceChanged(source); |
3818 } | 3876 } |
3819 for (Source source in removedSources) { | 3877 for (Source source in removedSources) { |
3820 _sourceRemoved(source); | 3878 _sourceRemoved(source); |
3821 } | 3879 } |
3822 if (addedDartSource) { | 3880 if (addedDartSource) { |
3823 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal
yze any libraries | 3881 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal
yze any libraries |
3824 // that might have been referencing the not-yet-existing source that was j
ust added. Longer | 3882 // that might have been referencing the not-yet-existing source that was j
ust added. Longer |
3825 // term we need to keep track of which libraries are referencing non-exist
ing sources and | 3883 // term we need to keep track of which libraries are referencing non-exist
ing sources and |
3826 // only re-analyze those libraries. | 3884 // only re-analyze those libraries. |
3827 _logInformation("Added Dart sources, invalidating all resolution informati
on"); | 3885 // logInformation("Added Dart sources, invalidating all resolution
information"); |
3828 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 3886 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
3829 Source source = mapEntry.getKey(); | 3887 Source source = mapEntry.getKey(); |
3830 SourceEntry sourceEntry = mapEntry.getValue(); | 3888 SourceEntry sourceEntry = mapEntry.getValue(); |
3831 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { | 3889 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { |
3832 DartEntry dartEntry = sourceEntry; | 3890 DartEntry dartEntry = sourceEntry; |
3833 DartEntryImpl dartCopy = dartEntry.writableCopy; | 3891 DartEntryImpl dartCopy = dartEntry.writableCopy; |
3834 _removeFromParts(source, dartEntry); | 3892 _removeFromParts(source, dartEntry); |
3835 dartCopy.invalidateAllResolutionInformation(); | 3893 dartCopy.invalidateAllResolutionInformation(); |
3836 mapEntry.setValue(dartCopy); | 3894 mapEntry.setValue(dartCopy); |
3837 SourcePriority priority = SourcePriority.UNKNOWN; | 3895 SourcePriority priority = SourcePriority.UNKNOWN; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4021 newContext.addSourceInfo(source, entry.getValue().writableCopy); | 4079 newContext.addSourceInfo(source, entry.getValue().writableCopy); |
4022 } | 4080 } |
4023 } | 4081 } |
4024 return newContext; | 4082 return newContext; |
4025 } | 4083 } |
4026 | 4084 |
4027 @override | 4085 @override |
4028 AnalysisOptions get analysisOptions => _options; | 4086 AnalysisOptions get analysisOptions => _options; |
4029 | 4087 |
4030 @override | 4088 @override |
| 4089 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { |
| 4090 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource); |
| 4091 if (sourceEntry is HtmlEntry) { |
| 4092 HtmlEntry htmlEntry = sourceEntry; |
| 4093 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPL
ICATION); |
| 4094 if (application != null) { |
| 4095 return application; |
| 4096 } |
| 4097 return htmlEntry.getValue(HtmlEntry.ANGULAR_ENTRY); |
| 4098 } |
| 4099 return null; |
| 4100 } |
| 4101 |
| 4102 @override |
4031 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource) { | 4103 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource) { |
4032 LibraryElement libraryElement = getLibraryElement(librarySource); | 4104 LibraryElement libraryElement = getLibraryElement(librarySource); |
4033 if (libraryElement != null) { | 4105 if (libraryElement != null) { |
4034 // try defining unit | 4106 // try defining unit |
4035 CompilationUnitElement definingUnit = libraryElement.definingCompilationUn
it; | 4107 CompilationUnitElement definingUnit = libraryElement.definingCompilationUn
it; |
4036 if (definingUnit.source == unitSource) { | 4108 if (definingUnit.source == unitSource) { |
4037 return definingUnit; | 4109 return definingUnit; |
4038 } | 4110 } |
4039 // try parts | 4111 // try parts |
4040 for (CompilationUnitElement partUnit in libraryElement.parts) { | 4112 for (CompilationUnitElement partUnit in libraryElement.parts) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4194 } | 4266 } |
4195 } | 4267 } |
4196 } | 4268 } |
4197 if (dependentLibraries.isEmpty) { | 4269 if (dependentLibraries.isEmpty) { |
4198 return Source.EMPTY_ARRAY; | 4270 return Source.EMPTY_ARRAY; |
4199 } | 4271 } |
4200 return new List.from(dependentLibraries); | 4272 return new List.from(dependentLibraries); |
4201 } | 4273 } |
4202 | 4274 |
4203 @override | 4275 @override |
| 4276 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { |
| 4277 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource); |
| 4278 if (sourceEntry is HtmlEntry) { |
| 4279 HtmlEntry htmlEntry = sourceEntry; |
| 4280 return htmlEntry.getValue(HtmlEntry.REFERENCED_LIBRARIES); |
| 4281 } |
| 4282 return Source.EMPTY_ARRAY; |
| 4283 } |
| 4284 |
| 4285 @override |
4204 LibraryElement getLibraryElement(Source source) { | 4286 LibraryElement getLibraryElement(Source source) { |
4205 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); | 4287 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); |
4206 if (sourceEntry is DartEntry) { | 4288 if (sourceEntry is DartEntry) { |
4207 return sourceEntry.getValue(DartEntry.ELEMENT); | 4289 return sourceEntry.getValue(DartEntry.ELEMENT); |
4208 } | 4290 } |
4209 return null; | 4291 return null; |
4210 } | 4292 } |
4211 | 4293 |
4212 @override | 4294 @override |
4213 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); | 4295 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4324 // Look for non-priority sources that need to be analyzed. | 4406 // Look for non-priority sources that need to be analyzed. |
4325 // | 4407 // |
4326 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4408 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
4327 _getSourcesNeedingProcessing(entry.getKey(), entry.getValue(), false, hint
sEnabled, sources); | 4409 _getSourcesNeedingProcessing(entry.getKey(), entry.getValue(), false, hint
sEnabled, sources); |
4328 } | 4410 } |
4329 return new List<Source>.from(sources); | 4411 return new List<Source>.from(sources); |
4330 } | 4412 } |
4331 | 4413 |
4332 @override | 4414 @override |
4333 AnalysisContentStatistics get statistics { | 4415 AnalysisContentStatistics get statistics { |
| 4416 bool hintsEnabled = _options.hint; |
4334 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl
(); | 4417 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl
(); |
4335 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 4418 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
4336 statistics.addSource(mapEntry.getKey()); | 4419 statistics.addSource(mapEntry.getKey()); |
4337 SourceEntry entry = mapEntry.getValue(); | 4420 SourceEntry entry = mapEntry.getValue(); |
4338 if (entry is DartEntry) { | 4421 if (entry is DartEntry) { |
4339 Source source = mapEntry.getKey(); | 4422 Source source = mapEntry.getKey(); |
4340 DartEntry dartEntry = entry; | 4423 DartEntry dartEntry = entry; |
4341 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); | 4424 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); |
4342 // get library independent values | 4425 // get library independent values |
4343 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); | 4426 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); |
4344 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); | 4427 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); |
4345 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); | 4428 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); |
4346 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); | 4429 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); |
4347 if (identical(kind, SourceKind.LIBRARY)) { | 4430 if (identical(kind, SourceKind.LIBRARY)) { |
4348 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); | 4431 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); |
4349 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); | 4432 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); |
4350 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); | 4433 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); |
4351 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); | 4434 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); |
4352 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); | 4435 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); |
4353 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); | 4436 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); |
4354 } | 4437 } |
4355 // get library-specific values | 4438 // get library-specific values |
4356 List<Source> librarySources = getLibrariesContaining(source); | 4439 List<Source> librarySources = getLibrariesContaining(source); |
4357 for (Source librarySource in librarySources) { | 4440 for (Source librarySource in librarySources) { |
4358 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.H
INTS); | |
4359 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R
ESOLUTION_ERRORS); | 4441 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R
ESOLUTION_ERRORS); |
4360 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R
ESOLVED_UNIT); | 4442 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R
ESOLVED_UNIT); |
4361 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.V
ERIFICATION_ERRORS); | 4443 if (_generateSdkErrors || !source.isInSystemLibrary) { |
| 4444 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry
.VERIFICATION_ERRORS); |
| 4445 if (hintsEnabled) { |
| 4446 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEnt
ry.HINTS); |
| 4447 } |
| 4448 } |
4362 } | 4449 } |
4363 } else if (entry is HtmlEntry) { | 4450 } else if (entry is HtmlEntry) { |
4364 HtmlEntry htmlEntry = entry; | 4451 HtmlEntry htmlEntry = entry; |
4365 statistics.putCacheItem(htmlEntry, SourceEntry.LINE_INFO); | 4452 statistics.putCacheItem(htmlEntry, SourceEntry.LINE_INFO); |
4366 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSE_ERRORS); | 4453 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSE_ERRORS); |
4367 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSED_UNIT); | 4454 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSED_UNIT); |
4368 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLUTION_ERRORS); | 4455 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLUTION_ERRORS); |
4369 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLVED_UNIT); | 4456 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLVED_UNIT); |
4370 } | 4457 } |
4371 } | 4458 } |
4372 return statistics; | 4459 return statistics; |
4373 } | 4460 } |
4374 | 4461 |
4375 @override | 4462 @override |
4376 TypeProvider get typeProvider { | 4463 TypeProvider get typeProvider { |
4377 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 4464 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
4378 return new TypeProviderImpl(computeLibraryElement(coreSource)); | 4465 return new TypeProviderImpl(computeLibraryElement(coreSource)); |
4379 } | 4466 } |
4380 | 4467 |
4381 @override | 4468 @override |
4382 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) { | |
4383 DartEntry dartEntry = _getReadableDartEntry(unitSource); | |
4384 if (dartEntry == null) { | |
4385 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f
or non-Dart file: ${unitSource.fullName}"); | |
4386 } | |
4387 Source librarySource = libraryElement.source; | |
4388 dartEntry = _cacheDartResolutionData(unitSource, librarySource, dartEntry, D
artEntry.RESOLVED_UNIT); | |
4389 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart
Entry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); | |
4390 } | |
4391 | |
4392 @override | |
4393 bool isClientLibrary(Source librarySource) { | 4469 bool isClientLibrary(Source librarySource) { |
4394 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); | 4470 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); |
4395 if (sourceEntry is DartEntry) { | 4471 if (sourceEntry is DartEntry) { |
4396 DartEntry dartEntry = sourceEntry; | 4472 DartEntry dartEntry = sourceEntry; |
4397 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); | 4473 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); |
4398 } | 4474 } |
4399 return false; | 4475 return false; |
4400 } | 4476 } |
4401 | 4477 |
4402 @override | 4478 @override |
(...skipping 30 matching lines...) Expand all Loading... |
4433 } | 4509 } |
4434 | 4510 |
4435 @override | 4511 @override |
4436 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour
ce, DartEntry.PARSED_UNIT, null); | 4512 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour
ce, DartEntry.PARSED_UNIT, null); |
4437 | 4513 |
4438 @override | 4514 @override |
4439 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr
y.PARSED_UNIT, null); | 4515 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr
y.PARSED_UNIT, null); |
4440 | 4516 |
4441 @override | 4517 @override |
4442 AnalysisResult performAnalysisTask() { | 4518 AnalysisResult performAnalysisTask() { |
| 4519 if (_TRACE_PERFORM_TASK) { |
| 4520 print("----------------------------------------"); |
| 4521 } |
4443 int getStart = JavaSystem.currentTimeMillis(); | 4522 int getStart = JavaSystem.currentTimeMillis(); |
4444 AnalysisTask task = nextAnalysisTask; | 4523 AnalysisTask task = nextAnalysisTask; |
4445 int getEnd = JavaSystem.currentTimeMillis(); | 4524 int getEnd = JavaSystem.currentTimeMillis(); |
4446 if (task == null && _validateCacheConsistency()) { | 4525 if (task == null && _validateCacheConsistency()) { |
4447 task = nextAnalysisTask; | 4526 task = nextAnalysisTask; |
4448 } | 4527 } |
4449 if (task == null) { | 4528 if (task == null) { |
4450 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); | 4529 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); |
4451 } | 4530 } |
4452 String taskDescriptor = task.toString(); | 4531 String taskDescriptor = task.toString(); |
4453 if (_recentTasks.add(taskDescriptor)) { | 4532 // if (recentTasks.add(taskDescriptor)) { |
4454 _logInformation("Performing task: ${taskDescriptor}"); | 4533 // logInformation("Performing task: " + taskDescriptor); |
4455 } else { | 4534 // } else { |
4456 _logInformation("*** Performing repeated task: ${taskDescriptor}"); | 4535 // if (TRACE_PERFORM_TASK) { |
| 4536 // System.out.print("* "); |
| 4537 // } |
| 4538 // logInformation("*** Performing repeated task: " + taskDescriptor); |
| 4539 // } |
| 4540 if (_TRACE_PERFORM_TASK) { |
| 4541 print(taskDescriptor); |
4457 } | 4542 } |
4458 int performStart = JavaSystem.currentTimeMillis(); | 4543 int performStart = JavaSystem.currentTimeMillis(); |
4459 try { | 4544 try { |
4460 task.perform(_resultRecorder); | 4545 task.perform(_resultRecorder); |
4461 } on ObsoleteSourceAnalysisException catch (exception) { | 4546 } on ObsoleteSourceAnalysisException catch (exception) { |
4462 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescriptor}", exception); | 4547 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescriptor}", exception); |
4463 } on AnalysisException catch (exception) { | 4548 } on AnalysisException catch (exception) { |
4464 if (exception.cause is! JavaIOException) { | 4549 if (exception.cause is! JavaIOException) { |
4465 AnalysisEngine.instance.logger.logError2("Internal error while performin
g the task: ${task}", exception); | 4550 AnalysisEngine.instance.logger.logError2("Internal error while performin
g the task: ${task}", exception); |
4466 } | 4551 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4499 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) => _getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT
, null); | 4584 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) => _getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT
, null); |
4500 | 4585 |
4501 @override | 4586 @override |
4502 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 4587 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
4503 computeHtmlElement(htmlSource); | 4588 computeHtmlElement(htmlSource); |
4504 return parseHtmlUnit(htmlSource); | 4589 return parseHtmlUnit(htmlSource); |
4505 } | 4590 } |
4506 | 4591 |
4507 @override | 4592 @override |
4508 void set analysisOptions(AnalysisOptions options) { | 4593 void set analysisOptions(AnalysisOptions options) { |
4509 bool needsRecompute = this._options.analyzeFunctionBodies != options.analyze
FunctionBodies || this._options.dart2jsHint != options.dart2jsHint || (this._opt
ions.hint && !options.hint) || this._options.preserveComments != options.preserv
eComments; | 4594 bool needsRecompute = this._options.analyzeFunctionBodies != options.analyze
FunctionBodies || this._options.generateSdkErrors != options.generateSdkErrors |
| this._options.dart2jsHint != options.dart2jsHint || (this._options.hint && !op
tions.hint) || this._options.preserveComments != options.preserveComments; |
4510 int cacheSize = options.cacheSize; | 4595 int cacheSize = options.cacheSize; |
4511 if (this._options.cacheSize != cacheSize) { | 4596 if (this._options.cacheSize != cacheSize) { |
4512 this._options.cacheSize = cacheSize; | 4597 this._options.cacheSize = cacheSize; |
4513 _cache.maxCacheSize = cacheSize; | 4598 _cache.maxCacheSize = cacheSize; |
4514 // | 4599 // |
4515 // Cap the size of the priority list to being less than the cache size. Fa
ilure to do so can | 4600 // Cap the size of the priority list to being less than the cache size. Fa
ilure to do so can |
4516 // result in an infinite loop in performAnalysisTask() because re-caching
one AST structure | 4601 // result in an infinite loop in performAnalysisTask() because re-caching
one AST structure |
4517 // can cause another priority source's AST structure to be flushed. | 4602 // can cause another priority source's AST structure to be flushed. |
4518 // | 4603 // |
4519 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 4604 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
4520 if (_priorityOrder.length > maxPriorityOrderSize) { | 4605 if (_priorityOrder.length > maxPriorityOrderSize) { |
4521 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); | 4606 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); |
4522 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriority
OrderSize); | 4607 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriority
OrderSize); |
4523 _priorityOrder = newPriorityOrder; | 4608 _priorityOrder = newPriorityOrder; |
4524 } | 4609 } |
4525 } | 4610 } |
4526 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; | 4611 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; |
| 4612 this._options.generateSdkErrors = options.generateSdkErrors; |
4527 this._options.dart2jsHint = options.dart2jsHint; | 4613 this._options.dart2jsHint = options.dart2jsHint; |
4528 this._options.hint = options.hint; | 4614 this._options.hint = options.hint; |
4529 this._options.incremental = options.incremental; | 4615 this._options.incremental = options.incremental; |
4530 this._options.preserveComments = options.preserveComments; | 4616 this._options.preserveComments = options.preserveComments; |
| 4617 _generateSdkErrors = options.generateSdkErrors; |
4531 if (needsRecompute) { | 4618 if (needsRecompute) { |
4532 _invalidateAllResolutionInformation(); | 4619 _invalidateAllResolutionInformation(); |
4533 } | 4620 } |
4534 } | 4621 } |
4535 | 4622 |
4536 @override | 4623 @override |
4537 void set analysisPriorityOrder(List<Source> sources) { | 4624 void set analysisPriorityOrder(List<Source> sources) { |
4538 if (sources == null || sources.isEmpty) { | 4625 if (sources == null || sources.isEmpty) { |
4539 _priorityOrder = Source.EMPTY_ARRAY; | 4626 _priorityOrder = Source.EMPTY_ARRAY; |
4540 } else { | 4627 } else { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4607 if (identical(_sourceFactory, factory)) { | 4694 if (identical(_sourceFactory, factory)) { |
4608 return; | 4695 return; |
4609 } else if (factory.context != null) { | 4696 } else if (factory.context != null) { |
4610 throw new IllegalStateException("Source factories cannot be shared between
contexts"); | 4697 throw new IllegalStateException("Source factories cannot be shared between
contexts"); |
4611 } | 4698 } |
4612 if (_sourceFactory != null) { | 4699 if (_sourceFactory != null) { |
4613 _sourceFactory.context = null; | 4700 _sourceFactory.context = null; |
4614 } | 4701 } |
4615 factory.context = this; | 4702 factory.context = this; |
4616 _sourceFactory = factory; | 4703 _sourceFactory = factory; |
| 4704 _coreLibrarySource = _sourceFactory.forUri(DartSdk.DART_CORE); |
4617 _invalidateAllResolutionInformation(); | 4705 _invalidateAllResolutionInformation(); |
4618 } | 4706 } |
4619 | 4707 |
4620 /** | 4708 /** |
4621 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were | 4709 * Record the results produced by performing a [ResolveDartLibraryCycleTask].
If the results |
4622 * computed from data that is now out-of-date, then the results will not be re
corded. | 4710 * were computed from data that is now out-of-date, then the results will not
be recorded. |
4623 * | 4711 * |
4624 * @param task the task that was performed | 4712 * @param task the task that was performed |
4625 * @return an entry containing the computed results | 4713 * @return an entry containing the computed results |
4626 * @throws AnalysisException if the results could not be recorded | 4714 * @throws AnalysisException if the results could not be recorded |
4627 */ | 4715 */ |
| 4716 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask
task) { |
| 4717 LibraryResolver2 resolver = task.libraryResolver; |
| 4718 AnalysisException thrownException = task.exception; |
| 4719 DartEntry unitEntry = null; |
| 4720 Source unitSource = task.unitSource; |
| 4721 if (resolver != null) { |
| 4722 // |
| 4723 // The resolver should only be null if an exception was thrown before (or
while) it was |
| 4724 // being created. |
| 4725 // |
| 4726 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries; |
| 4727 if (resolvedLibraries == null) { |
| 4728 // |
| 4729 // The resolved libraries should only be null if an exception was thrown
during resolution. |
| 4730 // |
| 4731 unitEntry = _getReadableDartEntry(unitSource); |
| 4732 if (unitEntry == null) { |
| 4733 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
| 4734 } |
| 4735 DartEntryImpl dartCopy = unitEntry.writableCopy; |
| 4736 dartCopy.recordResolutionError(); |
| 4737 dartCopy.exception = thrownException; |
| 4738 _cache.put(unitSource, dartCopy); |
| 4739 _cache.remove(unitSource); |
| 4740 if (thrownException != null) { |
| 4741 throw thrownException; |
| 4742 } |
| 4743 return dartCopy; |
| 4744 } |
| 4745 if (_allModificationTimesMatch(resolvedLibraries)) { |
| 4746 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
| 4747 RecordingErrorListener errorListener = resolver.errorListener; |
| 4748 for (ResolvableLibrary library in resolvedLibraries) { |
| 4749 Source librarySource = library.librarySource; |
| 4750 for (Source source in library.compilationUnitSources) { |
| 4751 CompilationUnit unit = library.getAST(source); |
| 4752 List<AnalysisError> errors = errorListener.getErrorsForSource(source
); |
| 4753 LineInfo lineInfo = getLineInfo(source); |
| 4754 DartEntry dartEntry = _cache.get(source) as DartEntry; |
| 4755 int sourceTime = getModificationStamp(source); |
| 4756 if (dartEntry.modificationTime != sourceTime) { |
| 4757 // The source has changed without the context being notified. Simu
late notification. |
| 4758 _sourceChanged(source); |
| 4759 dartEntry = _getReadableDartEntry(source); |
| 4760 if (dartEntry == null) { |
| 4761 throw new AnalysisException.con1("A Dart file became a non-Dart
file: ${source.fullName}"); |
| 4762 } |
| 4763 } |
| 4764 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4765 if (thrownException == null) { |
| 4766 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 4767 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 4768 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource,
unit); |
| 4769 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou
rce, errors); |
| 4770 if (source == librarySource) { |
| 4771 _recordElementData(dartEntry, dartCopy, library.libraryElement,
librarySource, htmlSource); |
| 4772 } |
| 4773 _cache.storedAst(source); |
| 4774 } else { |
| 4775 dartCopy.recordResolutionError(); |
| 4776 _cache.remove(source); |
| 4777 } |
| 4778 dartCopy.exception = thrownException; |
| 4779 _cache.put(source, dartCopy); |
| 4780 if (source != librarySource) { |
| 4781 _workManager.add(source, SourcePriority.PRIORITY_PART); |
| 4782 } |
| 4783 if (source == unitSource) { |
| 4784 unitEntry = dartCopy; |
| 4785 } |
| 4786 if (_generateSdkErrors || !source.isInSystemLibrary) { |
| 4787 ChangeNoticeImpl notice = _getNotice(source); |
| 4788 notice.compilationUnit = unit; |
| 4789 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4790 } |
| 4791 } |
| 4792 } |
| 4793 } else { |
| 4794 PrintStringWriter writer = new PrintStringWriter(); |
| 4795 writer.println("Library resolution results discarded for"); |
| 4796 for (ResolvableLibrary library in resolvedLibraries) { |
| 4797 for (Source source in library.compilationUnitSources) { |
| 4798 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4799 if (dartEntry != null) { |
| 4800 int resultTime = library.getModificationTime(source); |
| 4801 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM
odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m
odificationTime}"); |
| 4802 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4803 if (thrownException == null || resultTime >= 0) { |
| 4804 // |
| 4805 // The analysis was performed on out-of-date sources. Mark the c
ache so that the |
| 4806 // sources will be re-analyzed using the up-to-date sources. |
| 4807 // |
| 4808 dartCopy.recordResolutionNotInProcess(); |
| 4809 } else { |
| 4810 // |
| 4811 // We could not determine whether the sources were up-to-date or
out-of-date. Mark |
| 4812 // the cache so that we won't attempt to re-analyze the sources
until there's a |
| 4813 // good chance that we'll be able to do so without error. |
| 4814 // |
| 4815 dartCopy.recordResolutionError(); |
| 4816 _cache.remove(source); |
| 4817 } |
| 4818 dartCopy.exception = thrownException; |
| 4819 _cache.put(source, dartCopy); |
| 4820 if (source == unitSource) { |
| 4821 unitEntry = dartCopy; |
| 4822 } |
| 4823 } else { |
| 4824 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM
odificationStamp(source)}, no entry"); |
| 4825 } |
| 4826 } |
| 4827 } |
| 4828 _logInformation(writer.toString()); |
| 4829 } |
| 4830 } |
| 4831 if (thrownException != null) { |
| 4832 throw thrownException; |
| 4833 } |
| 4834 if (unitEntry == null) { |
| 4835 unitEntry = _getReadableDartEntry(unitSource); |
| 4836 if (unitEntry == null) { |
| 4837 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); |
| 4838 } |
| 4839 } |
| 4840 return unitEntry; |
| 4841 } |
| 4842 |
4628 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { | 4843 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { |
4629 LibraryResolver resolver = task.libraryResolver; | 4844 LibraryResolver resolver = task.libraryResolver; |
4630 AnalysisException thrownException = task.exception; | 4845 AnalysisException thrownException = task.exception; |
4631 DartEntry unitEntry = null; | 4846 DartEntry unitEntry = null; |
4632 Source unitSource = task.unitSource; | 4847 Source unitSource = task.unitSource; |
4633 if (resolver != null) { | 4848 if (resolver != null) { |
4634 // | 4849 // |
4635 // The resolver should only be null if an exception was thrown before (or
while) it was | 4850 // The resolver should only be null if an exception was thrown before (or
while) it was |
4636 // being created. | 4851 // being created. |
4637 // | 4852 // |
4638 Set<Library> resolvedLibraries = resolver.resolvedLibraries; | 4853 Set<Library> resolvedLibraries = resolver.resolvedLibraries; |
4639 if (resolvedLibraries == null) { | 4854 if (resolvedLibraries == null) { |
4640 // | 4855 // |
4641 // The resolved libraries should only be null if an exception was thrown
during resolution. | 4856 // The resolved libraries should only be null if an exception was thrown
during resolution. |
4642 // | 4857 // |
4643 unitEntry = _getReadableDartEntry(unitSource); | 4858 unitEntry = _getReadableDartEntry(unitSource); |
4644 if (unitEntry == null) { | 4859 if (unitEntry == null) { |
4645 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); | 4860 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
4646 } | 4861 } |
4647 DartEntryImpl dartCopy = unitEntry.writableCopy; | 4862 DartEntryImpl dartCopy = unitEntry.writableCopy; |
4648 dartCopy.recordResolutionError(); | 4863 dartCopy.recordResolutionError(); |
4649 dartCopy.exception = thrownException; | 4864 dartCopy.exception = thrownException; |
4650 _cache.put(unitSource, dartCopy); | 4865 _cache.put(unitSource, dartCopy); |
4651 _cache.remove(unitSource); | 4866 _cache.remove(unitSource); |
4652 if (thrownException != null) { | 4867 if (thrownException != null) { |
4653 throw thrownException; | 4868 throw thrownException; |
4654 } | 4869 } |
4655 return dartCopy; | 4870 return dartCopy; |
4656 } | 4871 } |
4657 if (_allModificationTimesMatch(resolvedLibraries)) { | 4872 if (_allModificationTimesMatch2(resolvedLibraries)) { |
4658 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 4873 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
4659 RecordingErrorListener errorListener = resolver.errorListener; | 4874 RecordingErrorListener errorListener = resolver.errorListener; |
4660 for (Library library in resolvedLibraries) { | 4875 for (Library library in resolvedLibraries) { |
4661 Source librarySource = library.librarySource; | 4876 Source librarySource = library.librarySource; |
4662 for (Source source in library.compilationUnitSources) { | 4877 for (Source source in library.compilationUnitSources) { |
4663 CompilationUnit unit = library.getAST(source); | 4878 CompilationUnit unit = library.getAST(source); |
4664 List<AnalysisError> errors = errorListener.getErrorsForSource(source
); | 4879 List<AnalysisError> errors = errorListener.getErrorsForSource(source
); |
4665 LineInfo lineInfo = getLineInfo(source); | 4880 LineInfo lineInfo = getLineInfo(source); |
4666 DartEntry dartEntry = _cache.get(source) as DartEntry; | 4881 DartEntry dartEntry = _cache.get(source) as DartEntry; |
4667 int sourceTime = getModificationStamp(source); | 4882 int sourceTime = getModificationStamp(source); |
(...skipping 20 matching lines...) Expand all Loading... |
4688 _cache.remove(source); | 4903 _cache.remove(source); |
4689 } | 4904 } |
4690 dartCopy.exception = thrownException; | 4905 dartCopy.exception = thrownException; |
4691 _cache.put(source, dartCopy); | 4906 _cache.put(source, dartCopy); |
4692 if (source != librarySource) { | 4907 if (source != librarySource) { |
4693 _workManager.add(source, SourcePriority.PRIORITY_PART); | 4908 _workManager.add(source, SourcePriority.PRIORITY_PART); |
4694 } | 4909 } |
4695 if (source == unitSource) { | 4910 if (source == unitSource) { |
4696 unitEntry = dartCopy; | 4911 unitEntry = dartCopy; |
4697 } | 4912 } |
4698 ChangeNoticeImpl notice = _getNotice(source); | 4913 if (_generateSdkErrors || !source.isInSystemLibrary) { |
4699 notice.compilationUnit = unit; | 4914 ChangeNoticeImpl notice = _getNotice(source); |
4700 notice.setErrors(dartCopy.allErrors, lineInfo); | 4915 notice.compilationUnit = unit; |
| 4916 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4917 } |
4701 } | 4918 } |
4702 } | 4919 } |
4703 } else { | 4920 } else { |
4704 PrintStringWriter writer = new PrintStringWriter(); | 4921 PrintStringWriter writer = new PrintStringWriter(); |
4705 writer.println("Library resolution results discarded for"); | 4922 writer.println("Library resolution results discarded for"); |
4706 for (Library library in resolvedLibraries) { | 4923 for (Library library in resolvedLibraries) { |
4707 for (Source source in library.compilationUnitSources) { | 4924 for (Source source in library.compilationUnitSources) { |
4708 DartEntry dartEntry = _getReadableDartEntry(source); | 4925 DartEntry dartEntry = _getReadableDartEntry(source); |
4709 if (dartEntry != null) { | 4926 if (dartEntry != null) { |
4710 int resultTime = library.getModificationTime(source); | 4927 int resultTime = library.getModificationTime(source); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4779 | 4996 |
4780 /** | 4997 /** |
4781 * Return `true` if the modification times of the sources used by the given li
brary resolver | 4998 * Return `true` if the modification times of the sources used by the given li
brary resolver |
4782 * to resolve one or more libraries are consistent with the modification times
in the cache. | 4999 * to resolve one or more libraries are consistent with the modification times
in the cache. |
4783 * | 5000 * |
4784 * @param resolver the library resolver used to resolve one or more libraries | 5001 * @param resolver the library resolver used to resolve one or more libraries |
4785 * @return `true` if we should record the results of the resolution | 5002 * @return `true` if we should record the results of the resolution |
4786 * @throws AnalysisException if any of the modification times could not be det
ermined (this should | 5003 * @throws AnalysisException if any of the modification times could not be det
ermined (this should |
4787 * not happen) | 5004 * not happen) |
4788 */ | 5005 */ |
4789 bool _allModificationTimesMatch(Set<Library> resolvedLibraries) { | 5006 bool _allModificationTimesMatch(List<ResolvableLibrary> resolvedLibraries) { |
| 5007 bool allTimesMatch = true; |
| 5008 for (ResolvableLibrary library in resolvedLibraries) { |
| 5009 for (Source source in library.compilationUnitSources) { |
| 5010 DartEntry dartEntry = _getReadableDartEntry(source); |
| 5011 if (dartEntry == null) { |
| 5012 // This shouldn't be possible because we should never have performed t
he task if the |
| 5013 // source didn't represent a Dart file, but check to be safe. |
| 5014 throw new AnalysisException.con1("Internal error: attempting to resolv
e non-Dart file as a Dart file: ${source.fullName}"); |
| 5015 } |
| 5016 int sourceTime = getModificationStamp(source); |
| 5017 int resultTime = library.getModificationTime(source); |
| 5018 if (sourceTime != resultTime) { |
| 5019 // The source has changed without the context being notified. Simulate
notification. |
| 5020 _sourceChanged(source); |
| 5021 allTimesMatch = false; |
| 5022 } |
| 5023 } |
| 5024 } |
| 5025 return allTimesMatch; |
| 5026 } |
| 5027 |
| 5028 /** |
| 5029 * Return `true` if the modification times of the sources used by the given li
brary resolver |
| 5030 * to resolve one or more libraries are consistent with the modification times
in the cache. |
| 5031 * |
| 5032 * @param resolver the library resolver used to resolve one or more libraries |
| 5033 * @return `true` if we should record the results of the resolution |
| 5034 * @throws AnalysisException if any of the modification times could not be det
ermined (this should |
| 5035 * not happen) |
| 5036 */ |
| 5037 bool _allModificationTimesMatch2(Set<Library> resolvedLibraries) { |
4790 bool allTimesMatch = true; | 5038 bool allTimesMatch = true; |
4791 for (Library library in resolvedLibraries) { | 5039 for (Library library in resolvedLibraries) { |
4792 for (Source source in library.compilationUnitSources) { | 5040 for (Source source in library.compilationUnitSources) { |
4793 DartEntry dartEntry = _getReadableDartEntry(source); | 5041 DartEntry dartEntry = _getReadableDartEntry(source); |
4794 if (dartEntry == null) { | 5042 if (dartEntry == null) { |
4795 // This shouldn't be possible because we should never have performed t
he task if the | 5043 // This shouldn't be possible because we should never have performed t
he task if the |
4796 // source didn't represent a Dart file, but check to be safe. | 5044 // source didn't represent a Dart file, but check to be safe. |
4797 throw new AnalysisException.con1("Internal error: attempting to resolv
e non-Dart file as a Dart file: ${source.fullName}"); | 5045 throw new AnalysisException.con1("Internal error: attempting to resolv
e non-Dart file as a Dart file: ${source.fullName}"); |
4798 } | 5046 } |
4799 int sourceTime = getModificationStamp(source); | 5047 int sourceTime = getModificationStamp(source); |
4800 int resultTime = library.getModificationTime(source); | 5048 int resultTime = library.getModificationTime(source); |
4801 if (sourceTime != resultTime) { | 5049 if (sourceTime != resultTime) { |
4802 // The source has changed without the context being notified. Simulate
notification. | 5050 // The source has changed without the context being notified. Simulate
notification. |
4803 _sourceChanged(source); | 5051 _sourceChanged(source); |
4804 allTimesMatch = false; | 5052 allTimesMatch = false; |
4805 } | 5053 } |
4806 } | 5054 } |
4807 } | 5055 } |
4808 return allTimesMatch; | 5056 return allTimesMatch; |
4809 } | 5057 } |
4810 | 5058 |
4811 /** | 5059 /** |
4812 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 5060 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
4813 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or | 5061 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
4814 * [CacheState#ERROR]. This method assumes that the data can be produced by ge
nerating hints | 5062 * [CacheState#ERROR]. This method assumes that the data can be produced by ge
nerating hints |
4815 * for the library if the data is not already cached. | 5063 * for the library if the data is not already cached. |
4816 * | 5064 * |
| 5065 * <b>Note:</b> This method cannot be used in an async environment. |
| 5066 * |
4817 * @param unitSource the source representing the Dart file | 5067 * @param unitSource the source representing the Dart file |
4818 * @param librarySource the source representing the library containing the Dar
t file | 5068 * @param librarySource the source representing the library containing the Dar
t file |
4819 * @param dartEntry the cache entry associated with the Dart file | 5069 * @param dartEntry the cache entry associated with the Dart file |
4820 * @param descriptor the descriptor representing the data to be returned | 5070 * @param descriptor the descriptor representing the data to be returned |
4821 * @return a cache entry containing the required data | 5071 * @return a cache entry containing the required data |
4822 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5072 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
4823 */ | 5073 */ |
4824 DartEntry _cacheDartHintData(Source unitSource, Source librarySource, DartEntr
y dartEntry, DataDescriptor descriptor) { | 5074 DartEntry _cacheDartHintData(Source unitSource, Source librarySource, DartEntr
y dartEntry, DataDescriptor descriptor) { |
4825 // | 5075 // |
4826 // Check to see whether we already have the information being requested. | 5076 // Check to see whether we already have the information being requested. |
4827 // | 5077 // |
4828 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); | 5078 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); |
4829 while (state != CacheState.ERROR && state != CacheState.VALID) { | 5079 while (state != CacheState.ERROR && state != CacheState.VALID) { |
4830 // | 5080 // |
4831 // If not, compute the information. Unless the modification date of the so
urce continues to | 5081 // If not, compute the information. Unless the modification date of the so
urce continues to |
4832 // change, this loop will eventually terminate. | 5082 // change, this loop will eventually terminate. |
4833 // | 5083 // |
4834 dartEntry = new GenerateDartHintsTask(this, getLibraryElement(librarySourc
e)).perform(_resultRecorder) as DartEntry; | 5084 DartEntry libraryEntry = _getReadableDartEntry(librarySource); |
| 5085 libraryEntry = _cacheDartResolutionData(librarySource, librarySource, libr
aryEntry, DartEntry.ELEMENT); |
| 5086 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
| 5087 CompilationUnitElement definingUnit = libraryElement.definingCompilationUn
it; |
| 5088 List<CompilationUnitElement> parts = libraryElement.parts; |
| 5089 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(p
arts.length + 1); |
| 5090 units[0] = _getResolvedUnit(definingUnit, librarySource); |
| 5091 if (units[0] == null) { |
| 5092 Source source = definingUnit.source; |
| 5093 units[0] = new TimestampedData<CompilationUnit>(getModificationStamp(sou
rce), resolveCompilationUnit(source, libraryElement)); |
| 5094 } |
| 5095 for (int i = 0; i < parts.length; i++) { |
| 5096 units[i + 1] = _getResolvedUnit(parts[i], librarySource); |
| 5097 if (units[i + 1] == null) { |
| 5098 Source source = parts[i].source; |
| 5099 units[i + 1] = new TimestampedData<CompilationUnit>(getModificationSta
mp(source), resolveCompilationUnit(source, libraryElement)); |
| 5100 } |
| 5101 } |
| 5102 dartEntry = new GenerateDartHintsTask(this, units, getLibraryElement(libra
rySource)).perform(_resultRecorder) as DartEntry; |
4835 state = dartEntry.getStateInLibrary(descriptor, librarySource); | 5103 state = dartEntry.getStateInLibrary(descriptor, librarySource); |
4836 } | 5104 } |
4837 return dartEntry; | 5105 return dartEntry; |
4838 } | 5106 } |
4839 | 5107 |
4840 /** | 5108 /** |
4841 * Given a source for a Dart file, return a cache entry in which the state of
the data represented | 5109 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
4842 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This | 5110 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This |
4843 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 5111 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
4844 * | 5112 * |
4845 * <b>Note:</b> This method cannot be used in an async environment | 5113 * <b>Note:</b> This method cannot be used in an async environment. |
4846 * | 5114 * |
4847 * @param source the source representing the Dart file | 5115 * @param source the source representing the Dart file |
4848 * @param dartEntry the cache entry associated with the Dart file | 5116 * @param dartEntry the cache entry associated with the Dart file |
4849 * @param descriptor the descriptor representing the data to be returned | 5117 * @param descriptor the descriptor representing the data to be returned |
4850 * @return a cache entry containing the required data | 5118 * @return a cache entry containing the required data |
4851 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5119 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
4852 */ | 5120 */ |
4853 DartEntry _cacheDartParseData(Source source, DartEntry dartEntry, DataDescript
or descriptor) { | 5121 DartEntry _cacheDartParseData(Source source, DartEntry dartEntry, DataDescript
or descriptor) { |
4854 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 5122 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
4855 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; | 5123 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
(...skipping 16 matching lines...) Expand all Loading... |
4872 } | 5140 } |
4873 return dartEntry; | 5141 return dartEntry; |
4874 } | 5142 } |
4875 | 5143 |
4876 /** | 5144 /** |
4877 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 5145 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
4878 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or | 5146 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
4879 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the | 5147 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the |
4880 * source in the context of the library if it is not already cached. | 5148 * source in the context of the library if it is not already cached. |
4881 * | 5149 * |
| 5150 * <b>Note:</b> This method cannot be used in an async environment. |
| 5151 * |
4882 * @param unitSource the source representing the Dart file | 5152 * @param unitSource the source representing the Dart file |
4883 * @param librarySource the source representing the library containing the Dar
t file | 5153 * @param librarySource the source representing the library containing the Dar
t file |
4884 * @param dartEntry the cache entry associated with the Dart file | 5154 * @param dartEntry the cache entry associated with the Dart file |
4885 * @param descriptor the descriptor representing the data to be returned | 5155 * @param descriptor the descriptor representing the data to be returned |
4886 * @return a cache entry containing the required data | 5156 * @return a cache entry containing the required data |
4887 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5157 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
4888 */ | 5158 */ |
4889 DartEntry _cacheDartResolutionData(Source unitSource, Source librarySource, Da
rtEntry dartEntry, DataDescriptor descriptor) { | 5159 DartEntry _cacheDartResolutionData(Source unitSource, Source librarySource, Da
rtEntry dartEntry, DataDescriptor descriptor) { |
4890 // | 5160 // |
4891 // Check to see whether we already have the information being requested. | 5161 // Check to see whether we already have the information being requested. |
(...skipping 11 matching lines...) Expand all Loading... |
4903 } | 5173 } |
4904 return dartEntry; | 5174 return dartEntry; |
4905 } | 5175 } |
4906 | 5176 |
4907 /** | 5177 /** |
4908 * Given a source for a Dart file, return a cache entry in which the state of
the data represented | 5178 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
4909 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This | 5179 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This |
4910 * method assumes that the data can be produced by scanning the source if it i
s not already | 5180 * method assumes that the data can be produced by scanning the source if it i
s not already |
4911 * cached. | 5181 * cached. |
4912 * | 5182 * |
4913 * <b>Note:</b> This method cannot be used in an async environment | 5183 * <b>Note:</b> This method cannot be used in an async environment. |
4914 * | 5184 * |
4915 * @param source the source representing the Dart file | 5185 * @param source the source representing the Dart file |
4916 * @param dartEntry the cache entry associated with the Dart file | 5186 * @param dartEntry the cache entry associated with the Dart file |
4917 * @param descriptor the descriptor representing the data to be returned | 5187 * @param descriptor the descriptor representing the data to be returned |
4918 * @return a cache entry containing the required data | 5188 * @return a cache entry containing the required data |
4919 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 5189 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
4920 */ | 5190 */ |
4921 DartEntry _cacheDartScanData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { | 5191 DartEntry _cacheDartScanData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { |
4922 // | 5192 // |
4923 // Check to see whether we already have the information being requested. | 5193 // Check to see whether we already have the information being requested. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4961 DartEntry _cacheDartVerificationData(Source unitSource, Source librarySource,
DartEntry dartEntry, DataDescriptor descriptor) { | 5231 DartEntry _cacheDartVerificationData(Source unitSource, Source librarySource,
DartEntry dartEntry, DataDescriptor descriptor) { |
4962 // | 5232 // |
4963 // Check to see whether we already have the information being requested. | 5233 // Check to see whether we already have the information being requested. |
4964 // | 5234 // |
4965 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); | 5235 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); |
4966 while (state != CacheState.ERROR && state != CacheState.VALID) { | 5236 while (state != CacheState.ERROR && state != CacheState.VALID) { |
4967 // | 5237 // |
4968 // If not, compute the information. Unless the modification date of the so
urce continues to | 5238 // If not, compute the information. Unless the modification date of the so
urce continues to |
4969 // change, this loop will eventually terminate. | 5239 // change, this loop will eventually terminate. |
4970 // | 5240 // |
4971 dartEntry = new GenerateDartErrorsTask(this, unitSource, getLibraryElement
(librarySource)).perform(_resultRecorder) as DartEntry; | 5241 LibraryElement library = computeLibraryElement(librarySource); |
| 5242 dartEntry = new GenerateDartErrorsTask(this, unitSource, dartEntry.modific
ationTime, resolveCompilationUnit(unitSource, library), library).perform(_result
Recorder) as DartEntry; |
4972 state = dartEntry.getStateInLibrary(descriptor, librarySource); | 5243 state = dartEntry.getStateInLibrary(descriptor, librarySource); |
4973 } | 5244 } |
4974 return dartEntry; | 5245 return dartEntry; |
4975 } | 5246 } |
4976 | 5247 |
4977 /** | 5248 /** |
4978 * Given a source for an HTML file, return a cache entry in which all of the d
ata represented by | 5249 * Given a source for an HTML file, return a cache entry in which all of the d
ata represented by |
4979 * the state of the given descriptors is either [CacheState#VALID] or | 5250 * the state of the given descriptors is either [CacheState#VALID] or |
4980 * [CacheState#ERROR]. This method assumes that the data can be produced by pa
rsing the | 5251 * [CacheState#ERROR]. This method assumes that the data can be produced by pa
rsing the |
4981 * source if it is not already cached. | 5252 * source if it is not already cached. |
4982 * | 5253 * |
4983 * <b>Note:</b> This method cannot be used in an async environment | 5254 * <b>Note:</b> This method cannot be used in an async environment. |
4984 * | 5255 * |
4985 * @param source the source representing the HTML file | 5256 * @param source the source representing the HTML file |
4986 * @param htmlEntry the cache entry associated with the HTML file | 5257 * @param htmlEntry the cache entry associated with the HTML file |
4987 * @param descriptor the descriptor representing the data to be returned | 5258 * @param descriptor the descriptor representing the data to be returned |
4988 * @return a cache entry containing the required data | 5259 * @return a cache entry containing the required data |
4989 * @throws AnalysisException if data could not be returned because the source
could not be | 5260 * @throws AnalysisException if data could not be returned because the source
could not be |
4990 * resolved | 5261 * resolved |
4991 */ | 5262 */ |
4992 HtmlEntry _cacheHtmlParseData(Source source, HtmlEntry htmlEntry, DataDescript
or descriptor) { | 5263 HtmlEntry _cacheHtmlParseData(Source source, HtmlEntry htmlEntry, DataDescript
or descriptor) { |
4993 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 5264 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
(...skipping 25 matching lines...) Expand all Loading... |
5019 } | 5290 } |
5020 return htmlEntry; | 5291 return htmlEntry; |
5021 } | 5292 } |
5022 | 5293 |
5023 /** | 5294 /** |
5024 * Given a source for an HTML file, return a cache entry in which the state of
the data | 5295 * Given a source for an HTML file, return a cache entry in which the state of
the data |
5025 * represented by the given descriptor is either [CacheState#VALID] or | 5296 * represented by the given descriptor is either [CacheState#VALID] or |
5026 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the | 5297 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the |
5027 * source if it is not already cached. | 5298 * source if it is not already cached. |
5028 * | 5299 * |
5029 * <b>Note:</b> This method cannot be used in an async environment | 5300 * <b>Note:</b> This method cannot be used in an async environment. |
5030 * | 5301 * |
5031 * @param source the source representing the HTML file | 5302 * @param source the source representing the HTML file |
5032 * @param dartEntry the cache entry associated with the HTML file | 5303 * @param dartEntry the cache entry associated with the HTML file |
5033 * @param descriptor the descriptor representing the data to be returned | 5304 * @param descriptor the descriptor representing the data to be returned |
5034 * @return a cache entry containing the required data | 5305 * @return a cache entry containing the required data |
5035 * @throws AnalysisException if data could not be returned because the source
could not be | 5306 * @throws AnalysisException if data could not be returned because the source
could not be |
5036 * resolved | 5307 * resolved |
5037 */ | 5308 */ |
5038 HtmlEntry _cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataDes
criptor descriptor) { | 5309 HtmlEntry _cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataDes
criptor descriptor) { |
5039 // | 5310 // |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5086 bool _containsAny(List<Source> sources, List<Source> targetSources) { | 5357 bool _containsAny(List<Source> sources, List<Source> targetSources) { |
5087 for (Source targetSource in targetSources) { | 5358 for (Source targetSource in targetSources) { |
5088 if (_contains(sources, targetSource)) { | 5359 if (_contains(sources, targetSource)) { |
5089 return true; | 5360 return true; |
5090 } | 5361 } |
5091 } | 5362 } |
5092 return false; | 5363 return false; |
5093 } | 5364 } |
5094 | 5365 |
5095 /** | 5366 /** |
| 5367 * Create a [GenerateDartErrorsTask] for the given source, marking the verific
ation errors |
| 5368 * as being in-process. |
| 5369 * |
| 5370 * @param source the source whose content is to be verified |
| 5371 * @param dartEntry the entry for the source |
| 5372 * @param librarySource the source for the library containing the source |
| 5373 * @param libraryEntry the entry for the library |
| 5374 * @return task data representing the created task |
| 5375 */ |
| 5376 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source source, Dart
Entry dartEntry, Source librarySource, SourceEntry libraryEntry) { |
| 5377 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C
acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID)
{ |
| 5378 } |
| 5379 CompilationUnit unit = dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT,
librarySource); |
| 5380 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
| 5381 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5382 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Cac
heState.IN_PROCESS); |
| 5383 _cache.put(source, dartCopy); |
| 5384 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, sou
rce, dartCopy.modificationTime, unit, libraryElement), false); |
| 5385 } |
| 5386 |
| 5387 /** |
| 5388 * Create a [GenerateDartHintsTask] for the given source, marking the hints as
being |
| 5389 * in-process. |
| 5390 * |
| 5391 * @param source the source whose content is to be verified |
| 5392 * @param dartEntry the entry for the source |
| 5393 * @param librarySource the source for the library containing the source |
| 5394 * @param libraryEntry the entry for the library |
| 5395 * @return task data representing the created task |
| 5396 */ |
| 5397 AnalysisContextImpl_TaskData _createGenerateDartHintsTask(Source source, DartE
ntry dartEntry, Source librarySource, DartEntry libraryEntry) { |
| 5398 if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { |
| 5399 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
| 5400 } |
| 5401 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
| 5402 CompilationUnitElement definingUnit = libraryElement.definingCompilationUnit
; |
| 5403 List<CompilationUnitElement> parts = libraryElement.parts; |
| 5404 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(par
ts.length + 1); |
| 5405 units[0] = _getResolvedUnit(definingUnit, librarySource); |
| 5406 if (units[0] == null) { |
| 5407 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless the
re are multiple ASTs |
| 5408 // that need to be resolved. |
| 5409 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
| 5410 } |
| 5411 for (int i = 0; i < parts.length; i++) { |
| 5412 units[i + 1] = _getResolvedUnit(parts[i], librarySource); |
| 5413 if (units[i + 1] == null) { |
| 5414 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless t
here are multiple |
| 5415 // ASTs that need to be resolved. |
| 5416 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
| 5417 } |
| 5418 } |
| 5419 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5420 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.IN_PRO
CESS); |
| 5421 _cache.put(source, dartCopy); |
| 5422 return new AnalysisContextImpl_TaskData(new GenerateDartHintsTask(this, unit
s, libraryElement), false); |
| 5423 } |
| 5424 |
| 5425 /** |
5096 * Create a [GetContentTask] for the given source, marking the content as bein
g in-process. | 5426 * Create a [GetContentTask] for the given source, marking the content as bein
g in-process. |
5097 * | 5427 * |
5098 * @param source the source whose content is to be accessed | 5428 * @param source the source whose content is to be accessed |
5099 * @param sourceEntry the entry for the source | 5429 * @param sourceEntry the entry for the source |
5100 * @return task data representing the created task | 5430 * @return task data representing the created task |
5101 */ | 5431 */ |
5102 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntry
sourceEntry) { | 5432 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntry
sourceEntry) { |
5103 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 5433 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
5104 sourceCopy.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); | 5434 sourceCopy.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); |
5105 _cache.put(source, sourceCopy); | 5435 _cache.put(source, sourceCopy); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5178 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { | 5508 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { |
5179 return _createResolveHtmlTask(source, htmlEntry); | 5509 return _createResolveHtmlTask(source, htmlEntry); |
5180 } | 5510 } |
5181 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5511 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
5182 htmlCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS); | 5512 htmlCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS); |
5183 _cache.put(source, htmlCopy); | 5513 _cache.put(source, htmlCopy); |
5184 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTask(this
, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.RESOLVED_UNIT))
, false); | 5514 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTask(this
, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.RESOLVED_UNIT))
, false); |
5185 } | 5515 } |
5186 | 5516 |
5187 /** | 5517 /** |
| 5518 * Create a [ResolveDartLibraryTask] for the given source, marking the element
model as |
| 5519 * being in-process. |
| 5520 * |
| 5521 * @param source the source whose content is to be resolved |
| 5522 * @param dartEntry the entry for the source |
| 5523 * @return task data representing the created task |
| 5524 */ |
| 5525 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, Dart
Entry dartEntry) { |
| 5526 try { |
| 5527 AnalysisContextImpl_CycleBuilder builder = new AnalysisContextImpl_CycleBu
ilder(this); |
| 5528 builder.computeCycleContaining(source); |
| 5529 AnalysisContextImpl_TaskData taskData = builder.taskData; |
| 5530 if (taskData != null) { |
| 5531 return taskData; |
| 5532 } |
| 5533 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask(th
is, source, source, builder.librariesInCycle), false); |
| 5534 } on AnalysisException catch (exception) { |
| 5535 AnalysisEngine.instance.logger.logError2("Internal error trying to compute
the next analysis task", exception); |
| 5536 } |
| 5537 return new AnalysisContextImpl_TaskData(null, false); |
| 5538 } |
| 5539 |
| 5540 /** |
5188 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit
as being | 5541 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit
as being |
5189 * in-process. | 5542 * in-process. |
5190 * | 5543 * |
5191 * @param source the source whose content is to be resolved | 5544 * @param source the source whose content is to be resolved |
5192 * @param htmlEntry the entry for the source | 5545 * @param htmlEntry the entry for the source |
5193 * @return task data representing the created task | 5546 * @return task data representing the created task |
5194 */ | 5547 */ |
5195 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntry h
tmlEntry) { | 5548 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntry h
tmlEntry) { |
5196 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { | 5549 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { |
5197 return _createParseHtmlTask(source, htmlEntry); | 5550 return _createParseHtmlTask(source, htmlEntry); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5271 List<ChangeNotice> notices = new List.from(_pendingNotices.values); | 5624 List<ChangeNotice> notices = new List.from(_pendingNotices.values); |
5272 _pendingNotices.clear(); | 5625 _pendingNotices.clear(); |
5273 return notices; | 5626 return notices; |
5274 } | 5627 } |
5275 | 5628 |
5276 /** | 5629 /** |
5277 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5630 * Given a source for a Dart file and the library that contains it, return the
data represented by |
5278 * the given descriptor that is associated with that source. This method assum
es that the data can | 5631 * the given descriptor that is associated with that source. This method assum
es that the data can |
5279 * be produced by generating hints for the library if it is not already cached
. | 5632 * be produced by generating hints for the library if it is not already cached
. |
5280 * | 5633 * |
| 5634 * <b>Note:</b> This method cannot be used in an async environment. |
| 5635 * |
5281 * @param unitSource the source representing the Dart file | 5636 * @param unitSource the source representing the Dart file |
5282 * @param librarySource the source representing the library containing the Dar
t file | 5637 * @param librarySource the source representing the library containing the Dar
t file |
5283 * @param dartEntry the entry representing the Dart file | 5638 * @param dartEntry the entry representing the Dart file |
5284 * @param descriptor the descriptor representing the data to be returned | 5639 * @param descriptor the descriptor representing the data to be returned |
5285 * @return the requested data about the given source | 5640 * @return the requested data about the given source |
5286 * @throws AnalysisException if data could not be returned because the source
could not be | 5641 * @throws AnalysisException if data could not be returned because the source
could not be |
5287 * resolved | 5642 * resolved |
5288 */ | 5643 */ |
5289 Object _getDartHintData(Source unitSource, Source librarySource, DartEntry dar
tEntry, DataDescriptor descriptor) { | 5644 Object _getDartHintData(Source unitSource, Source librarySource, DartEntry dar
tEntry, DataDescriptor descriptor) { |
5290 dartEntry = _cacheDartHintData(unitSource, librarySource, dartEntry, descrip
tor); | 5645 dartEntry = _cacheDartHintData(unitSource, librarySource, dartEntry, descrip
tor); |
5291 if (identical(descriptor, DartEntry.ELEMENT)) { | 5646 if (identical(descriptor, DartEntry.ELEMENT)) { |
5292 return dartEntry.getValue(descriptor); | 5647 return dartEntry.getValue(descriptor); |
5293 } | 5648 } |
5294 return dartEntry.getValueInLibrary(descriptor, librarySource); | 5649 return dartEntry.getValueInLibrary(descriptor, librarySource); |
5295 } | 5650 } |
5296 | 5651 |
5297 /** | 5652 /** |
5298 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5653 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
5299 * associated with that source. This method assumes that the data can be produ
ced by parsing the | 5654 * associated with that source. This method assumes that the data can be produ
ced by parsing the |
5300 * source if it is not already cached. | 5655 * source if it is not already cached. |
5301 * | 5656 * |
5302 * <b>Note:</b> This method cannot be used in an async environment | 5657 * <b>Note:</b> This method cannot be used in an async environment. |
5303 * | 5658 * |
5304 * @param source the source representing the Dart file | 5659 * @param source the source representing the Dart file |
5305 * @param dartEntry the cache entry associated with the Dart file | 5660 * @param dartEntry the cache entry associated with the Dart file |
5306 * @param descriptor the descriptor representing the data to be returned | 5661 * @param descriptor the descriptor representing the data to be returned |
5307 * @return the requested data about the given source | 5662 * @return the requested data about the given source |
5308 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5663 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
5309 */ | 5664 */ |
5310 Object _getDartParseData(Source source, DartEntry dartEntry, DataDescriptor de
scriptor) { | 5665 Object _getDartParseData(Source source, DartEntry dartEntry, DataDescriptor de
scriptor) { |
5311 dartEntry = _cacheDartParseData(source, dartEntry, descriptor); | 5666 dartEntry = _cacheDartParseData(source, dartEntry, descriptor); |
5312 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 5667 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
5313 _accessedAst(source); | 5668 _accessedAst(source); |
5314 return dartEntry.anyParsedCompilationUnit; | 5669 return dartEntry.anyParsedCompilationUnit; |
5315 } | 5670 } |
5316 return dartEntry.getValue(descriptor); | 5671 return dartEntry.getValue(descriptor); |
5317 } | 5672 } |
5318 | 5673 |
5319 /** | 5674 /** |
5320 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5675 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
5321 * associated with that source, or the given default value if the source is no
t a Dart file. This | 5676 * associated with that source, or the given default value if the source is no
t a Dart file. This |
5322 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 5677 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
5323 * | 5678 * |
5324 * <b>Note:</b> This method cannot be used in an async environment | 5679 * <b>Note:</b> This method cannot be used in an async environment. |
5325 * | 5680 * |
5326 * @param source the source representing the Dart file | 5681 * @param source the source representing the Dart file |
5327 * @param descriptor the descriptor representing the data to be returned | 5682 * @param descriptor the descriptor representing the data to be returned |
5328 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5683 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
5329 * @return the requested data about the given source | 5684 * @return the requested data about the given source |
5330 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5685 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
5331 */ | 5686 */ |
5332 Object _getDartParseData2(Source source, DataDescriptor descriptor, Object def
aultValue) { | 5687 Object _getDartParseData2(Source source, DataDescriptor descriptor, Object def
aultValue) { |
5333 DartEntry dartEntry = _getReadableDartEntry(source); | 5688 DartEntry dartEntry = _getReadableDartEntry(source); |
5334 if (dartEntry == null) { | 5689 if (dartEntry == null) { |
5335 return defaultValue; | 5690 return defaultValue; |
5336 } | 5691 } |
5337 try { | 5692 try { |
5338 return _getDartParseData(source, dartEntry, descriptor); | 5693 return _getDartParseData(source, dartEntry, descriptor); |
5339 } on ObsoleteSourceAnalysisException catch (exception) { | 5694 } on ObsoleteSourceAnalysisException catch (exception) { |
5340 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); | 5695 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
5341 return defaultValue; | 5696 return defaultValue; |
5342 } | 5697 } |
5343 } | 5698 } |
5344 | 5699 |
5345 /** | 5700 /** |
5346 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5701 * Given a source for a Dart file and the library that contains it, return the
data represented by |
5347 * the given descriptor that is associated with that source. This method assum
es that the data can | 5702 * the given descriptor that is associated with that source. This method assum
es that the data can |
5348 * be produced by resolving the source in the context of the library if it is
not already cached. | 5703 * be produced by resolving the source in the context of the library if it is
not already cached. |
5349 * | 5704 * |
| 5705 * <b>Note:</b> This method cannot be used in an async environment. |
| 5706 * |
5350 * @param unitSource the source representing the Dart file | 5707 * @param unitSource the source representing the Dart file |
5351 * @param librarySource the source representing the library containing the Dar
t file | 5708 * @param librarySource the source representing the library containing the Dar
t file |
5352 * @param dartEntry the entry representing the Dart file | 5709 * @param dartEntry the entry representing the Dart file |
5353 * @param descriptor the descriptor representing the data to be returned | 5710 * @param descriptor the descriptor representing the data to be returned |
5354 * @return the requested data about the given source | 5711 * @return the requested data about the given source |
5355 * @throws AnalysisException if data could not be returned because the source
could not be | 5712 * @throws AnalysisException if data could not be returned because the source
could not be |
5356 * resolved | 5713 * resolved |
5357 */ | 5714 */ |
5358 Object _getDartResolutionData(Source unitSource, Source librarySource, DartEnt
ry dartEntry, DataDescriptor descriptor) { | 5715 Object _getDartResolutionData(Source unitSource, Source librarySource, DartEnt
ry dartEntry, DataDescriptor descriptor) { |
5359 dartEntry = _cacheDartResolutionData(unitSource, librarySource, dartEntry, d
escriptor); | 5716 dartEntry = _cacheDartResolutionData(unitSource, librarySource, dartEntry, d
escriptor); |
5360 if (identical(descriptor, DartEntry.ELEMENT)) { | 5717 if (identical(descriptor, DartEntry.ELEMENT)) { |
5361 return dartEntry.getValue(descriptor); | 5718 return dartEntry.getValue(descriptor); |
5362 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 5719 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
5363 _accessedAst(unitSource); | 5720 _accessedAst(unitSource); |
5364 } | 5721 } |
5365 return dartEntry.getValueInLibrary(descriptor, librarySource); | 5722 return dartEntry.getValueInLibrary(descriptor, librarySource); |
5366 } | 5723 } |
5367 | 5724 |
5368 /** | 5725 /** |
5369 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5726 * Given a source for a Dart file and the library that contains it, return the
data represented by |
5370 * the given descriptor that is associated with that source, or the given defa
ult value if the | 5727 * the given descriptor that is associated with that source, or the given defa
ult value if the |
5371 * source is not a Dart file. This method assumes that the data can be produce
d by resolving the | 5728 * source is not a Dart file. This method assumes that the data can be produce
d by resolving the |
5372 * source in the context of the library if it is not already cached. | 5729 * source in the context of the library if it is not already cached. |
5373 * | 5730 * |
| 5731 * <b>Note:</b> This method cannot be used in an async environment. |
| 5732 * |
5374 * @param unitSource the source representing the Dart file | 5733 * @param unitSource the source representing the Dart file |
5375 * @param librarySource the source representing the library containing the Dar
t file | 5734 * @param librarySource the source representing the library containing the Dar
t file |
5376 * @param descriptor the descriptor representing the data to be returned | 5735 * @param descriptor the descriptor representing the data to be returned |
5377 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5736 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
5378 * @return the requested data about the given source | 5737 * @return the requested data about the given source |
5379 * @throws AnalysisException if data could not be returned because the source
could not be | 5738 * @throws AnalysisException if data could not be returned because the source
could not be |
5380 * resolved | 5739 * resolved |
5381 */ | 5740 */ |
5382 Object _getDartResolutionData2(Source unitSource, Source librarySource, DataDe
scriptor descriptor, Object defaultValue) { | 5741 Object _getDartResolutionData2(Source unitSource, Source librarySource, DataDe
scriptor descriptor, Object defaultValue) { |
5383 DartEntry dartEntry = _getReadableDartEntry(unitSource); | 5742 DartEntry dartEntry = _getReadableDartEntry(unitSource); |
5384 if (dartEntry == null) { | 5743 if (dartEntry == null) { |
5385 return defaultValue; | 5744 return defaultValue; |
5386 } | 5745 } |
5387 try { | 5746 try { |
5388 return _getDartResolutionData(unitSource, librarySource, dartEntry, descri
ptor); | 5747 return _getDartResolutionData(unitSource, librarySource, dartEntry, descri
ptor); |
5389 } on ObsoleteSourceAnalysisException catch (exception) { | 5748 } on ObsoleteSourceAnalysisException catch (exception) { |
5390 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); | 5749 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
5391 return defaultValue; | 5750 return defaultValue; |
5392 } | 5751 } |
5393 } | 5752 } |
5394 | 5753 |
5395 /** | 5754 /** |
5396 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5755 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
5397 * associated with that source. This method assumes that the data can be produ
ced by scanning the | 5756 * associated with that source. This method assumes that the data can be produ
ced by scanning the |
5398 * source if it is not already cached. | 5757 * source if it is not already cached. |
5399 * | 5758 * |
5400 * <b>Note:</b> This method cannot be used in an async environment | 5759 * <b>Note:</b> This method cannot be used in an async environment. |
5401 * | 5760 * |
5402 * @param source the source representing the Dart file | 5761 * @param source the source representing the Dart file |
5403 * @param dartEntry the cache entry associated with the Dart file | 5762 * @param dartEntry the cache entry associated with the Dart file |
5404 * @param descriptor the descriptor representing the data to be returned | 5763 * @param descriptor the descriptor representing the data to be returned |
5405 * @return the requested data about the given source | 5764 * @return the requested data about the given source |
5406 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 5765 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
5407 */ | 5766 */ |
5408 Object _getDartScanData(Source source, DartEntry dartEntry, DataDescriptor des
criptor) { | 5767 Object _getDartScanData(Source source, DartEntry dartEntry, DataDescriptor des
criptor) { |
5409 dartEntry = _cacheDartScanData(source, dartEntry, descriptor); | 5768 dartEntry = _cacheDartScanData(source, dartEntry, descriptor); |
5410 return dartEntry.getValue(descriptor); | 5769 return dartEntry.getValue(descriptor); |
5411 } | 5770 } |
5412 | 5771 |
5413 /** | 5772 /** |
5414 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5773 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
5415 * associated with that source, or the given default value if the source is no
t a Dart file. This | 5774 * associated with that source, or the given default value if the source is no
t a Dart file. This |
5416 * method assumes that the data can be produced by scanning the source if it i
s not already | 5775 * method assumes that the data can be produced by scanning the source if it i
s not already |
5417 * cached. | 5776 * cached. |
5418 * | 5777 * |
5419 * <b>Note:</b> This method cannot be used in an async environment | 5778 * <b>Note:</b> This method cannot be used in an async environment. |
5420 * | 5779 * |
5421 * @param source the source representing the Dart file | 5780 * @param source the source representing the Dart file |
5422 * @param descriptor the descriptor representing the data to be returned | 5781 * @param descriptor the descriptor representing the data to be returned |
5423 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5782 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
5424 * @return the requested data about the given source | 5783 * @return the requested data about the given source |
5425 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 5784 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
5426 */ | 5785 */ |
5427 Object _getDartScanData2(Source source, DataDescriptor descriptor, Object defa
ultValue) { | 5786 Object _getDartScanData2(Source source, DataDescriptor descriptor, Object defa
ultValue) { |
5428 DartEntry dartEntry = _getReadableDartEntry(source); | 5787 DartEntry dartEntry = _getReadableDartEntry(source); |
5429 if (dartEntry == null) { | 5788 if (dartEntry == null) { |
(...skipping 25 matching lines...) Expand all Loading... |
5455 Object _getDartVerificationData(Source unitSource, Source librarySource, DartE
ntry dartEntry, DataDescriptor descriptor) { | 5814 Object _getDartVerificationData(Source unitSource, Source librarySource, DartE
ntry dartEntry, DataDescriptor descriptor) { |
5456 dartEntry = _cacheDartVerificationData(unitSource, librarySource, dartEntry,
descriptor); | 5815 dartEntry = _cacheDartVerificationData(unitSource, librarySource, dartEntry,
descriptor); |
5457 return dartEntry.getValueInLibrary(descriptor, librarySource); | 5816 return dartEntry.getValueInLibrary(descriptor, librarySource); |
5458 } | 5817 } |
5459 | 5818 |
5460 /** | 5819 /** |
5461 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 5820 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
5462 * associated with that source, or the given default value if the source is no
t an HTML file. This | 5821 * associated with that source, or the given default value if the source is no
t an HTML file. This |
5463 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 5822 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
5464 * | 5823 * |
5465 * <b>Note:</b> This method cannot be used in an async environment | 5824 * <b>Note:</b> This method cannot be used in an async environment. |
5466 * | 5825 * |
5467 * @param source the source representing the Dart file | 5826 * @param source the source representing the Dart file |
5468 * @param descriptor the descriptor representing the data to be returned | 5827 * @param descriptor the descriptor representing the data to be returned |
5469 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 5828 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
5470 * @return the requested data about the given source | 5829 * @return the requested data about the given source |
5471 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5830 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
5472 */ | 5831 */ |
5473 Object _getHtmlParseData(Source source, DataDescriptor descriptor, Object defa
ultValue) { | 5832 Object _getHtmlParseData(Source source, DataDescriptor descriptor, Object defa
ultValue) { |
5474 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); | 5833 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); |
5475 if (htmlEntry == null) { | 5834 if (htmlEntry == null) { |
5476 return defaultValue; | 5835 return defaultValue; |
5477 } | 5836 } |
5478 htmlEntry = _cacheHtmlParseData(source, htmlEntry, descriptor); | 5837 htmlEntry = _cacheHtmlParseData(source, htmlEntry, descriptor); |
5479 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 5838 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
5480 _accessedAst(source); | 5839 _accessedAst(source); |
5481 return htmlEntry.anyParsedUnit; | 5840 return htmlEntry.anyParsedUnit; |
5482 } | 5841 } |
5483 return htmlEntry.getValue(descriptor); | 5842 return htmlEntry.getValue(descriptor); |
5484 } | 5843 } |
5485 | 5844 |
5486 /** | 5845 /** |
5487 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 5846 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
5488 * associated with that source, or the given default value if the source is no
t an HTML file. This | 5847 * associated with that source, or the given default value if the source is no
t an HTML file. This |
5489 * method assumes that the data can be produced by resolving the source if it
is not already | 5848 * method assumes that the data can be produced by resolving the source if it
is not already |
5490 * cached. | 5849 * cached. |
5491 * | 5850 * |
5492 * <b>Note:</b> This method cannot be used in an async environment | 5851 * <b>Note:</b> This method cannot be used in an async environment. |
5493 * | 5852 * |
5494 * @param source the source representing the HTML file | 5853 * @param source the source representing the HTML file |
5495 * @param descriptor the descriptor representing the data to be returned | 5854 * @param descriptor the descriptor representing the data to be returned |
5496 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 5855 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
5497 * @return the requested data about the given source | 5856 * @return the requested data about the given source |
5498 * @throws AnalysisException if data could not be returned because the source
could not be | 5857 * @throws AnalysisException if data could not be returned because the source
could not be |
5499 * resolved | 5858 * resolved |
5500 */ | 5859 */ |
5501 Object _getHtmlResolutionData(Source source, DataDescriptor descriptor, Object
defaultValue) { | 5860 Object _getHtmlResolutionData(Source source, DataDescriptor descriptor, Object
defaultValue) { |
5502 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); | 5861 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); |
5503 if (htmlEntry == null) { | 5862 if (htmlEntry == null) { |
5504 return defaultValue; | 5863 return defaultValue; |
5505 } | 5864 } |
5506 try { | 5865 try { |
5507 return _getHtmlResolutionData2(source, htmlEntry, descriptor); | 5866 return _getHtmlResolutionData2(source, htmlEntry, descriptor); |
5508 } on ObsoleteSourceAnalysisException catch (exception) { | 5867 } on ObsoleteSourceAnalysisException catch (exception) { |
5509 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); | 5868 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
5510 return defaultValue; | 5869 return defaultValue; |
5511 } | 5870 } |
5512 } | 5871 } |
5513 | 5872 |
5514 /** | 5873 /** |
5515 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 5874 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
5516 * associated with that source. This method assumes that the data can be produ
ced by resolving the | 5875 * associated with that source. This method assumes that the data can be produ
ced by resolving the |
5517 * source if it is not already cached. | 5876 * source if it is not already cached. |
5518 * | 5877 * |
5519 * <b>Note:</b> This method cannot be used in an async environment | 5878 * <b>Note:</b> This method cannot be used in an async environment. |
5520 * | 5879 * |
5521 * @param source the source representing the HTML file | 5880 * @param source the source representing the HTML file |
5522 * @param htmlEntry the entry representing the HTML file | 5881 * @param htmlEntry the entry representing the HTML file |
5523 * @param descriptor the descriptor representing the data to be returned | 5882 * @param descriptor the descriptor representing the data to be returned |
5524 * @return the requested data about the given source | 5883 * @return the requested data about the given source |
5525 * @throws AnalysisException if data could not be returned because the source
could not be | 5884 * @throws AnalysisException if data could not be returned because the source
could not be |
5526 * resolved | 5885 * resolved |
5527 */ | 5886 */ |
5528 Object _getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, DataDescrip
tor descriptor) { | 5887 Object _getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, DataDescrip
tor descriptor) { |
5529 htmlEntry = _cacheHtmlResolutionData(source, htmlEntry, descriptor); | 5888 htmlEntry = _cacheHtmlResolutionData(source, htmlEntry, descriptor); |
5530 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | 5889 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
5531 _accessedAst(source); | 5890 _accessedAst(source); |
5532 } | 5891 } |
5533 return htmlEntry.getValue(descriptor); | 5892 return htmlEntry.getValue(descriptor); |
5534 } | 5893 } |
5535 | 5894 |
5536 /** | 5895 /** |
5537 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, | 5896 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, |
5538 * or `null` if there is no more work to be done. | 5897 * or `null` if there is no more work to be done. |
5539 * | 5898 * |
5540 * @return the next task that needs to be performed | 5899 * @return the next task that needs to be performed |
5541 */ | 5900 */ |
5542 AnalysisTask get nextAnalysisTask { | 5901 AnalysisTask get nextAnalysisTask { |
5543 bool hintsEnabled = _options.hint; | 5902 bool hintsEnabled = _options.hint; |
5544 bool sdkErrorsEnabled = _options.generateSdkErrors; | |
5545 bool hasBlockedTask = false; | 5903 bool hasBlockedTask = false; |
5546 // | 5904 // |
5547 // Look for incremental analysis | 5905 // Look for incremental analysis |
5548 // | 5906 // |
5549 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork)
{ | 5907 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork)
{ |
5550 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalysis
Cache); | 5908 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalysis
Cache); |
5551 _incrementalAnalysisCache = null; | 5909 _incrementalAnalysisCache = null; |
5552 return task; | 5910 return task; |
5553 } | 5911 } |
5554 // | 5912 // |
5555 // Look for a priority source that needs to be analyzed. | 5913 // Look for a priority source that needs to be analyzed. |
5556 // | 5914 // |
5557 for (Source source in _priorityOrder) { | 5915 int priorityCount = _priorityOrder.length; |
5558 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(sour
ce, _cache.get(source), true, hintsEnabled, sdkErrorsEnabled); | 5916 for (int i = 0; i < priorityCount; i++) { |
| 5917 Source source = _priorityOrder[i]; |
| 5918 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(sour
ce, _cache.get(source), true, hintsEnabled); |
5559 AnalysisTask task = taskData.task; | 5919 AnalysisTask task = taskData.task; |
5560 if (task != null) { | 5920 if (task != null) { |
5561 return task; | 5921 return task; |
5562 } else if (taskData.isBlocked) { | 5922 } else if (taskData.isBlocked) { |
5563 hasBlockedTask = true; | 5923 hasBlockedTask = true; |
5564 } | 5924 } |
5565 } | 5925 } |
| 5926 if (_neededForResolution != null) { |
| 5927 for (Source source in _neededForResolution) { |
| 5928 SourceEntry sourceEntry = _cache.get(source); |
| 5929 if (sourceEntry is DartEntry) { |
| 5930 DartEntry dartEntry = sourceEntry; |
| 5931 if (!dartEntry.hasResolvableCompilationUnit) { |
| 5932 AnalysisContextImpl_TaskData taskData = _createParseDartTask(source,
dartEntry); |
| 5933 AnalysisTask task = taskData.task; |
| 5934 if (task != null) { |
| 5935 return task; |
| 5936 } else if (taskData.isBlocked) { |
| 5937 hasBlockedTask = true; |
| 5938 } |
| 5939 } |
| 5940 } |
| 5941 } |
| 5942 } |
5566 // | 5943 // |
5567 // Look for a non-priority source that needs to be analyzed. | 5944 // Look for a non-priority source that needs to be analyzed. |
5568 // | 5945 // |
5569 List<Source> sourcesToRemove = new List<Source>(); | 5946 List<Source> sourcesToRemove = new List<Source>(); |
5570 WorkManager_WorkIterator sources = _workManager.iterator(); | 5947 WorkManager_WorkIterator sources = _workManager.iterator(); |
5571 while (sources.hasNext) { | 5948 while (sources.hasNext) { |
5572 Source source = sources.next(); | 5949 Source source = sources.next(); |
5573 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(sour
ce, _cache.get(source), false, hintsEnabled, sdkErrorsEnabled); | 5950 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(sour
ce, _cache.get(source), false, hintsEnabled); |
5574 AnalysisTask task = taskData.task; | 5951 AnalysisTask task = taskData.task; |
5575 if (task != null) { | 5952 if (task != null) { |
| 5953 int count = sourcesToRemove.length; |
| 5954 for (int i = 0; i < count; i++) { |
| 5955 _workManager.remove(sourcesToRemove[i]); |
| 5956 } |
5576 return task; | 5957 return task; |
5577 } else if (taskData.isBlocked) { | 5958 } else if (taskData.isBlocked) { |
5578 hasBlockedTask = true; | 5959 hasBlockedTask = true; |
5579 } else { | 5960 } else { |
5580 sourcesToRemove.add(source); | 5961 sourcesToRemove.add(source); |
5581 } | 5962 } |
5582 } | 5963 } |
5583 int count = sourcesToRemove.length; | 5964 int count = sourcesToRemove.length; |
5584 for (int i = 0; i < count; i++) { | 5965 for (int i = 0; i < count; i++) { |
5585 _workManager.remove(sourcesToRemove[i]); | 5966 _workManager.remove(sourcesToRemove[i]); |
(...skipping 21 matching lines...) Expand all Loading... |
5607 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the | 5988 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the |
5608 * task that should be performed, or `null` if there is no more work to be don
e for the | 5989 * task that should be performed, or `null` if there is no more work to be don
e for the |
5609 * source. | 5990 * source. |
5610 * | 5991 * |
5611 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5992 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
5612 * | 5993 * |
5613 * @param source the source to be checked | 5994 * @param source the source to be checked |
5614 * @param sourceEntry the cache entry associated with the source | 5995 * @param sourceEntry the cache entry associated with the source |
5615 * @param isPriority `true` if the source is a priority source | 5996 * @param isPriority `true` if the source is a priority source |
5616 * @param hintsEnabled `true` if hints are currently enabled | 5997 * @param hintsEnabled `true` if hints are currently enabled |
5617 * @param sdkErrorsEnabled `true` if errors, warnings and hints should be gene
rated for | |
5618 * sources in the SDK | |
5619 * @return the next task that needs to be performed for the given source | 5998 * @return the next task that needs to be performed for the given source |
5620 */ | 5999 */ |
5621 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, Sour
ceEntry sourceEntry, bool isPriority, bool hintsEnabled, bool sdkErrorsEnabled)
{ | 6000 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, Sour
ceEntry sourceEntry, bool isPriority, bool hintsEnabled) { |
5622 if (sourceEntry == null) { | 6001 if (sourceEntry == null) { |
5623 return new AnalysisContextImpl_TaskData(null, false); | 6002 return new AnalysisContextImpl_TaskData(null, false); |
5624 } | 6003 } |
5625 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); | 6004 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); |
5626 if (identical(contentState, CacheState.INVALID)) { | 6005 if (identical(contentState, CacheState.INVALID)) { |
5627 return _createGetContentTask(source, sourceEntry); | 6006 return _createGetContentTask(source, sourceEntry); |
5628 } else if (identical(contentState, CacheState.IN_PROCESS)) { | 6007 } else if (identical(contentState, CacheState.IN_PROCESS)) { |
5629 // We are already in the process of getting the content. There's nothing e
lse we can do with | 6008 // We are already in the process of getting the content. There's nothing e
lse we can do with |
5630 // this source until that's complete. | 6009 // this source until that's complete. |
5631 return new AnalysisContextImpl_TaskData(null, true); | 6010 return new AnalysisContextImpl_TaskData(null, true); |
(...skipping 10 matching lines...) Expand all Loading... |
5642 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 6021 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
5643 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 6022 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
5644 return _createParseDartTask(source, dartEntry); | 6023 return _createParseDartTask(source, dartEntry); |
5645 } | 6024 } |
5646 if (isPriority && parseErrorsState != CacheState.ERROR) { | 6025 if (isPriority && parseErrorsState != CacheState.ERROR) { |
5647 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; | 6026 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; |
5648 if (parseUnit == null) { | 6027 if (parseUnit == null) { |
5649 return _createParseDartTask(source, dartEntry); | 6028 return _createParseDartTask(source, dartEntry); |
5650 } | 6029 } |
5651 } | 6030 } |
| 6031 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); |
| 6032 if (identical(kind, SourceKind.UNKNOWN)) { |
| 6033 return _createParseDartTask(source, dartEntry); |
| 6034 } else if (identical(kind, SourceKind.LIBRARY)) { |
| 6035 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 6036 if (identical(elementState, CacheState.INVALID)) { |
| 6037 return _createResolveDartLibraryTask(source, dartEntry); |
| 6038 } |
| 6039 } |
5652 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); | 6040 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); |
5653 for (Source librarySource in librariesContaining) { | 6041 for (Source librarySource in librariesContaining) { |
5654 SourceEntry libraryEntry = _cache.get(librarySource); | 6042 SourceEntry libraryEntry = _cache.get(librarySource); |
5655 if (libraryEntry is DartEntry) { | 6043 if (libraryEntry is DartEntry) { |
5656 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 6044 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
5657 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { | 6045 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { |
| 6046 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); |
5658 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 6047 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
5659 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); | 6048 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); |
5660 _cache.put(librarySource, libraryCopy); | 6049 _cache.put(librarySource, libraryCopy); |
5661 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); | 6050 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); |
5662 } | 6051 } |
5663 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R
ESOLVED_UNIT, librarySource); | 6052 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R
ESOLVED_UNIT, librarySource); |
5664 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority &&
identical(resolvedUnitState, CacheState.FLUSHED))) { | 6053 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority &&
identical(resolvedUnitState, CacheState.FLUSHED))) { |
5665 // | 6054 // |
5666 // The commented out lines below are an optimization that doesn't qu
ite work yet. The | 6055 // The commented out lines below are an optimization that doesn't qu
ite work yet. The |
5667 // problem is that if the source was not resolved because it wasn't
part of any library, | 6056 // problem is that if the source was not resolved because it wasn't
part of any library, |
5668 // then there won't be any elements in the element model that we can
use to resolve it. | 6057 // then there won't be any elements in the element model that we can
use to resolve it. |
5669 // | 6058 // |
5670 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); | 6059 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); |
5671 //if (libraryElement != null) { | 6060 //if (libraryElement != null) { |
| 6061 // return new ResolveDartUnitTask(this, source, libraryElement); |
| 6062 //} |
| 6063 // Possibly replace with: return createResolveDartLibraryTask(librar
ySource, (DartEntry) libraryEntry); |
5672 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6064 DartEntryImpl dartCopy = dartEntry.writableCopy; |
5673 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, C
acheState.IN_PROCESS); | 6065 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, C
acheState.IN_PROCESS); |
5674 _cache.put(source, dartCopy); | 6066 _cache.put(source, dartCopy); |
5675 //return new ResolveDartUnitTask(this, source, libraryElement); | |
5676 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); | 6067 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); |
5677 } | 6068 } |
5678 if (sdkErrorsEnabled || !source.isInSystemLibrary) { | 6069 if (_generateSdkErrors || !source.isInSystemLibrary) { |
5679 CacheState verificationErrorsState = dartEntry.getStateInLibrary(Dar
tEntry.VERIFICATION_ERRORS, librarySource); | 6070 CacheState verificationErrorsState = dartEntry.getStateInLibrary(Dar
tEntry.VERIFICATION_ERRORS, librarySource); |
5680 if (identical(verificationErrorsState, CacheState.INVALID) || (isPri
ority && identical(verificationErrorsState, CacheState.FLUSHED))) { | 6071 if (identical(verificationErrorsState, CacheState.INVALID) || (isPri
ority && identical(verificationErrorsState, CacheState.FLUSHED))) { |
5681 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); | 6072 return _createGenerateDartErrorsTask(source, dartEntry, librarySou
rce, libraryEntry); |
5682 if (libraryElement != null) { | |
5683 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
5684 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librar
ySource, CacheState.IN_PROCESS); | |
5685 _cache.put(source, dartCopy); | |
5686 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTa
sk(this, source, libraryElement), false); | |
5687 } | |
5688 } | 6073 } |
5689 if (hintsEnabled) { | 6074 if (hintsEnabled) { |
5690 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINT
S, librarySource); | 6075 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINT
S, librarySource); |
5691 if (identical(hintsState, CacheState.INVALID) || (isPriority && id
entical(hintsState, CacheState.FLUSHED))) { | 6076 if (identical(hintsState, CacheState.INVALID) || (isPriority && id
entical(hintsState, CacheState.FLUSHED))) { |
5692 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.
ELEMENT); | 6077 return _createGenerateDartHintsTask(source, dartEntry, librarySo
urce, libraryEntry); |
5693 if (libraryElement != null) { | |
5694 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
5695 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, Cac
heState.IN_PROCESS); | |
5696 _cache.put(source, dartCopy); | |
5697 return new AnalysisContextImpl_TaskData(new GenerateDartHintsT
ask(this, libraryElement), false); | |
5698 } | |
5699 } | 6078 } |
5700 } | 6079 } |
5701 } | 6080 } |
5702 } | 6081 } |
5703 } | 6082 } |
5704 } else if (sourceEntry is HtmlEntry) { | 6083 } else if (sourceEntry is HtmlEntry) { |
5705 HtmlEntry htmlEntry = sourceEntry; | 6084 HtmlEntry htmlEntry = sourceEntry; |
5706 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); | 6085 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); |
5707 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 6086 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
5708 return _createParseHtmlTask(source, htmlEntry); | 6087 return _createParseHtmlTask(source, htmlEntry); |
5709 } | 6088 } |
5710 if (isPriority && parseErrorsState != CacheState.ERROR) { | 6089 if (isPriority && parseErrorsState != CacheState.ERROR) { |
5711 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; | 6090 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; |
5712 if (parsedUnit == null) { | 6091 if (parsedUnit == null) { |
5713 return _createParseHtmlTask(source, htmlEntry); | 6092 return _createParseHtmlTask(source, htmlEntry); |
5714 } | 6093 } |
5715 } | 6094 } |
5716 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; | 6095 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
5717 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { | 6096 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { |
5718 return _createResolveHtmlTask(source, htmlEntry); | 6097 return _createResolveHtmlTask(source, htmlEntry); |
5719 } | 6098 } |
5720 // | 6099 // |
5721 // Angular support | 6100 // Angular support |
5722 // | 6101 // |
5723 if (_options.analyzeAngular) { | 6102 if (_options.analyzeAngular) { |
5724 // Try to resolve the HTML as an Angular entry point. | 6103 // Try to resolve the HTML as an Angular entry point. |
5725 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR
Y); | 6104 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR
Y); |
5726 if (identical(angularEntryState, CacheState.INVALID)) { | 6105 if (identical(angularEntryState, CacheState.INVALID) || (isPriority && i
dentical(angularEntryState, CacheState.FLUSHED))) { |
5727 return _createResolveAngularEntryHtmlTask(source, htmlEntry); | 6106 return _createResolveAngularEntryHtmlTask(source, htmlEntry); |
5728 } | 6107 } |
5729 // Try to resolve the HTML as an Angular application part. | 6108 // Try to resolve the HTML as an Angular application part. |
5730 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); | 6109 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); |
5731 if (identical(angularErrorsState, CacheState.INVALID)) { | 6110 if (identical(angularErrorsState, CacheState.INVALID) || (isPriority &&
identical(angularErrorsState, CacheState.FLUSHED))) { |
5732 return _createResolveAngularComponentTemplateTask(source, htmlEntry); | 6111 return _createResolveAngularComponentTemplateTask(source, htmlEntry); |
5733 } | 6112 } |
5734 } | 6113 } |
5735 } | 6114 } |
5736 return new AnalysisContextImpl_TaskData(null, false); | 6115 return new AnalysisContextImpl_TaskData(null, false); |
5737 } | 6116 } |
5738 | 6117 |
5739 /** | 6118 /** |
5740 * Return a change notice for the given source, creating one if one does not a
lready exist. | 6119 * Return a change notice for the given source, creating one if one does not a
lready exist. |
5741 * | 6120 * |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5804 /** | 6183 /** |
5805 * Return the cache entry associated with the given source, or `null` if there
is no entry | 6184 * Return the cache entry associated with the given source, or `null` if there
is no entry |
5806 * associated with the source. | 6185 * associated with the source. |
5807 * | 6186 * |
5808 * @param source the source for which a cache entry is being sought | 6187 * @param source the source for which a cache entry is being sought |
5809 * @return the source cache entry associated with the given source | 6188 * @return the source cache entry associated with the given source |
5810 */ | 6189 */ |
5811 SourceEntry _getReadableSourceEntryOrNull(Source source) => _cache.get(source)
; | 6190 SourceEntry _getReadableSourceEntryOrNull(Source source) => _cache.get(source)
; |
5812 | 6191 |
5813 /** | 6192 /** |
| 6193 * Return a resolved compilation unit corresponding to the given element in th
e given library, or |
| 6194 * `null` if the information is not cached. |
| 6195 * |
| 6196 * @param element the element representing the compilation unit |
| 6197 * @param librarySource the source representing the library containing the uni
t |
| 6198 * @return the specified resolved compilation unit |
| 6199 */ |
| 6200 TimestampedData<CompilationUnit> _getResolvedUnit(CompilationUnitElement eleme
nt, Source librarySource) { |
| 6201 SourceEntry sourceEntry = _cache.get(element.source); |
| 6202 if (sourceEntry is DartEntry) { |
| 6203 DartEntry dartEntry = sourceEntry; |
| 6204 if (identical(dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, library
Source), CacheState.VALID)) { |
| 6205 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime,
dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); |
| 6206 } |
| 6207 } |
| 6208 return null; |
| 6209 } |
| 6210 |
| 6211 /** |
5814 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 6212 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
5815 * | 6213 * |
5816 * @param kind the kind of sources to be returned | 6214 * @param kind the kind of sources to be returned |
5817 * @return all of the sources known to this context that have the given kind | 6215 * @return all of the sources known to this context that have the given kind |
5818 */ | 6216 */ |
5819 List<Source> _getSources(SourceKind kind) { | 6217 List<Source> _getSources(SourceKind kind) { |
5820 List<Source> sources = new List<Source>(); | 6218 List<Source> sources = new List<Source>(); |
5821 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 6219 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
5822 if (identical(entry.getValue().kind, kind)) { | 6220 if (identical(entry.getValue().kind, kind)) { |
5823 sources.add(entry.getKey()); | 6221 sources.add(entry.getKey()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5905 return; | 6303 return; |
5906 } | 6304 } |
5907 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; | 6305 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
5908 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { | 6306 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { |
5909 sources.add(source); | 6307 sources.add(source); |
5910 return; | 6308 return; |
5911 } | 6309 } |
5912 // Angular | 6310 // Angular |
5913 if (_options.analyzeAngular) { | 6311 if (_options.analyzeAngular) { |
5914 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); | 6312 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); |
5915 if (identical(angularErrorsState, CacheState.INVALID)) { | 6313 if (identical(angularErrorsState, CacheState.INVALID) || (isPriority &&
identical(angularErrorsState, CacheState.FLUSHED))) { |
5916 AngularApplication entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_EN
TRY); | 6314 AngularApplication entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_EN
TRY); |
5917 if (entryInfo != null) { | 6315 if (entryInfo != null) { |
5918 sources.add(source); | 6316 sources.add(source); |
5919 return; | 6317 return; |
5920 } | 6318 } |
5921 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU
LAR_APPLICATION); | 6319 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU
LAR_APPLICATION); |
5922 if (applicationInfo != null) { | 6320 if (applicationInfo != null) { |
5923 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG
ULAR_COMPONENT); | 6321 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG
ULAR_COMPONENT); |
5924 if (component != null) { | 6322 if (component != null) { |
5925 sources.add(source); | 6323 sources.add(source); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5992 } | 6390 } |
5993 } | 6391 } |
5994 // reset Dart sources | 6392 // reset Dart sources |
5995 List<Source> oldElementSources = application.elementSources; | 6393 List<Source> oldElementSources = application.elementSources; |
5996 for (Source elementSource in oldElementSources) { | 6394 for (Source elementSource in oldElementSources) { |
5997 DartEntry dartEntry = _getReadableDartEntry(elementSource); | 6395 DartEntry dartEntry = _getReadableDartEntry(elementSource); |
5998 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6396 DartEntryImpl dartCopy = dartEntry.writableCopy; |
5999 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); | 6397 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); |
6000 _cache.put(elementSource, dartCopy); | 6398 _cache.put(elementSource, dartCopy); |
6001 // notify about (disappeared) Angular errors | 6399 // notify about (disappeared) Angular errors |
6002 ChangeNoticeImpl notice = _getNotice(elementSource); | 6400 if (_generateSdkErrors || !elementSource.isInSystemLibrary) { |
6003 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE_I
NFO)); | 6401 ChangeNoticeImpl notice = _getNotice(elementSource); |
| 6402 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE
_INFO)); |
| 6403 } |
6004 } | 6404 } |
6005 } | 6405 } |
6006 | 6406 |
6007 /** | 6407 /** |
6008 * In response to a change to at least one of the compilation units in the giv
en library, | 6408 * In response to a change to at least one of the compilation units in the giv
en library, |
6009 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 6409 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
6010 * | 6410 * |
6011 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6411 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
6012 * | 6412 * |
6013 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be | 6413 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
6014 * re-accessed after this method returns. | 6414 * re-accessed after this method returns. |
6015 * | 6415 * |
6016 * @param librarySource the source of the library being invalidated | 6416 * @param librarySource the source of the library being invalidated |
6017 * @param writer the writer to which debugging information should be written | 6417 * @param writer the writer to which debugging information should be written |
6018 */ | 6418 */ |
6019 void _invalidateLibraryResolution(Source librarySource, PrintStringWriter writ
er) { | 6419 void _invalidateLibraryResolution(Source librarySource, PrintStringWriter writ
er) { |
6020 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if | 6420 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if |
6021 // the public namespace hasn't changed, which will be a fairly common case.
The question is | 6421 // the public namespace hasn't changed, which will be a fairly common case.
The question is |
6022 // whether we can afford the time to compute the namespace to look for diffe
rences. | 6422 // whether we can afford the time to compute the namespace to look for diffe
rences. |
6023 DartEntry libraryEntry = _getReadableDartEntry(librarySource); | 6423 DartEntry libraryEntry = _getReadableDartEntry(librarySource); |
6024 if (libraryEntry != null) { | 6424 if (libraryEntry != null) { |
6025 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); | 6425 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); |
6026 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 6426 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
6027 int oldTime = libraryCopy.modificationTime; | 6427 // long oldTime = libraryCopy.getModificationTime(); |
6028 libraryCopy.invalidateAllResolutionInformation(); | 6428 libraryCopy.invalidateAllResolutionInformation(); |
6029 _cache.put(librarySource, libraryCopy); | 6429 _cache.put(librarySource, libraryCopy); |
6030 _workManager.add(librarySource, SourcePriority.LIBRARY); | 6430 _workManager.add(librarySource, SourcePriority.LIBRARY); |
6031 if (writer != null) { | 6431 // if (writer != null) { |
6032 writer.println(" Invalidated library source: ${_debuggingString(library
Source)} (previously modified at ${oldTime})"); | 6432 // writer.println(" Invalidated library source: " + debuggingStrin
g(librarySource) |
6033 } | 6433 // + " (previously modified at " + oldTime + ")"); |
| 6434 // } |
6034 for (Source partSource in includedParts) { | 6435 for (Source partSource in includedParts) { |
6035 SourceEntry partEntry = _cache.get(partSource); | 6436 SourceEntry partEntry = _cache.get(partSource); |
6036 if (partEntry is DartEntry) { | 6437 if (partEntry is DartEntry) { |
6037 DartEntryImpl partCopy = partEntry.writableCopy; | 6438 DartEntryImpl partCopy = partEntry.writableCopy; |
6038 oldTime = partCopy.modificationTime; | 6439 // oldTime = partCopy.getModificationTime(); |
6039 if (partEntry != libraryCopy) { | 6440 if (partEntry != libraryCopy) { |
6040 partCopy.removeContainingLibrary(librarySource); | 6441 partCopy.removeContainingLibrary(librarySource); |
6041 _workManager.add(librarySource, SourcePriority.NORMAL_PART); | 6442 _workManager.add(librarySource, SourcePriority.NORMAL_PART); |
6042 } | 6443 } |
6043 partCopy.invalidateAllResolutionInformation(); | 6444 partCopy.invalidateAllResolutionInformation(); |
6044 _cache.put(partSource, partCopy); | 6445 _cache.put(partSource, partCopy); |
6045 if (writer != null) { | |
6046 writer.println(" Invalidated part source: ${_debuggingString(partSo
urce)} (previously modified at ${oldTime})"); | |
6047 } | |
6048 } | 6446 } |
6049 } | 6447 } |
6050 } | 6448 } |
6051 // invalidate Angular applications | 6449 // invalidate Angular applications |
6052 List<AngularApplication> angularApplicationsCopy = []; | 6450 List<AngularApplication> angularApplicationsCopy = []; |
6053 for (AngularApplication application in angularApplicationsCopy) { | 6451 for (AngularApplication application in angularApplicationsCopy) { |
6054 if (application.dependsOn(librarySource)) { | 6452 if (application.dependsOn(librarySource)) { |
6055 Source entryPointSource = application.entryPoint; | 6453 Source entryPointSource = application.entryPoint; |
6056 HtmlEntry entry = _getReadableHtmlEntry(entryPointSource); | 6454 HtmlEntry entry = _getReadableHtmlEntry(entryPointSource); |
6057 HtmlEntryImpl entryCopy = entry.writableCopy; | 6455 HtmlEntryImpl entryCopy = entry.writableCopy; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6145 } | 6543 } |
6146 } | 6544 } |
6147 // update Dart sources errors | 6545 // update Dart sources errors |
6148 List<Source> newElementSources = application.elementSources; | 6546 List<Source> newElementSources = application.elementSources; |
6149 for (Source elementSource in newElementSources) { | 6547 for (Source elementSource in newElementSources) { |
6150 DartEntry dartEntry = _getReadableDartEntry(elementSource); | 6548 DartEntry dartEntry = _getReadableDartEntry(elementSource); |
6151 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6549 DartEntryImpl dartCopy = dartEntry.writableCopy; |
6152 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource
)); | 6550 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource
)); |
6153 _cache.put(elementSource, dartCopy); | 6551 _cache.put(elementSource, dartCopy); |
6154 // notify about Dart errors | 6552 // notify about Dart errors |
6155 ChangeNoticeImpl notice = _getNotice(elementSource); | 6553 if (_generateSdkErrors || !elementSource.isInSystemLibrary) { |
6156 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); | 6554 ChangeNoticeImpl notice = _getNotice(elementSource); |
| 6555 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); |
| 6556 } |
6157 } | 6557 } |
6158 } | 6558 } |
6159 // remember Angular entry point | 6559 // remember Angular entry point |
6160 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); | 6560 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); |
6161 } | 6561 } |
6162 | 6562 |
6163 /** | 6563 /** |
6164 * Given a cache entry and a library element, record the library element and o
ther information | 6564 * Given a cache entry and a library element, record the library element and o
ther information |
6165 * gleaned from the element in the cache entry. | 6565 * gleaned from the element in the cache entry. |
6166 * | 6566 * |
6167 * @param dartEntry the original cache entry from which the copy was made | 6567 * @param dartEntry the original cache entry from which the copy was made |
6168 * @param dartCopy the cache entry in which data is to be recorded | 6568 * @param dartCopy the cache entry in which data is to be recorded |
6169 * @param library the library element used to record information | 6569 * @param library the library element used to record information |
6170 * @param librarySource the source for the library used to record information | 6570 * @param librarySource the source for the library used to record information |
6171 * @param htmlSource the source for the HTML library | 6571 * @param htmlSource the source for the HTML library |
6172 */ | 6572 */ |
6173 void _recordElementData(DartEntry dartEntry, DartEntryImpl dartCopy, LibraryEl
ement library, Source librarySource, Source htmlSource) { | 6573 void _recordElementData(DartEntry dartEntry, DartEntryImpl dartCopy, LibraryEl
ement library, Source librarySource, Source htmlSource) { |
6174 dartCopy.setValue(DartEntry.ELEMENT, library); | 6574 dartCopy.setValue(DartEntry.ELEMENT, library); |
6175 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); | 6575 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); |
6176 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new Se
t<LibraryElement>())); | 6576 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new Se
t<LibraryElement>())); |
6177 // TODO(brianwilkerson) Understand why we're doing this both here and in | |
6178 // ResolveDartDependenciesTask and whether we should also be capturing the i
mported and exported | |
6179 // sources here. | |
6180 _removeFromParts(librarySource, dartEntry); | |
6181 List<CompilationUnitElement> parts = library.parts; | |
6182 int count = parts.length; | |
6183 List<Source> unitSources = new List<Source>(count + 1); | |
6184 unitSources[0] = library.definingCompilationUnit.source; | |
6185 for (int i = 0; i < count; i++) { | |
6186 Source unitSource = parts[i].source; | |
6187 unitSources[i + 1] = unitSource; | |
6188 DartEntry unitEntry = _getReadableDartEntry(unitSource); | |
6189 if (unitSource != null) { | |
6190 DartEntryImpl unitCopy = unitEntry.writableCopy; | |
6191 unitCopy.addContainingLibrary(librarySource); | |
6192 _cache.put(unitSource, unitCopy); | |
6193 } | |
6194 } | |
6195 dartCopy.setValue(DartEntry.INCLUDED_PARTS, unitSources); | |
6196 } | 6577 } |
6197 | 6578 |
6198 /** | 6579 /** |
6199 * Record the results produced by performing a [GenerateDartErrorsTask]. If th
e results were | 6580 * Record the results produced by performing a [GenerateDartErrorsTask]. If th
e results were |
6200 * computed from data that is now out-of-date, then the results will not be re
corded. | 6581 * computed from data that is now out-of-date, then the results will not be re
corded. |
6201 * | 6582 * |
6202 * @param task the task that was performed | 6583 * @param task the task that was performed |
6203 * @return an entry containing the computed results | 6584 * @return an entry containing the computed results |
6204 * @throws AnalysisException if the results could not be recorded | 6585 * @throws AnalysisException if the results could not be recorded |
6205 */ | 6586 */ |
(...skipping 18 matching lines...) Expand all Loading... |
6224 // The source has changed without the context being notified. Simulate n
otification. | 6605 // The source has changed without the context being notified. Simulate n
otification. |
6225 _sourceChanged(source); | 6606 _sourceChanged(source); |
6226 dartEntry = _getReadableDartEntry(source); | 6607 dartEntry = _getReadableDartEntry(source); |
6227 if (dartEntry == null) { | 6608 if (dartEntry == null) { |
6228 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 6609 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
6229 } | 6610 } |
6230 } | 6611 } |
6231 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6612 DartEntryImpl dartCopy = dartEntry.writableCopy; |
6232 if (thrownException == null) { | 6613 if (thrownException == null) { |
6233 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
task.errors); | 6614 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
task.errors); |
6234 ChangeNoticeImpl notice = _getNotice(source); | 6615 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6235 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); | 6616 ChangeNoticeImpl notice = _getNotice(source); |
| 6617 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 6618 } |
6236 } else { | 6619 } else { |
6237 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
CacheState.ERROR); | 6620 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
CacheState.ERROR); |
6238 } | 6621 } |
6239 dartCopy.exception = thrownException; | 6622 dartCopy.exception = thrownException; |
6240 _cache.put(source, dartCopy); | 6623 _cache.put(source, dartCopy); |
6241 dartEntry = dartCopy; | 6624 dartEntry = dartCopy; |
6242 } else { | 6625 } else { |
6243 _logInformation2("Generated errors discarded for ${_debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); | 6626 _logInformation2("Generated errors discarded for ${_debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); |
6244 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6627 DartEntryImpl dartCopy = dartEntry.writableCopy; |
6245 if (thrownException == null || resultTime >= 0) { | 6628 if (thrownException == null || resultTime >= 0) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6324 // The source has changed without the context being notified. Simulate
notification. | 6707 // The source has changed without the context being notified. Simulate
notification. |
6325 _sourceChanged(unitSource); | 6708 _sourceChanged(unitSource); |
6326 dartEntry = _getReadableDartEntry(unitSource); | 6709 dartEntry = _getReadableDartEntry(unitSource); |
6327 if (dartEntry == null) { | 6710 if (dartEntry == null) { |
6328 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); | 6711 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); |
6329 } | 6712 } |
6330 } | 6713 } |
6331 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6714 DartEntryImpl dartCopy = dartEntry.writableCopy; |
6332 if (thrownException == null) { | 6715 if (thrownException == null) { |
6333 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat
a); | 6716 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat
a); |
6334 ChangeNoticeImpl notice = _getNotice(unitSource); | 6717 if (_generateSdkErrors || !unitSource.isInSystemLibrary) { |
6335 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); | 6718 ChangeNoticeImpl notice = _getNotice(unitSource); |
| 6719 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.L
INE_INFO)); |
| 6720 } |
6336 } else { | 6721 } else { |
6337 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.
ERROR); | 6722 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.
ERROR); |
6338 } | 6723 } |
6339 dartCopy.exception = thrownException; | 6724 dartCopy.exception = thrownException; |
6340 _cache.put(unitSource, dartCopy); | 6725 _cache.put(unitSource, dartCopy); |
6341 dartEntry = dartCopy; | 6726 dartEntry = dartCopy; |
6342 } else { | 6727 } else { |
6343 _logInformation2("Generated hints discarded for ${_debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); | 6728 _logInformation2("Generated hints discarded for ${_debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); |
6344 if (identical(dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource
), CacheState.IN_PROCESS)) { | 6729 if (identical(dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource
), CacheState.IN_PROCESS)) { |
6345 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6730 DartEntryImpl dartCopy = dartEntry.writableCopy; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6412 /** | 6797 /** |
6413 * Record the results produced by performing a [IncrementalAnalysisTask]. | 6798 * Record the results produced by performing a [IncrementalAnalysisTask]. |
6414 * | 6799 * |
6415 * @param task the task that was performed | 6800 * @param task the task that was performed |
6416 * @return an entry containing the computed results | 6801 * @return an entry containing the computed results |
6417 * @throws AnalysisException if the results could not be recorded | 6802 * @throws AnalysisException if the results could not be recorded |
6418 */ | 6803 */ |
6419 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task)
{ | 6804 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task)
{ |
6420 CompilationUnit unit = task.compilationUnit; | 6805 CompilationUnit unit = task.compilationUnit; |
6421 if (unit != null) { | 6806 if (unit != null) { |
6422 ChangeNoticeImpl notice = _getNotice(task.source); | 6807 if (_generateSdkErrors || !task.source.isInSystemLibrary) { |
6423 notice.compilationUnit = unit; | 6808 ChangeNoticeImpl notice = _getNotice(task.source); |
| 6809 notice.compilationUnit = unit; |
| 6810 } |
6424 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); | 6811 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); |
6425 } | 6812 } |
6426 return null; | 6813 return null; |
6427 } | 6814 } |
6428 | 6815 |
6429 /** | 6816 /** |
6430 * Record the results produced by performing a [ParseDartTask]. If the results
were computed | 6817 * Record the results produced by performing a [ParseDartTask]. If the results
were computed |
6431 * from data that is now out-of-date, then the results will not be recorded. | 6818 * from data that is now out-of-date, then the results will not be recorded. |
6432 * | 6819 * |
6433 * @param task the task that was performed | 6820 * @param task the task that was performed |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6479 partCopy.addContainingLibrary(source); | 6866 partCopy.addContainingLibrary(source); |
6480 _cache.put(partSource, partCopy); | 6867 _cache.put(partSource, partCopy); |
6481 } | 6868 } |
6482 } | 6869 } |
6483 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); | 6870 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); |
6484 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); | 6871 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); |
6485 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); | 6872 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); |
6486 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); | 6873 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); |
6487 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); | 6874 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); |
6488 _cache.storedAst(source); | 6875 _cache.storedAst(source); |
6489 ChangeNoticeImpl notice = _getNotice(source); | 6876 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6490 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); | 6877 ChangeNoticeImpl notice = _getNotice(source); |
| 6878 notice.setErrors(dartCopy.allErrors, task.lineInfo); |
| 6879 } |
6491 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache | 6880 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache |
6492 // is structurally equivalent to the fully parsed unit | 6881 // is structurally equivalent to the fully parsed unit |
6493 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); | 6882 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); |
6494 } else { | 6883 } else { |
6495 _removeFromParts(source, dartEntry); | 6884 _removeFromParts(source, dartEntry); |
6496 dartCopy.recordParseError(); | 6885 dartCopy.recordParseError(); |
6497 _cache.removedAst(source); | 6886 _cache.removedAst(source); |
6498 } | 6887 } |
6499 dartCopy.exception = thrownException; | 6888 dartCopy.exception = thrownException; |
6500 _cache.put(source, dartCopy); | 6889 _cache.put(source, dartCopy); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6565 } | 6954 } |
6566 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 6955 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
6567 if (thrownException == null) { | 6956 if (thrownException == null) { |
6568 LineInfo lineInfo = task.lineInfo; | 6957 LineInfo lineInfo = task.lineInfo; |
6569 ht.HtmlUnit unit = task.htmlUnit; | 6958 ht.HtmlUnit unit = task.htmlUnit; |
6570 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 6959 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
6571 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | 6960 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
6572 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); | 6961 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); |
6573 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); | 6962 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); |
6574 _cache.storedAst(source); | 6963 _cache.storedAst(source); |
6575 ChangeNoticeImpl notice = _getNotice(source); | 6964 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6576 notice.setErrors(htmlCopy.allErrors, lineInfo); | 6965 ChangeNoticeImpl notice = _getNotice(source); |
| 6966 notice.setErrors(htmlCopy.allErrors, lineInfo); |
| 6967 } |
6577 } else { | 6968 } else { |
6578 htmlCopy.recordParseError(); | 6969 htmlCopy.recordParseError(); |
6579 _cache.removedAst(source); | 6970 _cache.removedAst(source); |
6580 } | 6971 } |
6581 htmlCopy.exception = thrownException; | 6972 htmlCopy.exception = thrownException; |
6582 _cache.put(source, htmlCopy); | 6973 _cache.put(source, htmlCopy); |
6583 htmlEntry = htmlCopy; | 6974 htmlEntry = htmlCopy; |
6584 } else { | 6975 } else { |
6585 _logInformation2("Parse results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); | 6976 _logInformation2("Parse results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); |
6586 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 6977 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6650 _sourceChanged(source); | 7041 _sourceChanged(source); |
6651 htmlEntry = _getReadableHtmlEntry(source); | 7042 htmlEntry = _getReadableHtmlEntry(source); |
6652 if (htmlEntry == null) { | 7043 if (htmlEntry == null) { |
6653 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 7044 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
6654 } | 7045 } |
6655 } | 7046 } |
6656 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7047 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
6657 if (thrownException == null) { | 7048 if (thrownException == null) { |
6658 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); | 7049 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); |
6659 // notify about errors | 7050 // notify about errors |
6660 ChangeNoticeImpl notice = _getNotice(source); | 7051 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6661 notice.htmlUnit = task.resolvedUnit; | 7052 ChangeNoticeImpl notice = _getNotice(source); |
6662 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); | 7053 notice.htmlUnit = task.resolvedUnit; |
| 7054 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 7055 } |
6663 } else { | 7056 } else { |
6664 htmlCopy.recordResolutionError(); | 7057 htmlCopy.recordResolutionError(); |
6665 } | 7058 } |
6666 htmlCopy.exception = thrownException; | 7059 htmlCopy.exception = thrownException; |
6667 _cache.put(source, htmlCopy); | 7060 _cache.put(source, htmlCopy); |
6668 htmlEntry = htmlCopy; | 7061 htmlEntry = htmlCopy; |
6669 } else { | 7062 } else { |
6670 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7063 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
6671 if (thrownException == null || resultTime >= 0) { | 7064 if (thrownException == null || resultTime >= 0) { |
6672 // | 7065 // |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6732 htmlEntry = _getReadableHtmlEntry(source); | 7125 htmlEntry = _getReadableHtmlEntry(source); |
6733 if (htmlEntry == null) { | 7126 if (htmlEntry == null) { |
6734 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 7127 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
6735 } | 7128 } |
6736 } | 7129 } |
6737 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7130 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
6738 if (thrownException == null) { | 7131 if (thrownException == null) { |
6739 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | 7132 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
6740 _recordAngularEntryPoint(htmlCopy, task); | 7133 _recordAngularEntryPoint(htmlCopy, task); |
6741 _cache.storedAst(source); | 7134 _cache.storedAst(source); |
6742 ChangeNoticeImpl notice = _getNotice(source); | 7135 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6743 notice.htmlUnit = task.resolvedUnit; | 7136 ChangeNoticeImpl notice = _getNotice(source); |
6744 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); | 7137 notice.htmlUnit = task.resolvedUnit; |
| 7138 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 7139 } |
6745 } else { | 7140 } else { |
6746 htmlCopy.recordResolutionError(); | 7141 htmlCopy.recordResolutionError(); |
6747 } | 7142 } |
6748 htmlCopy.exception = thrownException; | 7143 htmlCopy.exception = thrownException; |
6749 _cache.put(source, htmlCopy); | 7144 _cache.put(source, htmlCopy); |
6750 htmlEntry = htmlCopy; | 7145 htmlEntry = htmlCopy; |
6751 } else { | 7146 } else { |
6752 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7147 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
6753 if (thrownException == null || resultTime >= 0) { | 7148 if (thrownException == null || resultTime >= 0) { |
6754 // | 7149 // |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6895 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 7290 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
6896 } | 7291 } |
6897 } | 7292 } |
6898 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7293 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
6899 if (thrownException == null) { | 7294 if (thrownException == null) { |
6900 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | 7295 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
6901 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | 7296 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
6902 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); | 7297 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); |
6903 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); | 7298 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); |
6904 _cache.storedAst(source); | 7299 _cache.storedAst(source); |
6905 ChangeNoticeImpl notice = _getNotice(source); | 7300 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6906 notice.htmlUnit = task.resolvedUnit; | 7301 ChangeNoticeImpl notice = _getNotice(source); |
6907 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); | 7302 notice.htmlUnit = task.resolvedUnit; |
| 7303 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 7304 } |
6908 } else { | 7305 } else { |
6909 htmlCopy.recordResolutionError(); | 7306 htmlCopy.recordResolutionError(); |
6910 _cache.removedAst(source); | 7307 _cache.removedAst(source); |
6911 } | 7308 } |
6912 htmlCopy.exception = thrownException; | 7309 htmlCopy.exception = thrownException; |
6913 _cache.put(source, htmlCopy); | 7310 _cache.put(source, htmlCopy); |
6914 htmlEntry = htmlCopy; | 7311 htmlEntry = htmlCopy; |
6915 } else { | 7312 } else { |
6916 _logInformation2("Resolution results discarded for ${_debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); | 7313 _logInformation2("Resolution results discarded for ${_debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); |
6917 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7314 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6980 } | 7377 } |
6981 } | 7378 } |
6982 DartEntryImpl dartCopy = dartEntry.writableCopy; | 7379 DartEntryImpl dartCopy = dartEntry.writableCopy; |
6983 if (thrownException == null) { | 7380 if (thrownException == null) { |
6984 LineInfo lineInfo = task.lineInfo; | 7381 LineInfo lineInfo = task.lineInfo; |
6985 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 7382 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
6986 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); | 7383 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); |
6987 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); | 7384 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); |
6988 _cache.storedAst(source); | 7385 _cache.storedAst(source); |
6989 _workManager.add(source, SourcePriority.NORMAL_PART); | 7386 _workManager.add(source, SourcePriority.NORMAL_PART); |
6990 ChangeNoticeImpl notice = _getNotice(source); | 7387 if (_generateSdkErrors || !source.isInSystemLibrary) { |
6991 notice.setErrors(dartEntry.allErrors, lineInfo); | 7388 ChangeNoticeImpl notice = _getNotice(source); |
| 7389 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 7390 } |
6992 } else { | 7391 } else { |
6993 _removeFromParts(source, dartEntry); | 7392 _removeFromParts(source, dartEntry); |
6994 dartCopy.recordScanError(); | 7393 dartCopy.recordScanError(); |
6995 _cache.removedAst(source); | 7394 _cache.removedAst(source); |
6996 } | 7395 } |
6997 dartCopy.exception = thrownException; | 7396 dartCopy.exception = thrownException; |
6998 _cache.put(source, dartCopy); | 7397 _cache.put(source, dartCopy); |
6999 dartEntry = dartCopy; | 7398 dartEntry = dartCopy; |
7000 } else { | 7399 } else { |
7001 _logInformation2("Scan results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}", thrownException); | 7400 _logInformation2("Scan results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}", thrownException); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7079 * | 7478 * |
7080 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7479 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
7081 * | 7480 * |
7082 * @param source the source that has been added | 7481 * @param source the source that has been added |
7083 * @return `true` if the new source is a Dart file | 7482 * @return `true` if the new source is a Dart file |
7084 */ | 7483 */ |
7085 bool _sourceAvailable(Source source) { | 7484 bool _sourceAvailable(Source source) { |
7086 SourceEntry sourceEntry = _cache.get(source); | 7485 SourceEntry sourceEntry = _cache.get(source); |
7087 if (sourceEntry == null) { | 7486 if (sourceEntry == null) { |
7088 sourceEntry = _createSourceEntry(source); | 7487 sourceEntry = _createSourceEntry(source); |
7089 _logInformation("Added new source: ${_debuggingString(source)}"); | |
7090 } else { | 7488 } else { |
7091 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 7489 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
7092 int oldTime = sourceCopy.modificationTime; | 7490 // long oldTime = sourceCopy.getModificationTime(); |
7093 sourceCopy.modificationTime = getModificationStamp(source); | 7491 sourceCopy.modificationTime = getModificationStamp(source); |
7094 // TODO(brianwilkerson) Understand why we're not invalidating the cache. | 7492 // TODO(brianwilkerson) Understand why we're not invalidating the cache. |
7095 _cache.put(source, sourceCopy); | 7493 _cache.put(source, sourceCopy); |
7096 _logInformation("Added new source: ${_debuggingString(source)} (previously
modified at ${oldTime})"); | |
7097 } | 7494 } |
7098 if (sourceEntry is HtmlEntry) { | 7495 if (sourceEntry is HtmlEntry) { |
7099 _workManager.add(source, SourcePriority.HTML); | 7496 _workManager.add(source, SourcePriority.HTML); |
7100 } else { | 7497 } else { |
7101 _workManager.add(source, SourcePriority.UNKNOWN); | 7498 _workManager.add(source, SourcePriority.UNKNOWN); |
7102 } | 7499 } |
7103 return sourceEntry is DartEntry; | 7500 return sourceEntry is DartEntry; |
7104 } | 7501 } |
7105 | 7502 |
7106 /** | 7503 /** |
7107 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7504 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
7108 * | 7505 * |
7109 * @param source the source that has been changed | 7506 * @param source the source that has been changed |
7110 */ | 7507 */ |
7111 void _sourceChanged(Source source) { | 7508 void _sourceChanged(Source source) { |
7112 SourceEntry sourceEntry = _cache.get(source); | 7509 SourceEntry sourceEntry = _cache.get(source); |
7113 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt
amp(source)) { | 7510 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt
amp(source)) { |
7114 // Either we have removed this source, in which case we don't care that it
is changed, or we | 7511 // Either we have removed this source, in which case we don't care that it
is changed, or we |
7115 // have already invalidated the cache and don't need to invalidate it agai
n. | 7512 // have already invalidated the cache and don't need to invalidate it agai
n. |
7116 if (sourceEntry == null) { | 7513 // if (sourceEntry == null) { |
7117 _logInformation("Modified source, but there is no entry: ${_debuggingStr
ing(source)}"); | 7514 // logInformation("Modified source, but there is no entry: " + debu
ggingString(source)); |
7118 } else { | 7515 // } else { |
7119 _logInformation("Modified source, but modification time matches: ${_debu
ggingString(source)}"); | 7516 // logInformation("Modified source, but modification time matches:
" + debuggingString(source)); |
7120 } | 7517 // } |
7121 return; | 7518 return; |
7122 } | 7519 } |
7123 if (sourceEntry is HtmlEntry) { | 7520 if (sourceEntry is HtmlEntry) { |
7124 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 7521 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
7125 int oldTime = htmlCopy.modificationTime; | 7522 // long oldTime = htmlCopy.getModificationTime(); |
7126 htmlCopy.modificationTime = getModificationStamp(source); | 7523 htmlCopy.modificationTime = getModificationStamp(source); |
7127 _invalidateAngularResolution(htmlCopy); | 7524 _invalidateAngularResolution(htmlCopy); |
7128 htmlCopy.invalidateAllInformation(); | 7525 htmlCopy.invalidateAllInformation(); |
7129 _cache.put(source, htmlCopy); | 7526 _cache.put(source, htmlCopy); |
7130 _cache.removedAst(source); | 7527 _cache.removedAst(source); |
7131 _workManager.add(source, SourcePriority.HTML); | 7528 _workManager.add(source, SourcePriority.HTML); |
7132 _logInformation("Modified HTML source: ${_debuggingString(source)} (previo
usly modified at ${oldTime})"); | |
7133 } else if (sourceEntry is DartEntry) { | 7529 } else if (sourceEntry is DartEntry) { |
7134 List<Source> containingLibraries = getLibrariesContaining(source); | 7530 List<Source> containingLibraries = getLibrariesContaining(source); |
7135 Set<Source> librariesToInvalidate = new Set<Source>(); | 7531 Set<Source> librariesToInvalidate = new Set<Source>(); |
7136 for (Source containingLibrary in containingLibraries) { | 7532 for (Source containingLibrary in containingLibraries) { |
7137 librariesToInvalidate.add(containingLibrary); | 7533 librariesToInvalidate.add(containingLibrary); |
7138 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { | 7534 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { |
7139 librariesToInvalidate.add(dependentLibrary); | 7535 librariesToInvalidate.add(dependentLibrary); |
7140 } | 7536 } |
7141 } | 7537 } |
7142 PrintStringWriter writer = new PrintStringWriter(); | 7538 PrintStringWriter writer = new PrintStringWriter(); |
7143 int oldTime = sourceEntry.modificationTime; | |
7144 writer.println("Modified Dart source: ${_debuggingString(source)} (previou
sly modified at ${oldTime})"); | |
7145 for (Source library in librariesToInvalidate) { | 7539 for (Source library in librariesToInvalidate) { |
7146 // for (Source library : containingLibraries) { | 7540 // for (Source library : containingLibraries) { |
7147 _invalidateLibraryResolution(library, writer); | 7541 _invalidateLibraryResolution(library, writer); |
7148 } | 7542 } |
7149 _removeFromParts(source, _cache.get(source) as DartEntry); | 7543 _removeFromParts(source, _cache.get(source) as DartEntry); |
7150 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; | 7544 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; |
7151 dartCopy.modificationTime = getModificationStamp(source); | 7545 dartCopy.modificationTime = getModificationStamp(source); |
7152 dartCopy.invalidateAllInformation(); | 7546 dartCopy.invalidateAllInformation(); |
7153 _cache.put(source, dartCopy); | 7547 _cache.put(source, dartCopy); |
7154 _cache.removedAst(source); | 7548 _cache.removedAst(source); |
7155 _workManager.add(source, SourcePriority.UNKNOWN); | 7549 _workManager.add(source, SourcePriority.UNKNOWN); |
7156 _logInformation(writer.toString()); | |
7157 } | 7550 } |
7158 } | 7551 } |
7159 | 7552 |
7160 /** | 7553 /** |
7161 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7554 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
7162 * | 7555 * |
7163 * @param source the source that has been deleted | 7556 * @param source the source that has been deleted |
7164 */ | 7557 */ |
7165 void _sourceRemoved(Source source) { | 7558 void _sourceRemoved(Source source) { |
7166 PrintStringWriter writer = new PrintStringWriter(); | 7559 PrintStringWriter writer = new PrintStringWriter(); |
7167 writer.println("Removed source: ${_debuggingString(source)}"); | |
7168 SourceEntry sourceEntry = _cache.get(source); | 7560 SourceEntry sourceEntry = _cache.get(source); |
7169 if (sourceEntry is HtmlEntry) { | 7561 if (sourceEntry is HtmlEntry) { |
7170 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 7562 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
7171 _invalidateAngularResolution(htmlCopy); | 7563 _invalidateAngularResolution(htmlCopy); |
7172 } else if (sourceEntry is DartEntry) { | 7564 } else if (sourceEntry is DartEntry) { |
7173 Set<Source> libraries = new Set<Source>(); | 7565 Set<Source> libraries = new Set<Source>(); |
7174 for (Source librarySource in getLibrariesContaining(source)) { | 7566 for (Source librarySource in getLibrariesContaining(source)) { |
7175 libraries.add(librarySource); | 7567 libraries.add(librarySource); |
7176 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ | 7568 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
7177 libraries.add(dependentLibrary); | 7569 libraries.add(dependentLibrary); |
7178 } | 7570 } |
7179 } | 7571 } |
7180 for (Source librarySource in libraries) { | 7572 for (Source librarySource in libraries) { |
7181 _invalidateLibraryResolution(librarySource, writer); | 7573 _invalidateLibraryResolution(librarySource, writer); |
7182 } | 7574 } |
7183 } | 7575 } |
7184 _cache.remove(source); | 7576 _cache.remove(source); |
7185 _workManager.remove(source); | 7577 _workManager.remove(source); |
7186 _removeFromPriorityOrder(source); | 7578 _removeFromPriorityOrder(source); |
7187 _logInformation(writer.toString()); | |
7188 } | 7579 } |
7189 | 7580 |
7190 /** | 7581 /** |
7191 * Check the cache for any invalid entries (entries whose modification time do
es not match the | 7582 * Check the cache for any invalid entries (entries whose modification time do
es not match the |
7192 * modification time of the source associated with the entry). Invalid entries
will be marked as | 7583 * modification time of the source associated with the entry). Invalid entries
will be marked as |
7193 * invalid so that the source will be re-analyzed. | 7584 * invalid so that the source will be re-analyzed. |
7194 * | 7585 * |
7195 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7586 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
7196 * | 7587 * |
7197 * @return `true` if at least one entry was invalid | 7588 * @return `true` if at least one entry was invalid |
(...skipping 10 matching lines...) Expand all Loading... |
7208 _sourceChanged(source); | 7599 _sourceChanged(source); |
7209 inconsistentCount++; | 7600 inconsistentCount++; |
7210 } | 7601 } |
7211 if (sourceEntry.exception != null) { | 7602 if (sourceEntry.exception != null) { |
7212 if (!exists(source)) { | 7603 if (!exists(source)) { |
7213 missingSources.add(source); | 7604 missingSources.add(source); |
7214 } | 7605 } |
7215 } | 7606 } |
7216 } | 7607 } |
7217 int consistencyCheckEnd = JavaSystem.nanoTime(); | 7608 int consistencyCheckEnd = JavaSystem.nanoTime(); |
7218 PrintStringWriter writer = new PrintStringWriter(); | 7609 if (inconsistentCount > 0 || missingSources.length > 0) { |
7219 writer.print("Consistency check took "); | 7610 PrintStringWriter writer = new PrintStringWriter(); |
7220 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | 7611 writer.print("Consistency check took "); |
7221 writer.println(" ms and found"); | 7612 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
7222 writer.print(" "); | 7613 writer.println(" ms and found"); |
7223 writer.print(inconsistentCount); | 7614 writer.print(" "); |
7224 writer.println(" inconsistent entries"); | 7615 writer.print(inconsistentCount); |
7225 writer.print(" "); | 7616 writer.println(" inconsistent entries"); |
7226 writer.print(missingSources.length); | 7617 writer.print(" "); |
7227 writer.println(" missing sources"); | 7618 writer.print(missingSources.length); |
7228 for (Source source in missingSources) { | 7619 writer.println(" missing sources"); |
7229 writer.print(" "); | 7620 for (Source source in missingSources) { |
7230 writer.println(source.fullName); | 7621 writer.print(" "); |
| 7622 writer.println(source.fullName); |
| 7623 } |
| 7624 _logInformation(writer.toString()); |
7231 } | 7625 } |
7232 _logInformation(writer.toString()); | |
7233 return inconsistentCount > 0; | 7626 return inconsistentCount > 0; |
7234 } | 7627 } |
7235 } | 7628 } |
7236 | 7629 |
7237 /** | 7630 /** |
7238 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c
ontext to | 7631 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c
ontext to |
7239 * record the results of a task. | 7632 * record the results of a task. |
7240 */ | 7633 */ |
7241 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi
tor<SourceEntry> { | 7634 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi
tor<SourceEntry> { |
7242 final AnalysisContextImpl AnalysisContextImpl_this; | 7635 final AnalysisContextImpl AnalysisContextImpl_this; |
(...skipping 18 matching lines...) Expand all Loading... |
7261 @override | 7654 @override |
7262 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this._
recordParseHtmlTaskResults(task); | 7655 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this._
recordParseHtmlTaskResults(task); |
7263 | 7656 |
7264 @override | 7657 @override |
7265 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp
lateTask task) => AnalysisContextImpl_this._recordResolveAngularComponentTemplat
eTaskResults(task); | 7658 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp
lateTask task) => AnalysisContextImpl_this._recordResolveAngularComponentTemplat
eTaskResults(task); |
7266 | 7659 |
7267 @override | 7660 @override |
7268 HtmlEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) =
> AnalysisContextImpl_this._recordResolveAngularEntryHtmlTaskResults(task); | 7661 HtmlEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) =
> AnalysisContextImpl_this._recordResolveAngularEntryHtmlTaskResults(task); |
7269 | 7662 |
7270 @override | 7663 @override |
| 7664 DartEntry visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task) =
> AnalysisContextImpl_this.recordResolveDartLibraryCycleTaskResults(task); |
| 7665 |
| 7666 @override |
7271 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis
ContextImpl_this.recordResolveDartLibraryTaskResults(task); | 7667 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis
ContextImpl_this.recordResolveDartLibraryTaskResults(task); |
7272 | 7668 |
7273 @override | 7669 @override |
7274 DartEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisContex
tImpl_this._recordResolveDartUnitTaskResults(task); | 7670 DartEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisContex
tImpl_this._recordResolveDartUnitTaskResults(task); |
7275 | 7671 |
7276 @override | 7672 @override |
7277 HtmlEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_th
is._recordResolveHtmlTaskResults(task); | 7673 HtmlEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_th
is._recordResolveHtmlTaskResults(task); |
7278 | 7674 |
7279 @override | 7675 @override |
7280 DartEntry visitScanDartTask(ScanDartTask task) => AnalysisContextImpl_this._re
cordScanDartTaskResults(task); | 7676 DartEntry visitScanDartTask(ScanDartTask task) => AnalysisContextImpl_this._re
cordScanDartTaskResults(task); |
7281 } | 7677 } |
7282 | 7678 |
7283 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy
{ | 7679 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy
{ |
7284 final AnalysisContextImpl AnalysisContextImpl_this; | 7680 final AnalysisContextImpl AnalysisContextImpl_this; |
7285 | 7681 |
7286 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); | 7682 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); |
7287 | 7683 |
7288 @override | 7684 @override |
7289 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { | 7685 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { |
7290 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) { | 7686 int priorityCount = AnalysisContextImpl_this._priorityOrder.length; |
7291 if (source == prioritySource) { | 7687 for (int i = 0; i < priorityCount; i++) { |
| 7688 if (source == AnalysisContextImpl_this._priorityOrder[i]) { |
7292 return RetentionPriority.HIGH; | 7689 return RetentionPriority.HIGH; |
7293 } | 7690 } |
7294 } | 7691 } |
| 7692 if (AnalysisContextImpl_this._neededForResolution != null && AnalysisContext
Impl_this._neededForResolution.contains(source)) { |
| 7693 return RetentionPriority.HIGH; |
| 7694 } |
7295 if (sourceEntry is DartEntry) { | 7695 if (sourceEntry is DartEntry) { |
7296 DartEntry dartEntry = sourceEntry; | 7696 DartEntry dartEntry = sourceEntry; |
7297 if (_astIsNeeded(dartEntry)) { | 7697 if (_astIsNeeded(dartEntry)) { |
7298 return RetentionPriority.MEDIUM; | 7698 return RetentionPriority.MEDIUM; |
7299 } | 7699 } |
7300 } | 7700 } |
7301 return RetentionPriority.LOW; | 7701 return RetentionPriority.LOW; |
7302 } | 7702 } |
7303 | 7703 |
7304 bool _astIsNeeded(DartEntry dartEntry) => dartEntry.hasInvalidData(DartEntry.H
INTS) || dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || dartEntry.ha
sInvalidData(DartEntry.RESOLUTION_ERRORS); | 7704 bool _astIsNeeded(DartEntry dartEntry) => dartEntry.hasInvalidData(DartEntry.H
INTS) || dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || dartEntry.ha
sInvalidData(DartEntry.RESOLUTION_ERRORS); |
7305 } | 7705 } |
7306 | 7706 |
7307 /** | 7707 /** |
| 7708 * Instances of the class `LibraryPair` hold a library and a list of the (source
, entry) |
| 7709 * pairs for compilation units in the library. |
| 7710 */ |
| 7711 class CycleBuilder_LibraryPair { |
| 7712 /** |
| 7713 * The library containing the compilation units. |
| 7714 */ |
| 7715 ResolvableLibrary library; |
| 7716 |
| 7717 /** |
| 7718 * The (source, entry) pairs representing the compilation units in the library
. |
| 7719 */ |
| 7720 List<CycleBuilder_SourceEntryPair> entryPairs; |
| 7721 |
| 7722 /** |
| 7723 * Initialize a newly created pair. |
| 7724 * |
| 7725 * @param library the library containing the compilation units |
| 7726 * @param entryPairs the (source, entry) pairs representing the compilation un
its in the |
| 7727 * library |
| 7728 */ |
| 7729 CycleBuilder_LibraryPair(ResolvableLibrary library, List<CycleBuilder_SourceEn
tryPair> entryPairs) { |
| 7730 this.library = library; |
| 7731 this.entryPairs = entryPairs; |
| 7732 } |
| 7733 } |
| 7734 |
| 7735 /** |
| 7736 * Instances of the class `SourceEntryPair` hold a source and the cache entry as
sociated |
| 7737 * with that source. They are used to reduce the number of times an entry must b
e looked up in |
| 7738 * the [cache]. |
| 7739 */ |
| 7740 class CycleBuilder_SourceEntryPair { |
| 7741 /** |
| 7742 * The source associated with the entry. |
| 7743 */ |
| 7744 Source source; |
| 7745 |
| 7746 /** |
| 7747 * The entry associated with the source. |
| 7748 */ |
| 7749 DartEntry entry; |
| 7750 |
| 7751 /** |
| 7752 * Initialize a newly created pair. |
| 7753 * |
| 7754 * @param source the source associated with the entry |
| 7755 * @param entry the entry associated with the source |
| 7756 */ |
| 7757 CycleBuilder_SourceEntryPair(Source source, DartEntry entry) { |
| 7758 this.source = source; |
| 7759 this.entry = entry; |
| 7760 } |
| 7761 } |
| 7762 |
| 7763 /** |
| 7764 * Instances of the class `CycleBuilder` are used to construct a list of the lib
raries that |
| 7765 * must be resolved together in order to resolve any one of the libraries. |
| 7766 */ |
| 7767 class AnalysisContextImpl_CycleBuilder { |
| 7768 final AnalysisContextImpl AnalysisContextImpl_this; |
| 7769 |
| 7770 /** |
| 7771 * A table mapping the sources of the defining compilation units of libraries
to the |
| 7772 * representation of the library that has the information needed to resolve th
e library. |
| 7773 */ |
| 7774 Map<Source, ResolvableLibrary> _libraryMap = new Map<Source, ResolvableLibrary
>(); |
| 7775 |
| 7776 /** |
| 7777 * The dependency graph used to compute the libraries in the cycle. |
| 7778 */ |
| 7779 DirectedGraph<ResolvableLibrary> _dependencyGraph; |
| 7780 |
| 7781 /** |
| 7782 * A list containing the libraries that are ready to be resolved. |
| 7783 */ |
| 7784 List<ResolvableLibrary> _librariesInCycle; |
| 7785 |
| 7786 /** |
| 7787 * The analysis task that needs to be performed before the cycle of libraries
can be resolved, |
| 7788 * or `null` if the libraries are ready to be resolved. |
| 7789 */ |
| 7790 AnalysisContextImpl_TaskData _taskData; |
| 7791 |
| 7792 /** |
| 7793 * Initialize a newly created cycle builder. |
| 7794 */ |
| 7795 AnalysisContextImpl_CycleBuilder(this.AnalysisContextImpl_this) : super(); |
| 7796 |
| 7797 /** |
| 7798 * Compute a list of the libraries that need to be resolved together in order
to resolve the |
| 7799 * given library. |
| 7800 * |
| 7801 * @param librarySource the source of the library to be resolved |
| 7802 * @throws AnalysisException if the core library cannot be found |
| 7803 */ |
| 7804 void computeCycleContaining(Source librarySource) { |
| 7805 // |
| 7806 // Create the object representing the library being resolved. |
| 7807 // |
| 7808 ResolvableLibrary targetLibrary = _createLibrary(librarySource); |
| 7809 // |
| 7810 // Compute the set of libraries that need to be resolved together. |
| 7811 // |
| 7812 _dependencyGraph = new DirectedGraph<ResolvableLibrary>(); |
| 7813 _computeLibraryDependencies(targetLibrary); |
| 7814 if (_taskData != null) { |
| 7815 return; |
| 7816 } |
| 7817 _librariesInCycle = _dependencyGraph.findCycleContaining(targetLibrary); |
| 7818 // |
| 7819 // Ensure that all of the data needed to resolve them has been computed. |
| 7820 // |
| 7821 _ensureImportsAndExports(); |
| 7822 if (_taskData != null) { |
| 7823 // At least one imported library needs to be resolved before the target li
brary. |
| 7824 AnalysisTask task = _taskData.task; |
| 7825 if (task is ResolveDartLibraryTask) { |
| 7826 AnalysisContextImpl_this._workManager.addFirst(task.librarySource, Sourc
ePriority.LIBRARY); |
| 7827 } |
| 7828 return; |
| 7829 } |
| 7830 _computePartsInCycle(librarySource); |
| 7831 if (_taskData != null) { |
| 7832 // At least one part needs to be parsed. |
| 7833 return; |
| 7834 } |
| 7835 // All of the AST's necessary to perform a resolution of the library cycle h
ave been |
| 7836 // gathered, so it is no longer necessary to retain them in the cache. |
| 7837 AnalysisContextImpl_this._neededForResolution = null; |
| 7838 } |
| 7839 |
| 7840 /** |
| 7841 * Return a list containing the libraries that are ready to be resolved (assum
ing that |
| 7842 * [getTaskData] returns `null`). |
| 7843 * |
| 7844 * @return the libraries that are ready to be resolved |
| 7845 */ |
| 7846 List<ResolvableLibrary> get librariesInCycle => _librariesInCycle; |
| 7847 |
| 7848 /** |
| 7849 * Return a representation of an analysis task that needs to be performed befo
re the cycle of |
| 7850 * libraries can be resolved, or `null` if the libraries are ready to be resol
ved. |
| 7851 * |
| 7852 * @return the analysis task that needs to be performed before the cycle of li
braries can be |
| 7853 * resolved |
| 7854 */ |
| 7855 AnalysisContextImpl_TaskData get taskData => _taskData; |
| 7856 |
| 7857 /** |
| 7858 * Recursively traverse the libraries reachable from the given library, creati
ng instances of |
| 7859 * the class [Library] to represent them, and record the references in the lib
rary |
| 7860 * objects. |
| 7861 * |
| 7862 * @param library the library to be processed to find libraries that have not
yet been traversed |
| 7863 * @throws AnalysisException if some portion of the library graph could not be
traversed |
| 7864 */ |
| 7865 void _computeLibraryDependencies(ResolvableLibrary library) { |
| 7866 Source librarySource = library.librarySource; |
| 7867 DartEntry dartEntry = AnalysisContextImpl_this._getReadableDartEntry(library
Source); |
| 7868 List<Source> importedSources = _getSources(librarySource, dartEntry, DartEnt
ry.IMPORTED_LIBRARIES); |
| 7869 if (_taskData != null) { |
| 7870 return; |
| 7871 } |
| 7872 List<Source> exportedSources = _getSources(librarySource, dartEntry, DartEnt
ry.EXPORTED_LIBRARIES); |
| 7873 if (_taskData != null) { |
| 7874 return; |
| 7875 } |
| 7876 _computeLibraryDependenciesFromDirectives(library, importedSources, exported
Sources); |
| 7877 } |
| 7878 |
| 7879 /** |
| 7880 * Recursively traverse the libraries reachable from the given library, creati
ng instances of |
| 7881 * the class [Library] to represent them, and record the references in the lib
rary |
| 7882 * objects. |
| 7883 * |
| 7884 * @param library the library to be processed to find libraries that have not
yet been traversed |
| 7885 * @param importedSources an array containing the sources that are imported in
to the given |
| 7886 * library |
| 7887 * @param exportedSources an array containing the sources that are exported fr
om the given |
| 7888 * library |
| 7889 */ |
| 7890 void _computeLibraryDependenciesFromDirectives(ResolvableLibrary library, List
<Source> importedSources, List<Source> exportedSources) { |
| 7891 int importCount = importedSources.length; |
| 7892 if (importCount > 0) { |
| 7893 List<ResolvableLibrary> importedLibraries = new List<ResolvableLibrary>(); |
| 7894 bool explicitlyImportsCore = false; |
| 7895 for (int i = 0; i < importCount; i++) { |
| 7896 Source importedSource = importedSources[i]; |
| 7897 if (importedSource == AnalysisContextImpl_this._coreLibrarySource) { |
| 7898 explicitlyImportsCore = true; |
| 7899 } |
| 7900 ResolvableLibrary importedLibrary = _libraryMap[importedSource]; |
| 7901 if (importedLibrary == null) { |
| 7902 importedLibrary = _createLibraryOrNull(importedSource); |
| 7903 if (importedLibrary != null) { |
| 7904 _computeLibraryDependencies(importedLibrary); |
| 7905 if (_taskData != null) { |
| 7906 return; |
| 7907 } |
| 7908 } |
| 7909 } |
| 7910 if (importedLibrary != null) { |
| 7911 importedLibraries.add(importedLibrary); |
| 7912 _dependencyGraph.addEdge(library, importedLibrary); |
| 7913 } |
| 7914 } |
| 7915 library.explicitlyImportsCore = explicitlyImportsCore; |
| 7916 if (!explicitlyImportsCore && AnalysisContextImpl_this._coreLibrarySource
!= library.librarySource) { |
| 7917 ResolvableLibrary importedLibrary = _libraryMap[AnalysisContextImpl_this
._coreLibrarySource]; |
| 7918 if (importedLibrary == null) { |
| 7919 importedLibrary = _createLibraryOrNull(AnalysisContextImpl_this._coreL
ibrarySource); |
| 7920 if (importedLibrary != null) { |
| 7921 _computeLibraryDependencies(importedLibrary); |
| 7922 if (_taskData != null) { |
| 7923 return; |
| 7924 } |
| 7925 } |
| 7926 } |
| 7927 if (importedLibrary != null) { |
| 7928 importedLibraries.add(importedLibrary); |
| 7929 _dependencyGraph.addEdge(library, importedLibrary); |
| 7930 } |
| 7931 } |
| 7932 library.importedLibraries = new List.from(importedLibraries); |
| 7933 } else { |
| 7934 library.explicitlyImportsCore = false; |
| 7935 ResolvableLibrary importedLibrary = _libraryMap[AnalysisContextImpl_this._
coreLibrarySource]; |
| 7936 if (importedLibrary == null) { |
| 7937 importedLibrary = _createLibraryOrNull(AnalysisContextImpl_this._coreLib
rarySource); |
| 7938 if (importedLibrary != null) { |
| 7939 _computeLibraryDependencies(importedLibrary); |
| 7940 if (_taskData != null) { |
| 7941 return; |
| 7942 } |
| 7943 } |
| 7944 } |
| 7945 if (importedLibrary != null) { |
| 7946 _dependencyGraph.addEdge(library, importedLibrary); |
| 7947 library.importedLibraries = <ResolvableLibrary> [importedLibrary]; |
| 7948 } |
| 7949 } |
| 7950 int exportCount = exportedSources.length; |
| 7951 if (exportCount > 0) { |
| 7952 List<ResolvableLibrary> exportedLibraries = new List<ResolvableLibrary>(); |
| 7953 for (int i = 0; i < exportCount; i++) { |
| 7954 Source exportedSource = exportedSources[i]; |
| 7955 ResolvableLibrary exportedLibrary = _libraryMap[exportedSource]; |
| 7956 if (exportedLibrary == null) { |
| 7957 exportedLibrary = _createLibraryOrNull(exportedSource); |
| 7958 if (exportedLibrary != null) { |
| 7959 _computeLibraryDependencies(exportedLibrary); |
| 7960 if (_taskData != null) { |
| 7961 return; |
| 7962 } |
| 7963 } |
| 7964 } |
| 7965 if (exportedLibrary != null) { |
| 7966 exportedLibraries.add(exportedLibrary); |
| 7967 _dependencyGraph.addEdge(library, exportedLibrary); |
| 7968 } |
| 7969 } |
| 7970 library.exportedLibraries = new List.from(exportedLibraries); |
| 7971 } |
| 7972 } |
| 7973 |
| 7974 /** |
| 7975 * Gather the resolvable AST structures for each of the compilation units in e
ach of the |
| 7976 * libraries in the cycle. This is done in two phases: first we ensure that we
have cached an |
| 7977 * AST structure for each compilation unit, then we gather them. We split the
work this way |
| 7978 * because getting the AST structures can change the state of the cache in suc
h a way that we |
| 7979 * would have more work to do if any compilation unit didn't have a resolvable
AST structure. |
| 7980 */ |
| 7981 void _computePartsInCycle(Source librarySource) { |
| 7982 int count = _librariesInCycle.length; |
| 7983 List<CycleBuilder_LibraryPair> libraryData = new List<CycleBuilder_LibraryPa
ir>(); |
| 7984 for (int i = 0; i < count; i++) { |
| 7985 ResolvableLibrary library = _librariesInCycle[i]; |
| 7986 libraryData.add(new CycleBuilder_LibraryPair(library, _ensurePartsInLibrar
y(library))); |
| 7987 } |
| 7988 AnalysisContextImpl_this._neededForResolution = _gatherSources(libraryData); |
| 7989 if (AnalysisContextImpl._TRACE_PERFORM_TASK) { |
| 7990 print(" preserve resolution data for ${AnalysisContextImpl_this._neededFo
rResolution.length} sources while resolving ${librarySource.fullName}"); |
| 7991 } |
| 7992 if (_taskData != null) { |
| 7993 return; |
| 7994 } |
| 7995 for (int i = 0; i < count; i++) { |
| 7996 _computePartsInLibrary(libraryData[i]); |
| 7997 } |
| 7998 } |
| 7999 |
| 8000 /** |
| 8001 * Gather the resolvable compilation units for each of the compilation units i
n the specified |
| 8002 * library. |
| 8003 * |
| 8004 * @param libraryPair a holder containing both the library and a list of (sour
ce, entry) pairs |
| 8005 * for all of the compilation units in the library |
| 8006 */ |
| 8007 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) { |
| 8008 ResolvableLibrary library = libraryPair.library; |
| 8009 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs; |
| 8010 int count = entryPairs.length; |
| 8011 List<ResolvableCompilationUnit> units = new List<ResolvableCompilationUnit>(
count); |
| 8012 for (int i = 0; i < count; i++) { |
| 8013 CycleBuilder_SourceEntryPair entryPair = entryPairs[i]; |
| 8014 Source source = entryPair.source; |
| 8015 DartEntryImpl dartCopy = entryPair.entry.writableCopy; |
| 8016 units[i] = new ResolvableCompilationUnit.con2(dartCopy.modificationTime, d
artCopy.resolvableCompilationUnit, source); |
| 8017 AnalysisContextImpl_this._cache.put(source, dartCopy); |
| 8018 } |
| 8019 library.resolvableCompilationUnits = units; |
| 8020 } |
| 8021 |
| 8022 /** |
| 8023 * Create an object to represent the information about the library defined by
the compilation |
| 8024 * unit with the given source. |
| 8025 * |
| 8026 * @param librarySource the source of the library's defining compilation unit |
| 8027 * @return the library object that was created |
| 8028 */ |
| 8029 ResolvableLibrary _createLibrary(Source librarySource) { |
| 8030 ResolvableLibrary library = new ResolvableLibrary(librarySource); |
| 8031 SourceEntry sourceEntry = AnalysisContextImpl_this._cache.get(librarySource)
; |
| 8032 if (sourceEntry is DartEntry) { |
| 8033 LibraryElementImpl libraryElement = sourceEntry.getValue(DartEntry.ELEMENT
) as LibraryElementImpl; |
| 8034 if (libraryElement != null) { |
| 8035 library.libraryElement = libraryElement; |
| 8036 } |
| 8037 } |
| 8038 _libraryMap[librarySource] = library; |
| 8039 return library; |
| 8040 } |
| 8041 |
| 8042 /** |
| 8043 * Create an object to represent the information about the library defined by
the compilation |
| 8044 * unit with the given source. |
| 8045 * |
| 8046 * @param librarySource the source of the library's defining compilation unit |
| 8047 * @return the library object that was created |
| 8048 */ |
| 8049 ResolvableLibrary _createLibraryOrNull(Source librarySource) { |
| 8050 if (!AnalysisContextImpl_this.exists(librarySource)) { |
| 8051 return null; |
| 8052 } |
| 8053 ResolvableLibrary library = new ResolvableLibrary(librarySource); |
| 8054 SourceEntry sourceEntry = AnalysisContextImpl_this._cache.get(librarySource)
; |
| 8055 if (sourceEntry is DartEntry) { |
| 8056 LibraryElementImpl libraryElement = sourceEntry.getValue(DartEntry.ELEMENT
) as LibraryElementImpl; |
| 8057 if (libraryElement != null) { |
| 8058 library.libraryElement = libraryElement; |
| 8059 } |
| 8060 } |
| 8061 _libraryMap[librarySource] = library; |
| 8062 return library; |
| 8063 } |
| 8064 |
| 8065 /** |
| 8066 * Ensure that all of the libraries that are exported by the given library (bu
t are not |
| 8067 * themselves in the cycle) have element models built for them. |
| 8068 * |
| 8069 * @param library the library being tested |
| 8070 */ |
| 8071 void _ensureExports(ResolvableLibrary library, Set<Source> visitedLibraries) { |
| 8072 List<ResolvableLibrary> dependencies = library.exports; |
| 8073 int dependencyCount = dependencies.length; |
| 8074 for (int i = 0; i < dependencyCount; i++) { |
| 8075 ResolvableLibrary dependency = dependencies[i]; |
| 8076 if (!_librariesInCycle.contains(dependency) && visitedLibraries.add(depend
ency.librarySource)) { |
| 8077 if (dependency.libraryElement == null) { |
| 8078 Source dependencySource = dependency.librarySource; |
| 8079 AnalysisContextImpl_this._workManager.addFirst(dependencySource, Sourc
ePriority.LIBRARY); |
| 8080 if (_taskData == null) { |
| 8081 _taskData = AnalysisContextImpl_this._createResolveDartLibraryTask(d
ependencySource, AnalysisContextImpl_this._getReadableDartEntry(dependencySource
)); |
| 8082 } |
| 8083 } else { |
| 8084 _ensureExports(dependency, visitedLibraries); |
| 8085 } |
| 8086 } |
| 8087 } |
| 8088 } |
| 8089 |
| 8090 /** |
| 8091 * Ensure that all of the libraries that are exported by the given library (bu
t are not |
| 8092 * themselves in the cycle) have element models built for them. |
| 8093 * |
| 8094 * @param library the library being tested |
| 8095 * @throws MissingDataException if there is at least one library being depende
d on that does not |
| 8096 * have an element model built for it |
| 8097 */ |
| 8098 void _ensureImports(ResolvableLibrary library) { |
| 8099 List<ResolvableLibrary> dependencies = library.imports; |
| 8100 int dependencyCount = dependencies.length; |
| 8101 for (int i = 0; i < dependencyCount; i++) { |
| 8102 ResolvableLibrary dependency = dependencies[i]; |
| 8103 if (!_librariesInCycle.contains(dependency) && dependency.libraryElement =
= null) { |
| 8104 Source dependencySource = dependency.librarySource; |
| 8105 AnalysisContextImpl_this._workManager.addFirst(dependencySource, SourceP
riority.LIBRARY); |
| 8106 if (_taskData == null) { |
| 8107 _taskData = AnalysisContextImpl_this._createResolveDartLibraryTask(dep
endencySource, AnalysisContextImpl_this._getReadableDartEntry(dependencySource))
; |
| 8108 } |
| 8109 } |
| 8110 } |
| 8111 } |
| 8112 |
| 8113 /** |
| 8114 * Ensure that all of the libraries that are either imported or exported by li
braries in the |
| 8115 * cycle (but are not themselves in the cycle) have element models built for t
hem. |
| 8116 */ |
| 8117 void _ensureImportsAndExports() { |
| 8118 Set<Source> visitedLibraries = new Set<Source>(); |
| 8119 int libraryCount = _librariesInCycle.length; |
| 8120 for (int i = 0; i < libraryCount; i++) { |
| 8121 ResolvableLibrary library = _librariesInCycle[i]; |
| 8122 _ensureImports(library); |
| 8123 _ensureExports(library, visitedLibraries); |
| 8124 } |
| 8125 } |
| 8126 |
| 8127 /** |
| 8128 * Ensure that there is a resolvable compilation unit available for all of the
compilation units |
| 8129 * in the given library. |
| 8130 * |
| 8131 * @param library the library for which resolvable compilation units must be a
vailable |
| 8132 * @return a list of (source, entry) pairs for all of the compilation units in
the library |
| 8133 */ |
| 8134 List<CycleBuilder_SourceEntryPair> _ensurePartsInLibrary(ResolvableLibrary lib
rary) { |
| 8135 List<CycleBuilder_SourceEntryPair> pairs = new List<CycleBuilder_SourceEntry
Pair>(); |
| 8136 Source librarySource = library.librarySource; |
| 8137 DartEntry libraryEntry = AnalysisContextImpl_this._getReadableDartEntry(libr
arySource); |
| 8138 _ensureResolvableCompilationUnit(librarySource, libraryEntry); |
| 8139 pairs.add(new CycleBuilder_SourceEntryPair(librarySource, libraryEntry)); |
| 8140 List<Source> partSources = _getSources(librarySource, libraryEntry, DartEntr
y.INCLUDED_PARTS); |
| 8141 int count = partSources.length; |
| 8142 for (int i = 0; i < count; i++) { |
| 8143 Source partSource = partSources[i]; |
| 8144 DartEntry partEntry = AnalysisContextImpl_this._getReadableDartEntry(partS
ource); |
| 8145 if (partEntry != null) { |
| 8146 _ensureResolvableCompilationUnit(partSource, partEntry); |
| 8147 pairs.add(new CycleBuilder_SourceEntryPair(partSource, partEntry)); |
| 8148 } |
| 8149 } |
| 8150 return pairs; |
| 8151 } |
| 8152 |
| 8153 /** |
| 8154 * Ensure that there is a resolvable compilation unit available for the given
source. |
| 8155 * |
| 8156 * @param source the source for which a resolvable compilation unit must be av
ailable |
| 8157 * @param dartEntry the entry associated with the source |
| 8158 */ |
| 8159 void _ensureResolvableCompilationUnit(Source source, DartEntry dartEntry) { |
| 8160 if (!dartEntry.hasResolvableCompilationUnit) { |
| 8161 if (_taskData == null) { |
| 8162 _taskData = AnalysisContextImpl_this._createParseDartTask(source, dartEn
try); |
| 8163 } |
| 8164 } |
| 8165 } |
| 8166 |
| 8167 Set<Source> _gatherSources(List<CycleBuilder_LibraryPair> libraryData) { |
| 8168 int libraryCount = libraryData.length; |
| 8169 Set<Source> sources = new Set<Source>(); |
| 8170 for (int i = 0; i < libraryCount; i++) { |
| 8171 List<CycleBuilder_SourceEntryPair> entryPairs = libraryData[i].entryPairs; |
| 8172 int entryCount = entryPairs.length; |
| 8173 for (int j = 0; j < entryCount; j++) { |
| 8174 sources.add(entryPairs[j].source); |
| 8175 } |
| 8176 } |
| 8177 return sources; |
| 8178 } |
| 8179 |
| 8180 /** |
| 8181 * Return the sources described by the given descriptor. |
| 8182 * |
| 8183 * @param source the source with which the sources are associated |
| 8184 * @param dartEntry the entry corresponding to the source |
| 8185 * @param descriptor the descriptor indicating which sources are to be returne
d |
| 8186 * @return the sources described by the given descriptor |
| 8187 */ |
| 8188 List<Source> _getSources(Source source, DartEntry dartEntry, DataDescriptor<Li
st<Source>> descriptor) { |
| 8189 if (dartEntry == null) { |
| 8190 return Source.EMPTY_ARRAY; |
| 8191 } |
| 8192 CacheState exportState = dartEntry.getState(descriptor); |
| 8193 if (identical(exportState, CacheState.ERROR)) { |
| 8194 return Source.EMPTY_ARRAY; |
| 8195 } else if (exportState != CacheState.VALID) { |
| 8196 if (_taskData == null) { |
| 8197 _taskData = AnalysisContextImpl_this._createParseDartTask(source, dartEn
try); |
| 8198 } |
| 8199 return Source.EMPTY_ARRAY; |
| 8200 } |
| 8201 return dartEntry.getValue(descriptor); |
| 8202 } |
| 8203 } |
| 8204 |
| 8205 /** |
7308 * Instances of the class `TaskData` represent information about the next task t
o be | 8206 * Instances of the class `TaskData` represent information about the next task t
o be |
7309 * performed. Each data has an implicit associated source: the source that might
need to be | 8207 * performed. Each data has an implicit associated source: the source that might
need to be |
7310 * analyzed. There are essentially three states that can be represented: | 8208 * analyzed. There are essentially three states that can be represented: |
7311 * * If [getTask] returns a non-`null` value, then that is the task that should | 8209 * * If [getTask] returns a non-`null` value, then that is the task that should |
7312 * be executed to further analyze the associated source. | 8210 * be executed to further analyze the associated source. |
7313 * * Otherwise, if [isBlocked] returns `true`, then there is no work that can be | 8211 * * Otherwise, if [isBlocked] returns `true`, then there is no work that can be |
7314 * done, but analysis for the associated source is not complete. | 8212 * done, but analysis for the associated source is not complete. |
7315 * * Otherwise, [getDependentSource] should return a source that needs to be ana
lyzed | 8213 * * Otherwise, [getDependentSource] should return a source that needs to be ana
lyzed |
7316 * before the analysis of the associated source can be completed. | 8214 * before the analysis of the associated source can be completed. |
7317 */ | 8215 */ |
(...skipping 22 matching lines...) Expand all Loading... |
7340 } | 8238 } |
7341 | 8239 |
7342 /** | 8240 /** |
7343 * Return `true` if the associated source is blocked waiting for its contents
to be | 8241 * Return `true` if the associated source is blocked waiting for its contents
to be |
7344 * loaded. | 8242 * loaded. |
7345 * | 8243 * |
7346 * @return `true` if the associated source is blocked waiting for its contents
to be | 8244 * @return `true` if the associated source is blocked waiting for its contents
to be |
7347 * loaded | 8245 * loaded |
7348 */ | 8246 */ |
7349 bool get isBlocked => _blocked; | 8247 bool get isBlocked => _blocked; |
| 8248 |
| 8249 @override |
| 8250 String toString() { |
| 8251 if (task == null) { |
| 8252 return "blocked: ${_blocked}"; |
| 8253 } |
| 8254 return task.toString(); |
| 8255 } |
7350 } | 8256 } |
7351 | 8257 |
7352 /** | 8258 /** |
7353 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info | 8259 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info |
7354 * associated with a source. | 8260 * associated with a source. |
7355 */ | 8261 */ |
7356 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { | 8262 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { |
7357 /** | 8263 /** |
7358 * The analysis errors associated with a source, or `null` if there are no err
ors. | 8264 * The analysis errors associated with a source, or `null` if there are no err
ors. |
7359 */ | 8265 */ |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8228 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); | 9134 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); |
8229 _checkThread(instrumentation); | 9135 _checkThread(instrumentation); |
8230 try { | 9136 try { |
8231 instrumentation.metric3("contextId", _contextId); | 9137 instrumentation.metric3("contextId", _contextId); |
8232 return _basis.analysisOptions; | 9138 return _basis.analysisOptions; |
8233 } finally { | 9139 } finally { |
8234 instrumentation.log(); | 9140 instrumentation.log(); |
8235 } | 9141 } |
8236 } | 9142 } |
8237 | 9143 |
| 9144 @override |
| 9145 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { |
| 9146 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAngularApplication"); |
| 9147 _checkThread(instrumentation); |
| 9148 try { |
| 9149 instrumentation.metric3("contextId", _contextId); |
| 9150 return _basis.getAngularApplicationWithHtml(htmlSource); |
| 9151 } finally { |
| 9152 instrumentation.log(); |
| 9153 } |
| 9154 } |
| 9155 |
8238 /** | 9156 /** |
8239 * @return the underlying [AnalysisContext]. | 9157 * @return the underlying [AnalysisContext]. |
8240 */ | 9158 */ |
8241 AnalysisContext get basis => _basis; | 9159 AnalysisContext get basis => _basis; |
8242 | 9160 |
8243 @override | 9161 @override |
8244 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource) { | 9162 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource) { |
8245 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getCompilationUnitElement"); | 9163 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getCompilationUnitElement"); |
8246 _checkThread(instrumentation); | 9164 _checkThread(instrumentation); |
8247 try { | 9165 try { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8397 if (ret != null) { | 9315 if (ret != null) { |
8398 instrumentation.metric2("Source-count", ret.length); | 9316 instrumentation.metric2("Source-count", ret.length); |
8399 } | 9317 } |
8400 return ret; | 9318 return ret; |
8401 } finally { | 9319 } finally { |
8402 instrumentation.log(); | 9320 instrumentation.log(); |
8403 } | 9321 } |
8404 } | 9322 } |
8405 | 9323 |
8406 @override | 9324 @override |
| 9325 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { |
| 9326 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrariesReferencedFromHtml"); |
| 9327 _checkThread(instrumentation); |
| 9328 try { |
| 9329 instrumentation.metric3("contextId", _contextId); |
| 9330 return _basis.getLibrariesReferencedFromHtml(htmlSource); |
| 9331 } finally { |
| 9332 instrumentation.log(); |
| 9333 } |
| 9334 } |
| 9335 |
| 9336 @override |
8407 LibraryElement getLibraryElement(Source source) { | 9337 LibraryElement getLibraryElement(Source source) { |
8408 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); | 9338 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); |
8409 _checkThread(instrumentation); | 9339 _checkThread(instrumentation); |
8410 try { | 9340 try { |
8411 instrumentation.metric3("contextId", _contextId); | 9341 instrumentation.metric3("contextId", _contextId); |
8412 return _basis.getLibraryElement(source); | 9342 return _basis.getLibraryElement(source); |
8413 } finally { | 9343 } finally { |
8414 instrumentation.log(); | 9344 instrumentation.log(); |
8415 } | 9345 } |
8416 } | 9346 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8502 instrumentation.metric3("contextId", _contextId); | 9432 instrumentation.metric3("contextId", _contextId); |
8503 return _basis.getResolvedHtmlUnit(htmlSource); | 9433 return _basis.getResolvedHtmlUnit(htmlSource); |
8504 } finally { | 9434 } finally { |
8505 instrumentation.log2(2); | 9435 instrumentation.log2(2); |
8506 } | 9436 } |
8507 } | 9437 } |
8508 | 9438 |
8509 @override | 9439 @override |
8510 SourceFactory get sourceFactory { | 9440 SourceFactory get sourceFactory { |
8511 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getSourceFactory"); | 9441 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getSourceFactory"); |
8512 _checkThread(instrumentation); | |
8513 try { | 9442 try { |
8514 instrumentation.metric3("contextId", _contextId); | 9443 instrumentation.metric3("contextId", _contextId); |
8515 return _basis.sourceFactory; | 9444 return _basis.sourceFactory; |
8516 } finally { | 9445 } finally { |
8517 instrumentation.log2(2); | 9446 instrumentation.log2(2); |
8518 } | 9447 } |
8519 } | 9448 } |
8520 | 9449 |
8521 @override | 9450 @override |
8522 AnalysisContentStatistics get statistics => _basis.statistics; | 9451 AnalysisContentStatistics get statistics => _basis.statistics; |
8523 | 9452 |
8524 @override | 9453 @override |
8525 TypeProvider get typeProvider => _basis.typeProvider; | 9454 TypeProvider get typeProvider => _basis.typeProvider; |
8526 | 9455 |
8527 @override | 9456 @override |
8528 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) => _basis.internalResolveCompilationUnit(uni
tSource, libraryElement); | |
8529 | |
8530 @override | |
8531 bool isClientLibrary(Source librarySource) { | 9457 bool isClientLibrary(Source librarySource) { |
8532 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
isClientLibrary"); | 9458 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
isClientLibrary"); |
8533 _checkThread(instrumentation); | 9459 _checkThread(instrumentation); |
8534 try { | 9460 try { |
8535 instrumentation.metric3("contextId", _contextId); | 9461 instrumentation.metric3("contextId", _contextId); |
8536 return _basis.isClientLibrary(librarySource); | 9462 return _basis.isClientLibrary(librarySource); |
8537 } finally { | 9463 } finally { |
8538 instrumentation.log(); | 9464 instrumentation.log(); |
8539 } | 9465 } |
8540 } | 9466 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8811 /** | 9737 /** |
8812 * Returns a type provider for this context or throws an exception if dart:cor
e cannot be | 9738 * Returns a type provider for this context or throws an exception if dart:cor
e cannot be |
8813 * resolved. | 9739 * resolved. |
8814 * | 9740 * |
8815 * @return the type provider (not `null`) | 9741 * @return the type provider (not `null`) |
8816 * @throws AnalysisException if dart:core cannot be resolved | 9742 * @throws AnalysisException if dart:core cannot be resolved |
8817 */ | 9743 */ |
8818 TypeProvider get typeProvider; | 9744 TypeProvider get typeProvider; |
8819 | 9745 |
8820 /** | 9746 /** |
8821 * Return a time-stamped fully-resolved compilation unit for the given source
in the given | |
8822 * library. | |
8823 * | |
8824 * @param unitSource the source of the compilation unit for which a resolved A
ST structure is to | |
8825 * be returned | |
8826 * @param libraryElement the element representing the library in which the com
pilation unit is to | |
8827 * be resolved | |
8828 * @return a time-stamped fully-resolved compilation unit for the source | |
8829 * @throws AnalysisException if the resolved compilation unit could not be com
puted | |
8830 */ | |
8831 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement); | |
8832 | |
8833 /** | |
8834 * Given a table mapping the source for the libraries represented by the corre
sponding elements to | 9747 * Given a table mapping the source for the libraries represented by the corre
sponding elements to |
8835 * the elements representing the libraries, record those mappings. | 9748 * the elements representing the libraries, record those mappings. |
8836 * | 9749 * |
8837 * @param elementMap a table mapping the source for the libraries represented
by the elements to | 9750 * @param elementMap a table mapping the source for the libraries represented
by the elements to |
8838 * the elements representing the libraries | 9751 * the elements representing the libraries |
8839 */ | 9752 */ |
8840 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 9753 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
8841 } | 9754 } |
8842 | 9755 |
8843 /** | 9756 /** |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9274 * Record that the given source is fully analyzed. | 10187 * Record that the given source is fully analyzed. |
9275 * | 10188 * |
9276 * @param source the source that is fully analyzed | 10189 * @param source the source that is fully analyzed |
9277 */ | 10190 */ |
9278 void remove(Source source) { | 10191 void remove(Source source) { |
9279 int queueCount = _workQueues.length; | 10192 int queueCount = _workQueues.length; |
9280 for (int i = 0; i < queueCount; i++) { | 10193 for (int i = 0; i < queueCount; i++) { |
9281 _workQueues[i].remove(source); | 10194 _workQueues[i].remove(source); |
9282 } | 10195 } |
9283 } | 10196 } |
| 10197 |
| 10198 @override |
| 10199 String toString() { |
| 10200 JavaStringBuilder builder = new JavaStringBuilder(); |
| 10201 List<SourcePriority> priorities = SourcePriority.values; |
| 10202 bool needsSeparator = false; |
| 10203 int queueCount = _workQueues.length; |
| 10204 for (int i = 0; i < queueCount; i++) { |
| 10205 List<Source> queue = _workQueues[i]; |
| 10206 if (!queue.isEmpty) { |
| 10207 if (needsSeparator) { |
| 10208 builder.append("; "); |
| 10209 } |
| 10210 builder.append(priorities[i]); |
| 10211 builder.append(": "); |
| 10212 int queueSize = queue.length; |
| 10213 for (int j = 0; j < queueSize; j++) { |
| 10214 if (j > 0) { |
| 10215 builder.append(", "); |
| 10216 } |
| 10217 builder.append(queue[j].fullName); |
| 10218 } |
| 10219 needsSeparator = true; |
| 10220 } |
| 10221 } |
| 10222 return builder.toString(); |
| 10223 } |
9284 } | 10224 } |
9285 | 10225 |
9286 /** | 10226 /** |
9287 * Instances of the class `WorkIterator` implement an iterator that returns the
sources in a | 10227 * Instances of the class `WorkIterator` implement an iterator that returns the
sources in a |
9288 * work manager in the order in which they are to be analyzed. | 10228 * work manager in the order in which they are to be analyzed. |
9289 */ | 10229 */ |
9290 class WorkManager_WorkIterator { | 10230 class WorkManager_WorkIterator { |
9291 final WorkManager WorkManager_this; | 10231 final WorkManager WorkManager_this; |
9292 | 10232 |
9293 /** | 10233 /** |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10432 } | 11372 } |
10433 } | 11373 } |
10434 } | 11374 } |
10435 // | 11375 // |
10436 for (AngularPropertyElement property in _element.properties) { | 11376 for (AngularPropertyElement property in _element.properties) { |
10437 // prepare attribute name | 11377 // prepare attribute name |
10438 String name = property.name; | 11378 String name = property.name; |
10439 if (name == ".") { | 11379 if (name == ".") { |
10440 name = selectorAttributeName; | 11380 name = selectorAttributeName; |
10441 } | 11381 } |
10442 // resolve attribute expression | 11382 // prepare attribute |
10443 ht.XmlAttributeNode attribute = node.getAttribute(name); | 11383 ht.XmlAttributeNode attribute = node.getAttribute(name); |
10444 if (attribute != null) { | 11384 if (attribute == null) { |
10445 // if not resolved as the selector, resolve as a property | 11385 continue; |
10446 if (name != selectorAttributeName) { | 11386 } |
10447 attribute.element = property; | 11387 // if not resolved as the selector, resolve as a property |
10448 } | 11388 if (name != selectorAttributeName) { |
10449 // resolve if binding | 11389 attribute.element = property; |
10450 if (property.propertyKind != AngularPropertyKind.ATTR) { | 11390 } |
10451 resolver._pushNameScope(); | 11391 // skip if attribute has no value |
10452 try { | 11392 if (!NgDirectiveProcessor.hasValue(attribute)) { |
10453 _onNgEventDirective(resolver); | 11393 continue; |
10454 AngularExpression expression = parseAngularExpression(resolver, attr
ibute); | 11394 } |
10455 resolver._resolveExpression(expression); | 11395 // resolve if binding |
10456 setAngularExpression(attribute, expression); | 11396 if (property.propertyKind != AngularPropertyKind.ATTR) { |
10457 } finally { | 11397 resolver._pushNameScope(); |
10458 resolver._popNameScope(); | 11398 try { |
10459 } | 11399 _onNgEventDirective(resolver); |
| 11400 AngularExpression expression = parseAngularExpression(resolver, attrib
ute); |
| 11401 resolver._resolveExpression(expression); |
| 11402 setAngularExpression(attribute, expression); |
| 11403 } finally { |
| 11404 resolver._popNameScope(); |
10460 } | 11405 } |
10461 } | 11406 } |
10462 } | 11407 } |
10463 } | 11408 } |
10464 | 11409 |
10465 @override | 11410 @override |
10466 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 11411 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
10467 | 11412 |
10468 /** | 11413 /** |
10469 * Support for <code>$event</code> variable in <code>NgEventDirective</code>. | 11414 * Support for <code>$event</code> variable in <code>NgEventDirective</code>. |
10470 */ | 11415 */ |
10471 void _onNgEventDirective(AngularHtmlUnitResolver resolver) { | 11416 void _onNgEventDirective(AngularHtmlUnitResolver resolver) { |
10472 if (_element.isClass("NgEventDirective")) { | 11417 if (_element.isClass("NgEventDirective")) { |
10473 DartType dynamicType = resolver.typeProvider.dynamicType; | 11418 DartType dynamicType = resolver.typeProvider.dynamicType; |
10474 resolver._defineVariable(resolver._createLocalVariableWithName(dynamicType
, "\$event")); | 11419 resolver._defineVariable(resolver._createLocalVariableWithName(dynamicType
, "\$event")); |
10475 } | 11420 } |
10476 } | 11421 } |
10477 } | 11422 } |
10478 | 11423 |
10479 /** | 11424 /** |
10480 * [NgDirectiveProcessor] describes any <code>NgDirective</code> annotation inst
ance. | 11425 * [NgDirectiveProcessor] describes any <code>NgDirective</code> annotation inst
ance. |
10481 */ | 11426 */ |
10482 abstract class NgDirectiveProcessor extends NgProcessor { | 11427 abstract class NgDirectiveProcessor extends NgProcessor { |
| 11428 static bool hasValue(ht.XmlAttributeNode attribute) { |
| 11429 ht.Token valueToken = attribute.valueToken; |
| 11430 return valueToken != null && !valueToken.isSynthetic; |
| 11431 } |
| 11432 |
10483 static AngularRawXmlExpression newAngularRawXmlExpression(AngularExpression e)
=> new AngularRawXmlExpression(e); | 11433 static AngularRawXmlExpression newAngularRawXmlExpression(AngularExpression e)
=> new AngularRawXmlExpression(e); |
10484 | 11434 |
10485 static ht.RawXmlExpression newRawXmlExpression(Expression e) => new ht.RawXmlE
xpression(e); | 11435 static ht.RawXmlExpression newRawXmlExpression(Expression e) => new ht.RawXmlE
xpression(e); |
10486 | 11436 |
10487 AngularExpression parseAngularExpression(AngularHtmlUnitResolver resolver, ht.
XmlAttributeNode attribute) { | 11437 AngularExpression parseAngularExpression(AngularHtmlUnitResolver resolver, ht.
XmlAttributeNode attribute) { |
10488 Token token = _scanAttribute(resolver, attribute); | 11438 Token token = _scanAttribute(resolver, attribute); |
10489 return resolver._parseAngularExpressionInToken(token); | 11439 return resolver._parseAngularExpressionInToken(token); |
10490 } | 11440 } |
10491 | 11441 |
10492 Expression parseDartExpression(AngularHtmlUnitResolver resolver, ht.XmlAttribu
teNode attribute) { | 11442 Expression parseDartExpression(AngularHtmlUnitResolver resolver, ht.XmlAttribu
teNode attribute) { |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10757 /** | 11707 /** |
10758 * Visit a [ResolveAngularEntryHtmlTask]. | 11708 * Visit a [ResolveAngularEntryHtmlTask]. |
10759 * | 11709 * |
10760 * @param task the task to be visited | 11710 * @param task the task to be visited |
10761 * @return the result of visiting the task | 11711 * @return the result of visiting the task |
10762 * @throws AnalysisException if the visitor throws an exception for some reaso
n | 11712 * @throws AnalysisException if the visitor throws an exception for some reaso
n |
10763 */ | 11713 */ |
10764 E visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task); | 11714 E visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task); |
10765 | 11715 |
10766 /** | 11716 /** |
| 11717 * Visit a [ResolveDartLibraryCycleTask]. |
| 11718 * |
| 11719 * @param task the task to be visited |
| 11720 * @return the result of visiting the task |
| 11721 * @throws AnalysisException if the visitor throws an exception for some reaso
n |
| 11722 */ |
| 11723 E visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task); |
| 11724 |
| 11725 /** |
10767 * Visit a [ResolveDartLibraryTask]. | 11726 * Visit a [ResolveDartLibraryTask]. |
10768 * | 11727 * |
10769 * @param task the task to be visited | 11728 * @param task the task to be visited |
10770 * @return the result of visiting the task | 11729 * @return the result of visiting the task |
10771 * @throws AnalysisException if the visitor throws an exception for some reaso
n | 11730 * @throws AnalysisException if the visitor throws an exception for some reaso
n |
10772 */ | 11731 */ |
10773 E visitResolveDartLibraryTask(ResolveDartLibraryTask task); | 11732 E visitResolveDartLibraryTask(ResolveDartLibraryTask task); |
10774 | 11733 |
10775 /** | 11734 /** |
10776 * Visit a [ResolveDartUnitTask]. | 11735 * Visit a [ResolveDartUnitTask]. |
(...skipping 27 matching lines...) Expand all Loading... |
10804 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings
for a single | 11763 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings
for a single |
10805 * Dart source. | 11764 * Dart source. |
10806 */ | 11765 */ |
10807 class GenerateDartErrorsTask extends AnalysisTask { | 11766 class GenerateDartErrorsTask extends AnalysisTask { |
10808 /** | 11767 /** |
10809 * The source for which errors and warnings are to be produced. | 11768 * The source for which errors and warnings are to be produced. |
10810 */ | 11769 */ |
10811 Source source; | 11770 Source source; |
10812 | 11771 |
10813 /** | 11772 /** |
| 11773 * The time at which the contents of the source were last modified. |
| 11774 */ |
| 11775 int modificationTime = 0; |
| 11776 |
| 11777 /** |
| 11778 * The compilation unit used to resolve the dependencies. |
| 11779 */ |
| 11780 CompilationUnit _unit; |
| 11781 |
| 11782 /** |
10814 * The element model for the library containing the source. | 11783 * The element model for the library containing the source. |
10815 */ | 11784 */ |
10816 LibraryElement libraryElement; | 11785 LibraryElement libraryElement; |
10817 | 11786 |
10818 /** | 11787 /** |
10819 * The time at which the contents of the source were last modified. | |
10820 */ | |
10821 int _modificationTime = -1; | |
10822 | |
10823 /** | |
10824 * The errors that were generated for the source. | 11788 * The errors that were generated for the source. |
10825 */ | 11789 */ |
10826 List<AnalysisError> _errors; | 11790 List<AnalysisError> _errors; |
10827 | 11791 |
10828 /** | 11792 /** |
10829 * Initialize a newly created task to perform analysis within the given contex
t. | 11793 * Initialize a newly created task to perform analysis within the given contex
t. |
10830 * | 11794 * |
10831 * @param context the context in which the task is to be performed | 11795 * @param context the context in which the task is to be performed |
10832 * @param source the source for which errors and warnings are to be produced | 11796 * @param source the source for which errors and warnings are to be produced |
| 11797 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 11798 * @param unit the compilation unit used to resolve the dependencies |
10833 * @param libraryElement the element model for the library containing the sour
ce | 11799 * @param libraryElement the element model for the library containing the sour
ce |
10834 */ | 11800 */ |
10835 GenerateDartErrorsTask(InternalAnalysisContext context, Source source, Library
Element libraryElement) : super(context) { | 11801 GenerateDartErrorsTask(InternalAnalysisContext context, Source source, int mod
ificationTime, CompilationUnit unit, LibraryElement libraryElement) : super(cont
ext) { |
10836 this.source = source; | 11802 this.source = source; |
| 11803 this.modificationTime = modificationTime; |
| 11804 this._unit = unit; |
10837 this.libraryElement = libraryElement; | 11805 this.libraryElement = libraryElement; |
10838 } | 11806 } |
10839 | 11807 |
10840 @override | 11808 @override |
10841 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi
s); | 11809 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi
s); |
10842 | 11810 |
10843 /** | 11811 /** |
10844 * Return the errors that were generated for the source. | 11812 * Return the errors that were generated for the source. |
10845 * | 11813 * |
10846 * @return the errors that were generated for the source | 11814 * @return the errors that were generated for the source |
10847 */ | 11815 */ |
10848 List<AnalysisError> get errors => _errors; | 11816 List<AnalysisError> get errors => _errors; |
10849 | 11817 |
10850 /** | |
10851 * Return the time at which the contents of the source that was verified were
last modified, or a | |
10852 * negative value if the task has not yet been performed or if an exception oc
curred. | |
10853 * | |
10854 * @return the time at which the contents of the source that was verified were
last modified | |
10855 */ | |
10856 int get modificationTime => _modificationTime; | |
10857 | |
10858 @override | 11818 @override |
10859 String get taskDescription => "generate errors and warnings for ${source.fullN
ame}"; | 11819 String get taskDescription => "generate errors and warnings for ${source.fullN
ame}"; |
10860 | 11820 |
10861 @override | 11821 @override |
10862 void internalPerform() { | 11822 void internalPerform() { |
10863 InternalAnalysisContext context = this.context; | |
10864 TimestampedData<CompilationUnit> data = context.internalResolveCompilationUn
it(source, libraryElement); | |
10865 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta
rt(); | 11823 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta
rt(); |
10866 try { | 11824 try { |
10867 _modificationTime = data.modificationTime; | |
10868 CompilationUnit unit = data.data; | |
10869 RecordingErrorListener errorListener = new RecordingErrorListener(); | 11825 RecordingErrorListener errorListener = new RecordingErrorListener(); |
10870 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 11826 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
10871 TypeProvider typeProvider = context.typeProvider; | 11827 TypeProvider typeProvider = context.typeProvider; |
10872 // | 11828 // |
10873 // Use the ConstantVerifier to verify the use of constants. This needs to
happen before using | 11829 // Use the ConstantVerifier to verify the use of constants. This needs to
happen before using |
10874 // the ErrorVerifier because some error codes need the computed constant v
alues. | 11830 // the ErrorVerifier because some error codes need the computed constant v
alues. |
10875 // | 11831 // |
10876 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty
peProvider); | 11832 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty
peProvider); |
10877 unit.accept(constantVerifier); | 11833 _unit.accept(constantVerifier); |
10878 // | 11834 // |
10879 // Use the ErrorVerifier to compute the rest of the errors. | 11835 // Use the ErrorVerifier to compute the rest of the errors. |
10880 // | 11836 // |
10881 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libraryElem
ent, typeProvider, new InheritanceManager(libraryElement)); | 11837 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libraryElem
ent, typeProvider, new InheritanceManager(libraryElement)); |
10882 unit.accept(errorVerifier); | 11838 _unit.accept(errorVerifier); |
10883 _errors = errorListener.getErrorsForSource(source); | 11839 _errors = errorListener.getErrorsForSource(source); |
10884 } finally { | 11840 } finally { |
10885 timeCounter.stop(); | 11841 timeCounter.stop(); |
10886 } | 11842 } |
10887 } | 11843 } |
10888 } | 11844 } |
10889 | 11845 |
10890 /** | 11846 /** |
10891 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. | 11847 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. |
10892 */ | 11848 */ |
10893 class GenerateDartHintsTask extends AnalysisTask { | 11849 class GenerateDartHintsTask extends AnalysisTask { |
10894 /** | 11850 /** |
| 11851 * The compilation units that comprise the library, with the defining compilat
ion unit appearing |
| 11852 * first in the array. |
| 11853 */ |
| 11854 List<TimestampedData<CompilationUnit>> _units; |
| 11855 |
| 11856 /** |
10895 * The element model for the library being analyzed. | 11857 * The element model for the library being analyzed. |
10896 */ | 11858 */ |
10897 LibraryElement libraryElement; | 11859 LibraryElement libraryElement; |
10898 | 11860 |
10899 /** | 11861 /** |
10900 * A table mapping the sources that were analyzed to the hints that were gener
ated for the | 11862 * A table mapping the sources that were analyzed to the hints that were gener
ated for the |
10901 * sources. | 11863 * sources. |
10902 */ | 11864 */ |
10903 Map<Source, TimestampedData<List<AnalysisError>>> _hintMap; | 11865 Map<Source, TimestampedData<List<AnalysisError>>> _hintMap; |
10904 | 11866 |
10905 /** | 11867 /** |
10906 * Initialize a newly created task to perform analysis within the given contex
t. | 11868 * Initialize a newly created task to perform analysis within the given contex
t. |
10907 * | 11869 * |
10908 * @param context the context in which the task is to be performed | 11870 * @param context the context in which the task is to be performed |
| 11871 * @param units the compilation units that comprise the library, with the defi
ning compilation |
| 11872 * unit appearing first in the array |
10909 * @param libraryElement the element model for the library being analyzed | 11873 * @param libraryElement the element model for the library being analyzed |
10910 */ | 11874 */ |
10911 GenerateDartHintsTask(InternalAnalysisContext context, LibraryElement libraryE
lement) : super(context) { | 11875 GenerateDartHintsTask(InternalAnalysisContext context, List<TimestampedData<Co
mpilationUnit>> units, LibraryElement libraryElement) : super(context) { |
| 11876 this._units = units; |
10912 this.libraryElement = libraryElement; | 11877 this.libraryElement = libraryElement; |
10913 } | 11878 } |
10914 | 11879 |
10915 @override | 11880 @override |
10916 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); | 11881 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); |
10917 | 11882 |
10918 /** | 11883 /** |
10919 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the | 11884 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the |
10920 * sources, or `null` if the task has not been performed or if the analysis di
d not complete | 11885 * sources, or `null` if the task has not been performed or if the analysis di
d not complete |
10921 * normally. | 11886 * normally. |
10922 * | 11887 * |
10923 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the | 11888 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the |
10924 * sources | 11889 * sources |
10925 */ | 11890 */ |
10926 Map<Source, TimestampedData<List<AnalysisError>>> get hintMap => _hintMap; | 11891 Map<Source, TimestampedData<List<AnalysisError>>> get hintMap => _hintMap; |
10927 | 11892 |
10928 @override | 11893 @override |
10929 String get taskDescription { | 11894 String get taskDescription { |
10930 Source librarySource = libraryElement.source; | 11895 Source librarySource = libraryElement.source; |
10931 if (librarySource == null) { | 11896 if (librarySource == null) { |
10932 return "generate Dart hints for library without source"; | 11897 return "generate Dart hints for library without source"; |
10933 } | 11898 } |
10934 return "generate Dart hints for ${librarySource.fullName}"; | 11899 return "generate Dart hints for ${librarySource.fullName}"; |
10935 } | 11900 } |
10936 | 11901 |
10937 @override | 11902 @override |
10938 void internalPerform() { | 11903 void internalPerform() { |
10939 RecordingErrorListener errorListener = new RecordingErrorListener(); | |
10940 List<CompilationUnitElement> parts = libraryElement.parts; | |
10941 int partCount = parts.length; | |
10942 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(partCount
+ 1); | |
10943 Map<Source, TimestampedData<CompilationUnit>> timestampMap = new Map<Source,
TimestampedData<CompilationUnit>>(); | |
10944 // | 11904 // |
10945 // Get all of the (fully resolved) compilation units that will be analyzed. | 11905 // Gather the compilation units. |
10946 // | 11906 // |
10947 Source unitSource = libraryElement.definingCompilationUnit.source; | 11907 int unitCount = _units.length; |
10948 TimestampedData<CompilationUnit> resolvedUnit = _getCompilationUnit(unitSour
ce); | 11908 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(unitCount
); |
10949 timestampMap[unitSource] = resolvedUnit; | 11909 for (int i = 0; i < unitCount; i++) { |
10950 CompilationUnit unit = resolvedUnit.data; | 11910 compilationUnits[i] = _units[i].data; |
10951 if (unit == null) { | |
10952 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask fa
iled to access resolved compilation unit for ${unitSource.fullName}"); | |
10953 } | |
10954 compilationUnits[0] = unit; | |
10955 for (int i = 0; i < partCount; i++) { | |
10956 unitSource = parts[i].source; | |
10957 resolvedUnit = _getCompilationUnit(unitSource); | |
10958 timestampMap[unitSource] = resolvedUnit; | |
10959 unit = resolvedUnit.data; | |
10960 if (unit == null) { | |
10961 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask
failed to access resolved compilation unit for ${unitSource.fullName}"); | |
10962 } | |
10963 compilationUnits[i + 1] = unit; | |
10964 } | 11911 } |
10965 // | 11912 // |
10966 // Analyze all of the units. | 11913 // Analyze all of the units. |
10967 // | 11914 // |
| 11915 RecordingErrorListener errorListener = new RecordingErrorListener(); |
10968 HintGenerator hintGenerator = new HintGenerator(compilationUnits, context, e
rrorListener); | 11916 HintGenerator hintGenerator = new HintGenerator(compilationUnits, context, e
rrorListener); |
10969 hintGenerator.generateForLibrary(); | 11917 hintGenerator.generateForLibrary(); |
10970 // | 11918 // |
10971 // Store the results. | 11919 // Store the results. |
10972 // | 11920 // |
10973 _hintMap = new Map<Source, TimestampedData<List<AnalysisError>>>(); | 11921 _hintMap = new Map<Source, TimestampedData<List<AnalysisError>>>(); |
10974 for (MapEntry<Source, TimestampedData<CompilationUnit>> entry in getMapEntry
Set(timestampMap)) { | 11922 for (int i = 0; i < unitCount; i++) { |
10975 Source source = entry.getKey(); | 11923 int modificationTime = _units[i].modificationTime; |
10976 TimestampedData<CompilationUnit> unitData = entry.getValue(); | 11924 Source source = _units[i].data.element.source; |
10977 List<AnalysisError> errors = errorListener.getErrorsForSource(source); | 11925 List<AnalysisError> errors = errorListener.getErrorsForSource(source); |
10978 _hintMap[source] = new TimestampedData<List<AnalysisError>>(unitData.modif
icationTime, errors); | 11926 _hintMap[source] = new TimestampedData<List<AnalysisError>>(modificationTi
me, errors); |
10979 } | 11927 } |
10980 } | 11928 } |
10981 | |
10982 /** | |
10983 * Return the resolved compilation unit associated with the given source. | |
10984 * | |
10985 * @param unitSource the source for the compilation unit whose resolved AST is
to be returned | |
10986 * @return the resolved compilation unit associated with the given source | |
10987 * @throws AnalysisException if the resolved compilation unit could not be com
puted | |
10988 */ | |
10989 TimestampedData<CompilationUnit> _getCompilationUnit(Source unitSource) => con
text.internalResolveCompilationUnit(unitSource, libraryElement); | |
10990 } | 11929 } |
10991 | 11930 |
10992 /** | 11931 /** |
10993 * Instances of the class `GetContentTask` get the contents of a source. | 11932 * Instances of the class `GetContentTask` get the contents of a source. |
10994 */ | 11933 */ |
10995 class GetContentTask extends AnalysisTask { | 11934 class GetContentTask extends AnalysisTask { |
10996 /** | 11935 /** |
10997 * The source to be read. | 11936 * The source to be read. |
10998 */ | 11937 */ |
10999 Source source; | 11938 Source source; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11182 int modificationTime = 0; | 12121 int modificationTime = 0; |
11183 | 12122 |
11184 /** | 12123 /** |
11185 * The head of the token stream used for parsing. | 12124 * The head of the token stream used for parsing. |
11186 */ | 12125 */ |
11187 Token _tokenStream; | 12126 Token _tokenStream; |
11188 | 12127 |
11189 /** | 12128 /** |
11190 * The line information associated with the source. | 12129 * The line information associated with the source. |
11191 */ | 12130 */ |
11192 LineInfo _lineInfo; | 12131 LineInfo lineInfo; |
11193 | 12132 |
11194 /** | 12133 /** |
11195 * The compilation unit that was produced by parsing the source. | 12134 * The compilation unit that was produced by parsing the source. |
11196 */ | 12135 */ |
11197 CompilationUnit _unit; | 12136 CompilationUnit _unit; |
11198 | 12137 |
11199 /** | 12138 /** |
11200 * A flag indicating whether the source contains a 'library' directive. | 12139 * A flag indicating whether the source contains a 'library' directive. |
11201 */ | 12140 */ |
11202 bool _containsLibraryDirective = false; | 12141 bool _containsLibraryDirective = false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11237 * @param context the context in which the task is to be performed | 12176 * @param context the context in which the task is to be performed |
11238 * @param source the source to be parsed | 12177 * @param source the source to be parsed |
11239 * @param modificationTime the time at which the contents of the source were l
ast modified | 12178 * @param modificationTime the time at which the contents of the source were l
ast modified |
11240 * @param tokenStream the head of the token stream used for parsing | 12179 * @param tokenStream the head of the token stream used for parsing |
11241 * @param lineInfo the line information associated with the source | 12180 * @param lineInfo the line information associated with the source |
11242 */ | 12181 */ |
11243 ParseDartTask(InternalAnalysisContext context, Source source, int modification
Time, Token tokenStream, LineInfo lineInfo) : super(context) { | 12182 ParseDartTask(InternalAnalysisContext context, Source source, int modification
Time, Token tokenStream, LineInfo lineInfo) : super(context) { |
11244 this.source = source; | 12183 this.source = source; |
11245 this.modificationTime = modificationTime; | 12184 this.modificationTime = modificationTime; |
11246 this._tokenStream = tokenStream; | 12185 this._tokenStream = tokenStream; |
11247 this._lineInfo = lineInfo; | 12186 this.lineInfo = lineInfo; |
11248 } | 12187 } |
11249 | 12188 |
11250 @override | 12189 @override |
11251 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); | 12190 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); |
11252 | 12191 |
11253 /** | 12192 /** |
11254 * Return the compilation unit that was produced by parsing the source, or `nu
ll` if the | 12193 * Return the compilation unit that was produced by parsing the source, or `nu
ll` if the |
11255 * task has not yet been performed or if an exception occurred. | 12194 * task has not yet been performed or if an exception occurred. |
11256 * | 12195 * |
11257 * @return the compilation unit that was produced by parsing the source | 12196 * @return the compilation unit that was produced by parsing the source |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11318 void internalPerform() { | 12257 void internalPerform() { |
11319 // | 12258 // |
11320 // Then parse the token stream. | 12259 // Then parse the token stream. |
11321 // | 12260 // |
11322 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); | 12261 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); |
11323 try { | 12262 try { |
11324 RecordingErrorListener errorListener = new RecordingErrorListener(); | 12263 RecordingErrorListener errorListener = new RecordingErrorListener(); |
11325 Parser parser = new Parser(source, errorListener); | 12264 Parser parser = new Parser(source, errorListener); |
11326 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies
; | 12265 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies
; |
11327 _unit = parser.parseCompilationUnit(_tokenStream); | 12266 _unit = parser.parseCompilationUnit(_tokenStream); |
11328 _unit.lineInfo = _lineInfo; | 12267 _unit.lineInfo = lineInfo; |
11329 _errors = errorListener.getErrorsForSource(source); | 12268 _errors = errorListener.getErrorsForSource(source); |
11330 for (Directive directive in _unit.directives) { | 12269 for (Directive directive in _unit.directives) { |
11331 if (directive is ExportDirective) { | 12270 if (directive is ExportDirective) { |
11332 Source exportSource = _resolveSource(source, directive, errorListener)
; | 12271 Source exportSource = _resolveSource(source, directive, errorListener)
; |
11333 if (exportSource != null) { | 12272 if (exportSource != null) { |
11334 _exportedSources.add(exportSource); | 12273 _exportedSources.add(exportSource); |
11335 } | 12274 } |
11336 } else if (directive is ImportDirective) { | 12275 } else if (directive is ImportDirective) { |
11337 Source importSource = _resolveSource(source, directive, errorListener)
; | 12276 Source importSource = _resolveSource(source, directive, errorListener)
; |
11338 if (importSource != null) { | 12277 if (importSource != null) { |
11339 _importedSources.add(importSource); | 12278 _importedSources.add(importSource); |
11340 } | 12279 } |
11341 } else if (directive is LibraryDirective) { | 12280 } else if (directive is LibraryDirective) { |
11342 _containsLibraryDirective = true; | 12281 _containsLibraryDirective = true; |
11343 } else if (directive is PartDirective) { | 12282 } else if (directive is PartDirective) { |
11344 Source partSource = _resolveSource(source, directive, errorListener); | 12283 Source partSource = _resolveSource(source, directive, errorListener); |
11345 if (partSource != null) { | 12284 if (partSource != null && partSource != source) { |
11346 _includedSources.add(partSource); | 12285 _includedSources.add(partSource); |
11347 } | 12286 } |
11348 } else if (directive is PartOfDirective) { | 12287 } else if (directive is PartOfDirective) { |
11349 _containsPartOfDirective = true; | 12288 _containsPartOfDirective = true; |
11350 } | 12289 } |
11351 } | 12290 } |
11352 } finally { | 12291 } finally { |
11353 timeCounterParse.stop(); | 12292 timeCounterParse.stop(); |
11354 } | 12293 } |
11355 } | 12294 } |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11774 // | 12713 // |
11775 // Remember the resolved unit. | 12714 // Remember the resolved unit. |
11776 // | 12715 // |
11777 _resolvedUnit = _unit; | 12716 _resolvedUnit = _unit; |
11778 } | 12717 } |
11779 } | 12718 } |
11780 | 12719 |
11781 /** | 12720 /** |
11782 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. | 12721 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. |
11783 */ | 12722 */ |
| 12723 class ResolveDartLibraryCycleTask extends AnalysisTask { |
| 12724 /** |
| 12725 * The source representing the file whose compilation unit is to be returned.
TODO(brianwilkerson) |
| 12726 * This should probably be removed, but is being left in for now to ease the t
ransition. |
| 12727 */ |
| 12728 Source unitSource; |
| 12729 |
| 12730 /** |
| 12731 * The source representing the library to be resolved. |
| 12732 */ |
| 12733 Source librarySource; |
| 12734 |
| 12735 /** |
| 12736 * The libraries that are part of the cycle containing the library to be resol
ved. |
| 12737 */ |
| 12738 List<ResolvableLibrary> _librariesInCycle; |
| 12739 |
| 12740 /** |
| 12741 * The library resolver holding information about the libraries that were reso
lved. |
| 12742 */ |
| 12743 LibraryResolver2 _resolver; |
| 12744 |
| 12745 /** |
| 12746 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12747 * |
| 12748 * @param context the context in which the task is to be performed |
| 12749 * @param unitSource the source representing the file whose compilation unit i
s to be returned |
| 12750 * @param librarySource the source representing the library to be resolved |
| 12751 * @param librariesInCycle the libraries that are part of the cycle containing
the library to be |
| 12752 * resolved |
| 12753 */ |
| 12754 ResolveDartLibraryCycleTask(InternalAnalysisContext context, Source unitSource
, Source librarySource, List<ResolvableLibrary> librariesInCycle) : super(contex
t) { |
| 12755 this.unitSource = unitSource; |
| 12756 this.librarySource = librarySource; |
| 12757 this._librariesInCycle = librariesInCycle; |
| 12758 } |
| 12759 |
| 12760 @override |
| 12761 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryCycleTas
k(this); |
| 12762 |
| 12763 /** |
| 12764 * Return the library resolver holding information about the libraries that we
re resolved. |
| 12765 * |
| 12766 * @return the library resolver holding information about the libraries that w
ere resolved |
| 12767 */ |
| 12768 LibraryResolver2 get libraryResolver => _resolver; |
| 12769 |
| 12770 @override |
| 12771 String get taskDescription { |
| 12772 if (librarySource == null) { |
| 12773 return "resolve library null source"; |
| 12774 } |
| 12775 return "resolve library ${librarySource.fullName}"; |
| 12776 } |
| 12777 |
| 12778 @override |
| 12779 void internalPerform() { |
| 12780 _resolver = new LibraryResolver2(context); |
| 12781 _resolver.resolveLibrary(librarySource, _librariesInCycle); |
| 12782 } |
| 12783 } |
| 12784 |
| 12785 /** |
| 12786 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. |
| 12787 */ |
11784 class ResolveDartLibraryTask extends AnalysisTask { | 12788 class ResolveDartLibraryTask extends AnalysisTask { |
11785 /** | 12789 /** |
11786 * The source representing the file whose compilation unit is to be returned. | 12790 * The source representing the file whose compilation unit is to be returned. |
11787 */ | 12791 */ |
11788 Source unitSource; | 12792 Source unitSource; |
11789 | 12793 |
11790 /** | 12794 /** |
11791 * The source representing the library to be resolved. | 12795 * The source representing the library to be resolved. |
11792 */ | 12796 */ |
11793 Source librarySource; | 12797 Source librarySource; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12256 } | 13260 } |
12257 | 13261 |
12258 @override | 13262 @override |
12259 void logInformation(String message) { | 13263 void logInformation(String message) { |
12260 } | 13264 } |
12261 | 13265 |
12262 @override | 13266 @override |
12263 void logInformation2(String message, Exception exception) { | 13267 void logInformation2(String message, Exception exception) { |
12264 } | 13268 } |
12265 } | 13269 } |
OLD | NEW |