| 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 3671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3682 void addSourceInfo(Source source, SourceEntry info) { | 3682 void addSourceInfo(Source source, SourceEntry info) { |
| 3683 // This implementation assumes that the access to the cache does not need to
be synchronized | 3683 // This implementation assumes that the access to the cache does not need to
be synchronized |
| 3684 // because no other object can have access to this context while this method
is being invoked. | 3684 // because no other object can have access to this context while this method
is being invoked. |
| 3685 _cache.put(source, info); | 3685 _cache.put(source, info); |
| 3686 } | 3686 } |
| 3687 | 3687 |
| 3688 void applyChanges(ChangeSet changeSet) { | 3688 void applyChanges(ChangeSet changeSet) { |
| 3689 if (changeSet.isEmpty) { | 3689 if (changeSet.isEmpty) { |
| 3690 return; | 3690 return; |
| 3691 } | 3691 } |
| 3692 { | 3692 _recentTasks.clear(); |
| 3693 _recentTasks.clear(); | 3693 // |
| 3694 // | 3694 // First, compute the list of sources that have been removed. |
| 3695 // First, compute the list of sources that have been removed. | 3695 // |
| 3696 // | 3696 List<Source> removedSources = new List<Source>.from(changeSet.removed3); |
| 3697 List<Source> removedSources = new List<Source>.from(changeSet.removed3); | 3697 for (SourceContainer container in changeSet.removedContainers) { |
| 3698 for (SourceContainer container in changeSet.removedContainers) { | 3698 addSourcesInContainer(removedSources, container); |
| 3699 addSourcesInContainer(removedSources, container); | 3699 } |
| 3700 // |
| 3701 // Then determine which cached results are no longer valid. |
| 3702 // |
| 3703 bool addedDartSource = false; |
| 3704 for (Source source in changeSet.added3) { |
| 3705 if (sourceAvailable(source)) { |
| 3706 addedDartSource = true; |
| 3700 } | 3707 } |
| 3701 // | 3708 } |
| 3702 // Then determine which cached results are no longer valid. | 3709 for (Source source in changeSet.changed3) { |
| 3703 // | 3710 sourceChanged(source); |
| 3704 bool addedDartSource = false; | 3711 } |
| 3705 for (Source source in changeSet.added3) { | 3712 for (Source source in removedSources) { |
| 3706 if (sourceAvailable(source)) { | 3713 sourceRemoved(source); |
| 3707 addedDartSource = true; | 3714 } |
| 3708 } | 3715 if (addedDartSource) { |
| 3709 } | 3716 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal
yze any libraries |
| 3710 for (Source source in changeSet.changed3) { | 3717 // that might have been referencing the not-yet-existing source that was j
ust added. Longer |
| 3711 sourceChanged(source); | 3718 // term we need to keep track of which libraries are referencing non-exist
ing sources and |
| 3712 } | 3719 // only re-analyze those libraries. |
| 3713 for (Source source in removedSources) { | 3720 logInformation("Added Dart sources, invalidating all resolution informatio
n"); |
| 3714 sourceRemoved(source); | 3721 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 3715 } | 3722 Source source = mapEntry.getKey(); |
| 3716 if (addedDartSource) { | 3723 SourceEntry sourceEntry = mapEntry.getValue(); |
| 3717 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-an
alyze any libraries | 3724 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { |
| 3718 // that might have been referencing the not-yet-existing source that was
just added. Longer | 3725 DartEntry dartEntry = sourceEntry; |
| 3719 // term we need to keep track of which libraries are referencing non-exi
sting sources and | 3726 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3720 // only re-analyze those libraries. | 3727 removeFromParts(source, dartEntry); |
| 3721 logInformation("Added Dart sources, invalidating all resolution informat
ion"); | 3728 dartCopy.invalidateAllResolutionInformation(); |
| 3722 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 3729 mapEntry.setValue(dartCopy); |
| 3723 Source source = mapEntry.getKey(); | 3730 SourcePriority priority = SourcePriority.UNKNOWN; |
| 3724 SourceEntry sourceEntry = mapEntry.getValue(); | 3731 SourceKind kind = dartCopy.kind; |
| 3725 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { | 3732 if (identical(kind, SourceKind.LIBRARY)) { |
| 3726 DartEntry dartEntry = sourceEntry; | 3733 priority = SourcePriority.LIBRARY; |
| 3727 DartEntryImpl dartCopy = dartEntry.writableCopy; | 3734 } else if (identical(kind, SourceKind.PART)) { |
| 3728 removeFromParts(source, dartEntry); | 3735 priority = SourcePriority.NORMAL_PART; |
| 3729 dartCopy.invalidateAllResolutionInformation(); | |
| 3730 mapEntry.setValue(dartCopy); | |
| 3731 SourcePriority priority = SourcePriority.UNKNOWN; | |
| 3732 SourceKind kind = dartCopy.kind; | |
| 3733 if (identical(kind, SourceKind.LIBRARY)) { | |
| 3734 priority = SourcePriority.LIBRARY; | |
| 3735 } else if (identical(kind, SourceKind.PART)) { | |
| 3736 priority = SourcePriority.NORMAL_PART; | |
| 3737 } | |
| 3738 _workManager.add(source, priority); | |
| 3739 } | 3736 } |
| 3737 _workManager.add(source, priority); |
| 3740 } | 3738 } |
| 3741 } | 3739 } |
| 3742 } | 3740 } |
| 3743 } | 3741 } |
| 3744 | 3742 |
| 3745 String computeDocumentationComment(Element element) { | 3743 String computeDocumentationComment(Element element) { |
| 3746 if (element == null) { | 3744 if (element == null) { |
| 3747 return null; | 3745 return null; |
| 3748 } | 3746 } |
| 3749 Source source = element.source; | 3747 Source source = element.source; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 3869 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 3872 if (unit == null) { | 3870 if (unit == null) { |
| 3873 AnalysisException cause = htmlEntry.exception; | 3871 AnalysisException cause = htmlEntry.exception; |
| 3874 throw new AnalysisException.con2("Internal error: computeResolvableAngular
ComponentHtmlUnit could not resolve ${source.fullName}", cause); | 3872 throw new AnalysisException.con2("Internal error: computeResolvableAngular
ComponentHtmlUnit could not resolve ${source.fullName}", cause); |
| 3875 } | 3873 } |
| 3876 // If the unit is ever modified by resolution then we will need to create a
copy of it. | 3874 // If the unit is ever modified by resolution then we will need to create a
copy of it. |
| 3877 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); | 3875 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); |
| 3878 } | 3876 } |
| 3879 | 3877 |
| 3880 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { | 3878 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { |
| 3881 { | 3879 DartEntry dartEntry = getReadableDartEntry(source); |
| 3882 DartEntry dartEntry = getReadableDartEntry(source); | 3880 if (dartEntry == null) { |
| 3883 if (dartEntry == null) { | 3881 throw new AnalysisException.con1("computeResolvableCompilationUnit for non
-Dart: ${source.fullName}"); |
| 3884 throw new AnalysisException.con1("computeResolvableCompilationUnit for n
on-Dart: ${source.fullName}"); | |
| 3885 } | |
| 3886 dartEntry = cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); | |
| 3887 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 3888 CompilationUnit unit = dartCopy.resolvableCompilationUnit; | |
| 3889 if (unit == null) { | |
| 3890 throw new AnalysisException.con2("Internal error: computeResolvableCompi
lationUnit could not parse ${source.fullName}", dartEntry.exception); | |
| 3891 } | |
| 3892 _cache.put(source, dartCopy); | |
| 3893 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); | |
| 3894 } | 3882 } |
| 3883 dartEntry = cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); |
| 3884 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3885 CompilationUnit unit = dartCopy.resolvableCompilationUnit; |
| 3886 if (unit == null) { |
| 3887 throw new AnalysisException.con2("Internal error: computeResolvableCompila
tionUnit could not parse ${source.fullName}", dartEntry.exception); |
| 3888 } |
| 3889 _cache.put(source, dartCopy); |
| 3890 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); |
| 3895 } | 3891 } |
| 3896 | 3892 |
| 3897 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) { | 3893 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) { |
| 3898 HtmlEntry htmlEntry = getReadableHtmlEntry(source); | 3894 HtmlEntry htmlEntry = getReadableHtmlEntry(source); |
| 3899 if (htmlEntry == null) { | 3895 if (htmlEntry == null) { |
| 3900 throw new AnalysisException.con1("computeResolvableHtmlUnit invoked for no
n-HTML file: ${source.fullName}"); | 3896 throw new AnalysisException.con1("computeResolvableHtmlUnit invoked for no
n-HTML file: ${source.fullName}"); |
| 3901 } | 3897 } |
| 3902 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); | 3898 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); |
| 3903 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 3899 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 3904 if (unit == null) { | 3900 if (unit == null) { |
| 3905 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t could not parse ${source.fullName}"); | 3901 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t could not parse ${source.fullName}"); |
| 3906 } | 3902 } |
| 3907 // If the unit is ever modified by resolution then we will need to create a
copy of it. | 3903 // If the unit is ever modified by resolution then we will need to create a
copy of it. |
| 3908 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); | 3904 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); |
| 3909 } | 3905 } |
| 3910 | 3906 |
| 3911 bool exists(Source source) { | 3907 bool exists(Source source) { |
| 3912 if (source == null) { | 3908 if (source == null) { |
| 3913 return false; | 3909 return false; |
| 3914 } | 3910 } |
| 3915 { | 3911 if (_contentCache.getContents(source) != null) { |
| 3916 if (_contentCache.getContents(source) != null) { | 3912 return true; |
| 3917 return true; | |
| 3918 } | |
| 3919 } | 3913 } |
| 3920 return source.exists(); | 3914 return source.exists(); |
| 3921 } | 3915 } |
| 3922 | 3916 |
| 3923 AnalysisContext extractContext(SourceContainer container) => extractContextInt
o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis
Context); | 3917 AnalysisContext extractContext(SourceContainer container) => extractContextInt
o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis
Context); |
| 3924 | 3918 |
| 3925 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) { | 3919 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) { |
| 3926 List<Source> sourcesToRemove = new List<Source>(); | 3920 List<Source> sourcesToRemove = new List<Source>(); |
| 3927 { | 3921 // Move sources in the specified directory to the new context |
| 3928 // Move sources in the specified directory to the new context | 3922 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 3929 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 3923 Source source = entry.getKey(); |
| 3930 Source source = entry.getKey(); | 3924 if (container.contains(source)) { |
| 3931 if (container.contains(source)) { | 3925 sourcesToRemove.add(source); |
| 3932 sourcesToRemove.add(source); | 3926 newContext.addSourceInfo(source, entry.getValue().writableCopy); |
| 3933 newContext.addSourceInfo(source, entry.getValue().writableCopy); | |
| 3934 } | |
| 3935 } | 3927 } |
| 3936 } | 3928 } |
| 3937 return newContext; | 3929 return newContext; |
| 3938 } | 3930 } |
| 3939 | 3931 |
| 3940 AnalysisOptions get analysisOptions => _options; | 3932 AnalysisOptions get analysisOptions => _options; |
| 3941 | 3933 |
| 3942 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource) { | 3934 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib
rarySource) { |
| 3943 LibraryElement libraryElement = getLibraryElement(librarySource); | 3935 LibraryElement libraryElement = getLibraryElement(librarySource); |
| 3944 if (libraryElement != null) { | 3936 if (libraryElement != null) { |
| 3945 // try defining unit | 3937 // try defining unit |
| 3946 CompilationUnitElement definingUnit = libraryElement.definingCompilationUn
it; | 3938 CompilationUnitElement definingUnit = libraryElement.definingCompilationUn
it; |
| 3947 if (definingUnit.source == unitSource) { | 3939 if (definingUnit.source == unitSource) { |
| 3948 return definingUnit; | 3940 return definingUnit; |
| 3949 } | 3941 } |
| 3950 // try parts | 3942 // try parts |
| 3951 for (CompilationUnitElement partUnit in libraryElement.parts) { | 3943 for (CompilationUnitElement partUnit in libraryElement.parts) { |
| 3952 if (partUnit.source == unitSource) { | 3944 if (partUnit.source == unitSource) { |
| 3953 return partUnit; | 3945 return partUnit; |
| 3954 } | 3946 } |
| 3955 } | 3947 } |
| 3956 } | 3948 } |
| 3957 return null; | 3949 return null; |
| 3958 } | 3950 } |
| 3959 | 3951 |
| 3960 TimestampedData<String> getContents(Source source) { | 3952 TimestampedData<String> getContents(Source source) { |
| 3961 { | 3953 String contents = _contentCache.getContents(source); |
| 3962 String contents = _contentCache.getContents(source); | 3954 if (contents != null) { |
| 3963 if (contents != null) { | 3955 return new TimestampedData<String>(_contentCache.getModificationStamp(sour
ce), contents); |
| 3964 return new TimestampedData<String>(_contentCache.getModificationStamp(so
urce), contents); | |
| 3965 } | |
| 3966 } | 3956 } |
| 3967 return source.contents; | 3957 return source.contents; |
| 3968 } | 3958 } |
| 3969 | 3959 |
| 3970 void getContentsToReceiver(Source source, Source_ContentReceiver receiver) { | 3960 void getContentsToReceiver(Source source, Source_ContentReceiver receiver) { |
| 3971 { | 3961 String contents = _contentCache.getContents(source); |
| 3972 String contents = _contentCache.getContents(source); | 3962 if (contents != null) { |
| 3973 if (contents != null) { | 3963 receiver.accept(contents, _contentCache.getModificationStamp(source)); |
| 3974 receiver.accept(contents, _contentCache.getModificationStamp(source)); | 3964 return; |
| 3975 return; | |
| 3976 } | |
| 3977 } | 3965 } |
| 3978 source.getContentsToReceiver(receiver); | 3966 source.getContentsToReceiver(receiver); |
| 3979 } | 3967 } |
| 3980 | 3968 |
| 3981 Element getElement(ElementLocation location) { | 3969 Element getElement(ElementLocation location) { |
| 3982 // TODO(brianwilkerson) This should not be a "get" method. | 3970 // TODO(brianwilkerson) This should not be a "get" method. |
| 3983 try { | 3971 try { |
| 3984 List<String> components = (location as ElementLocationImpl).components; | 3972 List<String> components = (location as ElementLocationImpl).components; |
| 3985 Source librarySource = computeSourceFromEncoding(components[0]); | 3973 Source librarySource = computeSourceFromEncoding(components[0]); |
| 3986 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; | 3974 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4014 return sourceEntry.getValue(HtmlEntry.ELEMENT); | 4002 return sourceEntry.getValue(HtmlEntry.ELEMENT); |
| 4015 } | 4003 } |
| 4016 return null; | 4004 return null; |
| 4017 } | 4005 } |
| 4018 | 4006 |
| 4019 List<Source> getHtmlFilesReferencing(Source source) { | 4007 List<Source> getHtmlFilesReferencing(Source source) { |
| 4020 SourceKind sourceKind = getKindOf(source); | 4008 SourceKind sourceKind = getKindOf(source); |
| 4021 if (sourceKind == null) { | 4009 if (sourceKind == null) { |
| 4022 return Source.EMPTY_ARRAY; | 4010 return Source.EMPTY_ARRAY; |
| 4023 } | 4011 } |
| 4024 { | 4012 List<Source> htmlSources = new List<Source>(); |
| 4025 List<Source> htmlSources = new List<Source>(); | 4013 while (true) { |
| 4026 while (true) { | 4014 if (sourceKind == SourceKind.LIBRARY) { |
| 4027 if (sourceKind == SourceKind.LIBRARY) { | 4015 } else if (sourceKind == SourceKind.PART) { |
| 4028 } else if (sourceKind == SourceKind.PART) { | 4016 List<Source> librarySources = getLibrariesContaining(source); |
| 4029 List<Source> librarySources = getLibrariesContaining(source); | 4017 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4030 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4018 SourceEntry sourceEntry = entry.getValue(); |
| 4031 SourceEntry sourceEntry = entry.getValue(); | 4019 if (identical(sourceEntry.kind, SourceKind.HTML)) { |
| 4032 if (identical(sourceEntry.kind, SourceKind.HTML)) { | 4020 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal
ue(HtmlEntry.REFERENCED_LIBRARIES); |
| 4033 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getV
alue(HtmlEntry.REFERENCED_LIBRARIES); | 4021 if (containsAny(referencedLibraries, librarySources)) { |
| 4034 if (containsAny(referencedLibraries, librarySources)) { | 4022 htmlSources.add(entry.getKey()); |
| 4035 htmlSources.add(entry.getKey()); | |
| 4036 } | |
| 4037 } | 4023 } |
| 4038 } | 4024 } |
| 4039 } | 4025 } |
| 4040 break; | |
| 4041 } | 4026 } |
| 4042 if (htmlSources.isEmpty) { | 4027 break; |
| 4043 return Source.EMPTY_ARRAY; | |
| 4044 } | |
| 4045 return new List.from(htmlSources); | |
| 4046 } | 4028 } |
| 4029 if (htmlSources.isEmpty) { |
| 4030 return Source.EMPTY_ARRAY; |
| 4031 } |
| 4032 return new List.from(htmlSources); |
| 4047 } | 4033 } |
| 4048 | 4034 |
| 4049 List<Source> get htmlSources => getSources(SourceKind.HTML); | 4035 List<Source> get htmlSources => getSources(SourceKind.HTML); |
| 4050 | 4036 |
| 4051 SourceKind getKindOf(Source source) { | 4037 SourceKind getKindOf(Source source) { |
| 4052 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4038 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 4053 if (sourceEntry == null) { | 4039 if (sourceEntry == null) { |
| 4054 return SourceKind.UNKNOWN; | 4040 return SourceKind.UNKNOWN; |
| 4055 } | 4041 } |
| 4056 return sourceEntry.kind; | 4042 return sourceEntry.kind; |
| 4057 } | 4043 } |
| 4058 | 4044 |
| 4059 List<Source> get launchableClientLibrarySources { | 4045 List<Source> get launchableClientLibrarySources { |
| 4060 // TODO(brianwilkerson) This needs to filter out libraries that do not refer
ence dart:html, | 4046 // TODO(brianwilkerson) This needs to filter out libraries that do not refer
ence dart:html, |
| 4061 // either directly or indirectly. | 4047 // either directly or indirectly. |
| 4062 List<Source> sources = new List<Source>(); | 4048 List<Source> sources = new List<Source>(); |
| 4063 { | 4049 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4064 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4050 Source source = entry.getKey(); |
| 4065 Source source = entry.getKey(); | 4051 SourceEntry sourceEntry = entry.getValue(); |
| 4066 SourceEntry sourceEntry = entry.getValue(); | 4052 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemL
ibrary) { |
| 4067 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste
mLibrary) { | 4053 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 4068 // DartEntry dartEntry = (DartEntry) sourceEntry; | 4054 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry
.getValue(DartEntry.IS_CLIENT)) { |
| 4069 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEnt
ry.getValue(DartEntry.IS_CLIENT)) { | 4055 sources.add(source); |
| 4070 sources.add(source); | |
| 4071 } | |
| 4072 } | 4056 } |
| 4073 } | 4057 } |
| 4074 return new List.from(sources); | 4058 return new List.from(sources); |
| 4075 } | 4059 } |
| 4076 | 4060 |
| 4077 List<Source> get launchableServerLibrarySources { | 4061 List<Source> get launchableServerLibrarySources { |
| 4078 // TODO(brianwilkerson) This needs to filter out libraries that reference da
rt:html, either | 4062 // TODO(brianwilkerson) This needs to filter out libraries that reference da
rt:html, either |
| 4079 // directly or indirectly. | 4063 // directly or indirectly. |
| 4080 List<Source> sources = new List<Source>(); | 4064 List<Source> sources = new List<Source>(); |
| 4081 { | 4065 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4082 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4066 Source source = entry.getKey(); |
| 4083 Source source = entry.getKey(); | 4067 SourceEntry sourceEntry = entry.getValue(); |
| 4084 SourceEntry sourceEntry = entry.getValue(); | 4068 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemL
ibrary) { |
| 4085 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste
mLibrary) { | 4069 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 4086 // DartEntry dartEntry = (DartEntry) sourceEntry; | 4070 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr
y.getValue(DartEntry.IS_CLIENT)) { |
| 4087 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEn
try.getValue(DartEntry.IS_CLIENT)) { | 4071 sources.add(source); |
| 4088 sources.add(source); | |
| 4089 } | |
| 4090 } | 4072 } |
| 4091 } | 4073 } |
| 4092 return new List.from(sources); | 4074 return new List.from(sources); |
| 4093 } | 4075 } |
| 4094 | 4076 |
| 4095 List<Source> getLibrariesContaining(Source source) { | 4077 List<Source> getLibrariesContaining(Source source) { |
| 4096 DartEntry dartEntry = getReadableDartEntry(source); | 4078 DartEntry dartEntry = getReadableDartEntry(source); |
| 4097 if (dartEntry == null) { | 4079 if (dartEntry == null) { |
| 4098 return Source.EMPTY_ARRAY; | 4080 return Source.EMPTY_ARRAY; |
| 4099 } | 4081 } |
| 4100 return dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES); | 4082 return dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES); |
| 4101 } | 4083 } |
| 4102 | 4084 |
| 4103 List<Source> getLibrariesDependingOn(Source librarySource) { | 4085 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 4104 { | 4086 List<Source> dependentLibraries = new List<Source>(); |
| 4105 List<Source> dependentLibraries = new List<Source>(); | 4087 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4106 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4088 SourceEntry sourceEntry = entry.getValue(); |
| 4107 SourceEntry sourceEntry = entry.getValue(); | 4089 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { |
| 4108 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { | 4090 if (contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIBR
ARIES), librarySource)) { |
| 4109 if (contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LI
BRARIES), librarySource)) { | 4091 dependentLibraries.add(entry.getKey()); |
| 4110 dependentLibraries.add(entry.getKey()); | 4092 } |
| 4111 } | 4093 if (contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIBR
ARIES), librarySource)) { |
| 4112 if (contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LI
BRARIES), librarySource)) { | 4094 dependentLibraries.add(entry.getKey()); |
| 4113 dependentLibraries.add(entry.getKey()); | |
| 4114 } | |
| 4115 } | 4095 } |
| 4116 } | 4096 } |
| 4117 if (dependentLibraries.isEmpty) { | |
| 4118 return Source.EMPTY_ARRAY; | |
| 4119 } | |
| 4120 return new List.from(dependentLibraries); | |
| 4121 } | 4097 } |
| 4098 if (dependentLibraries.isEmpty) { |
| 4099 return Source.EMPTY_ARRAY; |
| 4100 } |
| 4101 return new List.from(dependentLibraries); |
| 4122 } | 4102 } |
| 4123 | 4103 |
| 4124 LibraryElement getLibraryElement(Source source) { | 4104 LibraryElement getLibraryElement(Source source) { |
| 4125 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4105 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 4126 if (sourceEntry is DartEntry) { | 4106 if (sourceEntry is DartEntry) { |
| 4127 return sourceEntry.getValue(DartEntry.ELEMENT); | 4107 return sourceEntry.getValue(DartEntry.ELEMENT); |
| 4128 } | 4108 } |
| 4129 return null; | 4109 return null; |
| 4130 } | 4110 } |
| 4131 | 4111 |
| 4132 List<Source> get librarySources => getSources(SourceKind.LIBRARY); | 4112 List<Source> get librarySources => getSources(SourceKind.LIBRARY); |
| 4133 | 4113 |
| 4134 LineInfo getLineInfo(Source source) { | 4114 LineInfo getLineInfo(Source source) { |
| 4135 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4115 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 4136 if (sourceEntry != null) { | 4116 if (sourceEntry != null) { |
| 4137 return sourceEntry.getValue(SourceEntry.LINE_INFO); | 4117 return sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 4138 } | 4118 } |
| 4139 return null; | 4119 return null; |
| 4140 } | 4120 } |
| 4141 | 4121 |
| 4142 int getModificationStamp(Source source) { | 4122 int getModificationStamp(Source source) { |
| 4143 { | 4123 int stamp = _contentCache.getModificationStamp(source); |
| 4144 int stamp = _contentCache.getModificationStamp(source); | 4124 if (stamp != null) { |
| 4145 if (stamp != null) { | 4125 return stamp; |
| 4146 return stamp; | |
| 4147 } | |
| 4148 } | 4126 } |
| 4149 return source.modificationStamp; | 4127 return source.modificationStamp; |
| 4150 } | 4128 } |
| 4151 | 4129 |
| 4152 Namespace getPublicNamespace(LibraryElement library) { | 4130 Namespace getPublicNamespace(LibraryElement library) { |
| 4153 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the | 4131 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the |
| 4154 // API of the interface. | 4132 // API of the interface. |
| 4155 Source source = library.definingCompilationUnit.source; | 4133 Source source = library.definingCompilationUnit.source; |
| 4156 DartEntry dartEntry = getReadableDartEntry(source); | 4134 DartEntry dartEntry = getReadableDartEntry(source); |
| 4157 if (dartEntry == null) { | 4135 if (dartEntry == null) { |
| 4158 return null; | 4136 return null; |
| 4159 } | 4137 } |
| 4160 Namespace namespace = null; | 4138 Namespace namespace = null; |
| 4161 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 4139 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 4162 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 4140 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 4163 } | 4141 } |
| 4164 if (namespace == null) { | 4142 if (namespace == null) { |
| 4165 NamespaceBuilder builder = new NamespaceBuilder(); | 4143 NamespaceBuilder builder = new NamespaceBuilder(); |
| 4166 namespace = builder.createPublicNamespace(library); | 4144 namespace = builder.createPublicNamespace(library); |
| 4167 { | 4145 dartEntry = getReadableDartEntry(source); |
| 4168 dartEntry = getReadableDartEntry(source); | 4146 if (dartEntry == null) { |
| 4169 if (dartEntry == null) { | 4147 AnalysisEngine.instance.logger.logError2("Could not compute the public n
amespace for ${library.source.fullName}", new AnalysisException.con1("A Dart fil
e became a non-Dart file: ${source.fullName}")); |
| 4170 AnalysisEngine.instance.logger.logError2("Could not compute the public
namespace for ${library.source.fullName}", new AnalysisException.con1("A Dart f
ile became a non-Dart file: ${source.fullName}")); | 4148 return null; |
| 4171 return null; | 4149 } |
| 4172 } | 4150 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 4173 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 4151 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; |
| 4174 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; | 4152 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 4175 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 4153 _cache.put(source, dartCopy); |
| 4176 _cache.put(source, dartCopy); | |
| 4177 } | |
| 4178 } | 4154 } |
| 4179 } | 4155 } |
| 4180 return namespace; | 4156 return namespace; |
| 4181 } | 4157 } |
| 4182 | 4158 |
| 4183 Namespace getPublicNamespace2(Source source) { | 4159 Namespace getPublicNamespace2(Source source) { |
| 4184 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the | 4160 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the |
| 4185 // API of the interface. | 4161 // API of the interface. |
| 4186 DartEntry dartEntry = getReadableDartEntry(source); | 4162 DartEntry dartEntry = getReadableDartEntry(source); |
| 4187 if (dartEntry == null) { | 4163 if (dartEntry == null) { |
| 4188 return null; | 4164 return null; |
| 4189 } | 4165 } |
| 4190 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 4166 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 4191 if (namespace == null) { | 4167 if (namespace == null) { |
| 4192 LibraryElement library = computeLibraryElement(source); | 4168 LibraryElement library = computeLibraryElement(source); |
| 4193 if (library == null) { | 4169 if (library == null) { |
| 4194 return null; | 4170 return null; |
| 4195 } | 4171 } |
| 4196 NamespaceBuilder builder = new NamespaceBuilder(); | 4172 NamespaceBuilder builder = new NamespaceBuilder(); |
| 4197 namespace = builder.createPublicNamespace(library); | 4173 namespace = builder.createPublicNamespace(library); |
| 4198 { | 4174 dartEntry = getReadableDartEntry(source); |
| 4199 dartEntry = getReadableDartEntry(source); | 4175 if (dartEntry == null) { |
| 4200 if (dartEntry == null) { | 4176 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
source.fullName}"); |
| 4201 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 4177 } |
| 4202 } | 4178 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 4203 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 4179 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; |
| 4204 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; | 4180 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 4205 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 4181 _cache.put(source, dartCopy); |
| 4206 _cache.put(source, dartCopy); | |
| 4207 } | |
| 4208 } | 4182 } |
| 4209 } | 4183 } |
| 4210 return namespace; | 4184 return namespace; |
| 4211 } | 4185 } |
| 4212 | 4186 |
| 4213 List<Source> get refactoringUnsafeSources { | 4187 List<Source> get refactoringUnsafeSources { |
| 4214 List<Source> sources = new List<Source>(); | 4188 List<Source> sources = new List<Source>(); |
| 4215 { | 4189 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4216 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4190 SourceEntry sourceEntry = entry.getValue(); |
| 4217 SourceEntry sourceEntry = entry.getValue(); | 4191 if (sourceEntry is DartEntry) { |
| 4218 if (sourceEntry is DartEntry) { | 4192 if (!sourceEntry.isRefactoringSafe) { |
| 4219 if (!sourceEntry.isRefactoringSafe) { | 4193 sources.add(entry.getKey()); |
| 4220 sources.add(entry.getKey()); | |
| 4221 } | |
| 4222 } | 4194 } |
| 4223 } | 4195 } |
| 4224 } | 4196 } |
| 4225 return new List.from(sources); | 4197 return new List.from(sources); |
| 4226 } | 4198 } |
| 4227 | 4199 |
| 4228 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { | 4200 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { |
| 4229 if (library == null) { | 4201 if (library == null) { |
| 4230 return null; | 4202 return null; |
| 4231 } | 4203 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4253 | 4225 |
| 4254 /** | 4226 /** |
| 4255 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This | 4227 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This |
| 4256 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi
sTask]. | 4228 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi
sTask]. |
| 4257 * This method is intended to be used for testing purposes only. | 4229 * This method is intended to be used for testing purposes only. |
| 4258 * | 4230 * |
| 4259 * @return a list of the sources that would be processed by [performAnalysisTa
sk] | 4231 * @return a list of the sources that would be processed by [performAnalysisTa
sk] |
| 4260 */ | 4232 */ |
| 4261 List<Source> get sourcesNeedingProcessing { | 4233 List<Source> get sourcesNeedingProcessing { |
| 4262 Set<Source> sources = new Set<Source>(); | 4234 Set<Source> sources = new Set<Source>(); |
| 4263 { | 4235 bool hintsEnabled = _options.hint; |
| 4264 bool hintsEnabled = _options.hint; | 4236 // |
| 4265 // | 4237 // Look for priority sources that need to be analyzed. |
| 4266 // Look for priority sources that need to be analyzed. | 4238 // |
| 4267 // | 4239 for (Source source in _priorityOrder) { |
| 4268 for (Source source in _priorityOrder) { | 4240 getSourcesNeedingProcessing2(source, _cache.get(source), true, hintsEnable
d, sources); |
| 4269 getSourcesNeedingProcessing2(source, _cache.get(source), true, hintsEnab
led, sources); | 4241 } |
| 4270 } | 4242 // |
| 4271 // | 4243 // Look for non-priority sources that need to be analyzed. |
| 4272 // Look for non-priority sources that need to be analyzed. | 4244 // |
| 4273 // | 4245 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4274 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4246 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hint
sEnabled, sources); |
| 4275 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hi
ntsEnabled, sources); | |
| 4276 } | |
| 4277 } | 4247 } |
| 4278 return new List<Source>.from(sources); | 4248 return new List<Source>.from(sources); |
| 4279 } | 4249 } |
| 4280 | 4250 |
| 4281 AnalysisContentStatistics get statistics { | 4251 AnalysisContentStatistics get statistics { |
| 4282 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl
(); | 4252 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl
(); |
| 4283 { | 4253 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 4284 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 4254 statistics.addSource(mapEntry.getKey()); |
| 4285 statistics.addSource(mapEntry.getKey()); | 4255 SourceEntry entry = mapEntry.getValue(); |
| 4286 SourceEntry entry = mapEntry.getValue(); | 4256 if (entry is DartEntry) { |
| 4287 if (entry is DartEntry) { | 4257 Source source = mapEntry.getKey(); |
| 4288 Source source = mapEntry.getKey(); | 4258 DartEntry dartEntry = entry; |
| 4289 DartEntry dartEntry = entry; | 4259 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); |
| 4290 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); | 4260 // get library independent values |
| 4291 // get library independent values | 4261 statistics.putCacheItem2(dartEntry, SourceEntry.LINE_INFO); |
| 4292 statistics.putCacheItem2(dartEntry, SourceEntry.LINE_INFO); | 4262 statistics.putCacheItem2(dartEntry, DartEntry.PARSE_ERRORS); |
| 4293 statistics.putCacheItem2(dartEntry, DartEntry.PARSE_ERRORS); | 4263 statistics.putCacheItem2(dartEntry, DartEntry.PARSED_UNIT); |
| 4294 statistics.putCacheItem2(dartEntry, DartEntry.PARSED_UNIT); | 4264 statistics.putCacheItem2(dartEntry, DartEntry.SOURCE_KIND); |
| 4295 statistics.putCacheItem2(dartEntry, DartEntry.SOURCE_KIND); | 4265 if (identical(kind, SourceKind.LIBRARY)) { |
| 4296 if (identical(kind, SourceKind.LIBRARY)) { | 4266 statistics.putCacheItem2(dartEntry, DartEntry.ELEMENT); |
| 4297 statistics.putCacheItem2(dartEntry, DartEntry.ELEMENT); | 4267 statistics.putCacheItem2(dartEntry, DartEntry.EXPORTED_LIBRARIES); |
| 4298 statistics.putCacheItem2(dartEntry, DartEntry.EXPORTED_LIBRARIES); | 4268 statistics.putCacheItem2(dartEntry, DartEntry.IMPORTED_LIBRARIES); |
| 4299 statistics.putCacheItem2(dartEntry, DartEntry.IMPORTED_LIBRARIES); | 4269 statistics.putCacheItem2(dartEntry, DartEntry.INCLUDED_PARTS); |
| 4300 statistics.putCacheItem2(dartEntry, DartEntry.INCLUDED_PARTS); | 4270 statistics.putCacheItem2(dartEntry, DartEntry.IS_CLIENT); |
| 4301 statistics.putCacheItem2(dartEntry, DartEntry.IS_CLIENT); | 4271 statistics.putCacheItem2(dartEntry, DartEntry.IS_LAUNCHABLE); |
| 4302 statistics.putCacheItem2(dartEntry, DartEntry.IS_LAUNCHABLE); | |
| 4303 } | |
| 4304 // get library-specific values | |
| 4305 List<Source> librarySources = getLibrariesContaining(source); | |
| 4306 for (Source librarySource in librarySources) { | |
| 4307 statistics.putCacheItem(dartEntry, librarySource, DartEntry.HINTS); | |
| 4308 statistics.putCacheItem(dartEntry, librarySource, DartEntry.RESOLUTI
ON_ERRORS); | |
| 4309 statistics.putCacheItem(dartEntry, librarySource, DartEntry.RESOLVED
_UNIT); | |
| 4310 statistics.putCacheItem(dartEntry, librarySource, DartEntry.VERIFICA
TION_ERRORS); | |
| 4311 } | |
| 4312 } else if (entry is HtmlEntry) { | |
| 4313 HtmlEntry htmlEntry = entry; | |
| 4314 statistics.putCacheItem2(htmlEntry, SourceEntry.LINE_INFO); | |
| 4315 statistics.putCacheItem2(htmlEntry, HtmlEntry.PARSE_ERRORS); | |
| 4316 statistics.putCacheItem2(htmlEntry, HtmlEntry.PARSED_UNIT); | |
| 4317 statistics.putCacheItem2(htmlEntry, HtmlEntry.RESOLUTION_ERRORS); | |
| 4318 statistics.putCacheItem2(htmlEntry, HtmlEntry.RESOLVED_UNIT); | |
| 4319 statistics.putCacheItem2(htmlEntry, HtmlEntry.HINTS); | |
| 4320 } | 4272 } |
| 4273 // get library-specific values |
| 4274 List<Source> librarySources = getLibrariesContaining(source); |
| 4275 for (Source librarySource in librarySources) { |
| 4276 statistics.putCacheItem(dartEntry, librarySource, DartEntry.HINTS); |
| 4277 statistics.putCacheItem(dartEntry, librarySource, DartEntry.RESOLUTION
_ERRORS); |
| 4278 statistics.putCacheItem(dartEntry, librarySource, DartEntry.RESOLVED_U
NIT); |
| 4279 statistics.putCacheItem(dartEntry, librarySource, DartEntry.VERIFICATI
ON_ERRORS); |
| 4280 } |
| 4281 } else if (entry is HtmlEntry) { |
| 4282 HtmlEntry htmlEntry = entry; |
| 4283 statistics.putCacheItem2(htmlEntry, SourceEntry.LINE_INFO); |
| 4284 statistics.putCacheItem2(htmlEntry, HtmlEntry.PARSE_ERRORS); |
| 4285 statistics.putCacheItem2(htmlEntry, HtmlEntry.PARSED_UNIT); |
| 4286 statistics.putCacheItem2(htmlEntry, HtmlEntry.RESOLUTION_ERRORS); |
| 4287 statistics.putCacheItem2(htmlEntry, HtmlEntry.RESOLVED_UNIT); |
| 4288 statistics.putCacheItem2(htmlEntry, HtmlEntry.HINTS); |
| 4321 } | 4289 } |
| 4322 } | 4290 } |
| 4323 return statistics; | 4291 return statistics; |
| 4324 } | 4292 } |
| 4325 | 4293 |
| 4326 TypeProvider get typeProvider { | 4294 TypeProvider get typeProvider { |
| 4327 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 4295 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 4328 return new TypeProviderImpl(computeLibraryElement(coreSource)); | 4296 return new TypeProviderImpl(computeLibraryElement(coreSource)); |
| 4329 } | 4297 } |
| 4330 | 4298 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4378 return false; | 4346 return false; |
| 4379 } | 4347 } |
| 4380 | 4348 |
| 4381 void mergeContext(AnalysisContext context) { | 4349 void mergeContext(AnalysisContext context) { |
| 4382 if (context is InstrumentedAnalysisContextImpl) { | 4350 if (context is InstrumentedAnalysisContextImpl) { |
| 4383 context = (context as InstrumentedAnalysisContextImpl).basis; | 4351 context = (context as InstrumentedAnalysisContextImpl).basis; |
| 4384 } | 4352 } |
| 4385 if (context is! AnalysisContextImpl) { | 4353 if (context is! AnalysisContextImpl) { |
| 4386 return; | 4354 return; |
| 4387 } | 4355 } |
| 4388 { | 4356 // TODO(brianwilkerson) This does not lock against the other context's cache
Lock. |
| 4389 // TODO(brianwilkerson) This does not lock against the other context's cac
heLock. | 4357 for (MapEntry<Source, SourceEntry> entry in (context as AnalysisContextImpl)
._cache.entrySet()) { |
| 4390 for (MapEntry<Source, SourceEntry> entry in (context as AnalysisContextImp
l)._cache.entrySet()) { | 4358 Source newSource = entry.getKey(); |
| 4391 Source newSource = entry.getKey(); | 4359 SourceEntry existingEntry = getReadableSourceEntry(newSource); |
| 4392 SourceEntry existingEntry = getReadableSourceEntry(newSource); | 4360 if (existingEntry == null) { |
| 4393 if (existingEntry == null) { | 4361 // TODO(brianwilkerson) Decide whether we really need to copy the info. |
| 4394 // TODO(brianwilkerson) Decide whether we really need to copy the info
. | 4362 _cache.put(newSource, entry.getValue().writableCopy); |
| 4395 _cache.put(newSource, entry.getValue().writableCopy); | 4363 } else { |
| 4396 } else { | |
| 4397 } | |
| 4398 } | 4364 } |
| 4399 } | 4365 } |
| 4400 } | 4366 } |
| 4401 | 4367 |
| 4402 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc
e, DartEntry.PARSED_UNIT, null); | 4368 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc
e, DartEntry.PARSED_UNIT, null); |
| 4403 | 4369 |
| 4404 ht.HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry
.PARSED_UNIT, null); | 4370 ht.HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry
.PARSED_UNIT, null); |
| 4405 | 4371 |
| 4406 AnalysisResult performAnalysisTask() { | 4372 AnalysisResult performAnalysisTask() { |
| 4407 int getStart = JavaSystem.currentTimeMillis(); | 4373 int getStart = JavaSystem.currentTimeMillis(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4427 } on AnalysisException catch (exception) { | 4393 } on AnalysisException catch (exception) { |
| 4428 if (exception.cause is! JavaIOException) { | 4394 if (exception.cause is! JavaIOException) { |
| 4429 AnalysisEngine.instance.logger.logError2("Internal error while performin
g the task: ${task}", exception); | 4395 AnalysisEngine.instance.logger.logError2("Internal error while performin
g the task: ${task}", exception); |
| 4430 } | 4396 } |
| 4431 } | 4397 } |
| 4432 int performEnd = JavaSystem.currentTimeMillis(); | 4398 int performEnd = JavaSystem.currentTimeMillis(); |
| 4433 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r
untimeType.toString(), performEnd - performStart); | 4399 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r
untimeType.toString(), performEnd - performStart); |
| 4434 } | 4400 } |
| 4435 | 4401 |
| 4436 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 4402 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 4437 { | 4403 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 4438 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | 4404 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { |
| 4439 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ | 4405 Source librarySource = entry.getKey(); |
| 4440 Source librarySource = entry.getKey(); | 4406 LibraryElement library = entry.getValue(); |
| 4441 LibraryElement library = entry.getValue(); | 4407 // |
| 4442 // | 4408 // Cache the element in the library's info. |
| 4443 // Cache the element in the library's info. | 4409 // |
| 4444 // | 4410 DartEntry dartEntry = getReadableDartEntry(librarySource); |
| 4445 DartEntry dartEntry = getReadableDartEntry(librarySource); | 4411 if (dartEntry != null) { |
| 4446 if (dartEntry != null) { | 4412 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4447 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4413 recordElementData(dartEntry, dartCopy, library, library.source, htmlSour
ce); |
| 4448 recordElementData(dartEntry, dartCopy, library, library.source, htmlSo
urce); | 4414 _cache.put(librarySource, dartCopy); |
| 4449 _cache.put(librarySource, dartCopy); | |
| 4450 } | |
| 4451 } | 4415 } |
| 4452 } | 4416 } |
| 4453 } | 4417 } |
| 4454 | 4418 |
| 4455 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 4419 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 4456 if (library == null) { | 4420 if (library == null) { |
| 4457 return null; | 4421 return null; |
| 4458 } | 4422 } |
| 4459 return resolveCompilationUnit2(unitSource, library.source); | 4423 return resolveCompilationUnit2(unitSource, library.source); |
| 4460 } | 4424 } |
| 4461 | 4425 |
| 4462 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) => getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT,
null); | 4426 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) => getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT,
null); |
| 4463 | 4427 |
| 4464 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 4428 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 4465 computeHtmlElement(htmlSource); | 4429 computeHtmlElement(htmlSource); |
| 4466 return parseHtmlUnit(htmlSource); | 4430 return parseHtmlUnit(htmlSource); |
| 4467 } | 4431 } |
| 4468 | 4432 |
| 4469 void set analysisOptions(AnalysisOptions options) { | 4433 void set analysisOptions(AnalysisOptions options) { |
| 4470 { | 4434 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; |
| 4471 bool needsRecompute = this._options.analyzeFunctionBodies != options.analy
zeFunctionBodies || this._options.dart2jsHint != options.dart2jsHint || (this._o
ptions.hint && !options.hint) || this._options.preserveComments != options.prese
rveComments; | 4435 int cacheSize = options.cacheSize; |
| 4472 int cacheSize = options.cacheSize; | 4436 if (this._options.cacheSize != cacheSize) { |
| 4473 if (this._options.cacheSize != cacheSize) { | 4437 this._options.cacheSize = cacheSize; |
| 4474 this._options.cacheSize = cacheSize; | 4438 _cache.maxCacheSize = cacheSize; |
| 4475 _cache.maxCacheSize = cacheSize; | 4439 // |
| 4476 // | 4440 // Cap the size of the priority list to being less than the cache size. Fa
ilure to do so can |
| 4477 // Cap the size of the priority list to being less than the cache size.
Failure to do so can | 4441 // result in an infinite loop in performAnalysisTask() because re-caching
one AST structure |
| 4478 // result in an infinite loop in performAnalysisTask() because re-cachin
g one AST structure | 4442 // can cause another priority source's AST structure to be flushed. |
| 4479 // can cause another priority source's AST structure to be flushed. | 4443 // |
| 4480 // | 4444 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
| 4481 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 4445 if (_priorityOrder.length > maxPriorityOrderSize) { |
| 4482 if (_priorityOrder.length > maxPriorityOrderSize) { | 4446 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); |
| 4483 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize)
; | 4447 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriority
OrderSize); |
| 4484 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriori
tyOrderSize); | 4448 _priorityOrder = newPriorityOrder; |
| 4485 _priorityOrder = newPriorityOrder; | |
| 4486 } | |
| 4487 } | 4449 } |
| 4488 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; | 4450 } |
| 4489 this._options.dart2jsHint = options.dart2jsHint; | 4451 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; |
| 4490 this._options.hint = options.hint; | 4452 this._options.dart2jsHint = options.dart2jsHint; |
| 4491 this._options.incremental = options.incremental; | 4453 this._options.hint = options.hint; |
| 4492 this._options.preserveComments = options.preserveComments; | 4454 this._options.incremental = options.incremental; |
| 4493 if (needsRecompute) { | 4455 this._options.preserveComments = options.preserveComments; |
| 4494 invalidateAllResolutionInformation(); | 4456 if (needsRecompute) { |
| 4495 } | 4457 invalidateAllResolutionInformation(); |
| 4496 } | 4458 } |
| 4497 } | 4459 } |
| 4498 | 4460 |
| 4499 void set analysisPriorityOrder(List<Source> sources) { | 4461 void set analysisPriorityOrder(List<Source> sources) { |
| 4500 { | 4462 if (sources == null || sources.isEmpty) { |
| 4501 if (sources == null || sources.isEmpty) { | 4463 _priorityOrder = Source.EMPTY_ARRAY; |
| 4464 } else { |
| 4465 while (sources.remove(null)) { |
| 4466 } |
| 4467 if (sources.isEmpty) { |
| 4502 _priorityOrder = Source.EMPTY_ARRAY; | 4468 _priorityOrder = Source.EMPTY_ARRAY; |
| 4503 } else { | 4469 } |
| 4504 while (sources.remove(null)) { | 4470 // |
| 4505 } | 4471 // Cap the size of the priority list to being less than the cache size. Fa
ilure to do so can |
| 4506 if (sources.isEmpty) { | 4472 // result in an infinite loop in performAnalysisTask() because re-caching
one AST structure |
| 4507 _priorityOrder = Source.EMPTY_ARRAY; | 4473 // can cause another priority source's AST structure to be flushed. |
| 4508 } | 4474 // |
| 4509 // | 4475 int count = Math.min(sources.length, _options.cacheSize - _PRIORITY_ORDER_
SIZE_DELTA); |
| 4510 // Cap the size of the priority list to being less than the cache size.
Failure to do so can | 4476 _priorityOrder = new List<Source>(count); |
| 4511 // result in an infinite loop in performAnalysisTask() because re-cachin
g one AST structure | 4477 for (int i = 0; i < count; i++) { |
| 4512 // can cause another priority source's AST structure to be flushed. | 4478 _priorityOrder[i] = sources[i]; |
| 4513 // | |
| 4514 int count = Math.min(sources.length, _options.cacheSize - _PRIORITY_ORDE
R_SIZE_DELTA); | |
| 4515 _priorityOrder = new List<Source>(count); | |
| 4516 for (int i = 0; i < count; i++) { | |
| 4517 _priorityOrder[i] = sources[i]; | |
| 4518 } | |
| 4519 } | 4479 } |
| 4520 } | 4480 } |
| 4521 } | 4481 } |
| 4522 | 4482 |
| 4523 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { | 4483 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { |
| 4524 { | 4484 _recentTasks.clear(); |
| 4525 _recentTasks.clear(); | 4485 String originalContents = _contentCache.setContents(source, contents); |
| 4526 String originalContents = _contentCache.setContents(source, contents); | 4486 if (contents != null) { |
| 4527 if (contents != null) { | 4487 if (contents != originalContents) { |
| 4528 if (contents != originalContents) { | 4488 if (_options.incremental) { |
| 4529 if (_options.incremental) { | 4489 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment
alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt
h, getReadableSourceEntry(source)); |
| 4530 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increme
ntalAnalysisCache, source, originalContents, contents, offset, oldLength, newLen
gth, getReadableSourceEntry(source)); | |
| 4531 } | |
| 4532 sourceChanged(source); | |
| 4533 SourceEntry sourceEntry = _cache.get(source); | |
| 4534 if (sourceEntry != null) { | |
| 4535 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | |
| 4536 sourceCopy.modificationTime = _contentCache.getModificationStamp(sou
rce); | |
| 4537 sourceCopy.setValue(SourceEntry.CONTENT, contents); | |
| 4538 _cache.put(source, sourceCopy); | |
| 4539 } | |
| 4540 } | 4490 } |
| 4541 } else if (originalContents != null) { | |
| 4542 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); | |
| 4543 sourceChanged(source); | 4491 sourceChanged(source); |
| 4492 SourceEntry sourceEntry = _cache.get(source); |
| 4493 if (sourceEntry != null) { |
| 4494 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 4495 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc
e); |
| 4496 sourceCopy.setValue(SourceEntry.CONTENT, contents); |
| 4497 _cache.put(source, sourceCopy); |
| 4498 } |
| 4544 } | 4499 } |
| 4500 } else if (originalContents != null) { |
| 4501 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); |
| 4502 sourceChanged(source); |
| 4545 } | 4503 } |
| 4546 } | 4504 } |
| 4547 | 4505 |
| 4548 void setContents(Source source, String contents) { | 4506 void setContents(Source source, String contents) { |
| 4549 { | 4507 _recentTasks.clear(); |
| 4550 _recentTasks.clear(); | 4508 String originalContents = _contentCache.setContents(source, contents); |
| 4551 String originalContents = _contentCache.setContents(source, contents); | 4509 if (contents != null) { |
| 4552 if (contents != null) { | 4510 if (contents != originalContents) { |
| 4553 if (contents != originalContents) { | |
| 4554 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementa
lAnalysisCache, source); | |
| 4555 sourceChanged(source); | |
| 4556 SourceEntry sourceEntry = _cache.get(source); | |
| 4557 if (sourceEntry != null) { | |
| 4558 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | |
| 4559 sourceCopy.modificationTime = _contentCache.getModificationStamp(sou
rce); | |
| 4560 sourceCopy.setValue(SourceEntry.CONTENT, contents); | |
| 4561 _cache.put(source, sourceCopy); | |
| 4562 } | |
| 4563 } | |
| 4564 } else if (originalContents != null) { | |
| 4565 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); | 4511 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); |
| 4566 sourceChanged(source); | 4512 sourceChanged(source); |
| 4513 SourceEntry sourceEntry = _cache.get(source); |
| 4514 if (sourceEntry != null) { |
| 4515 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 4516 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc
e); |
| 4517 sourceCopy.setValue(SourceEntry.CONTENT, contents); |
| 4518 _cache.put(source, sourceCopy); |
| 4519 } |
| 4567 } | 4520 } |
| 4521 } else if (originalContents != null) { |
| 4522 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); |
| 4523 sourceChanged(source); |
| 4568 } | 4524 } |
| 4569 } | 4525 } |
| 4570 | 4526 |
| 4571 void set sourceFactory(SourceFactory factory) { | 4527 void set sourceFactory(SourceFactory factory) { |
| 4572 { | 4528 if (identical(_sourceFactory, factory)) { |
| 4573 if (identical(_sourceFactory, factory)) { | 4529 return; |
| 4574 return; | 4530 } else if (factory.context != null) { |
| 4575 } else if (factory.context != null) { | 4531 throw new IllegalStateException("Source factories cannot be shared between
contexts"); |
| 4576 throw new IllegalStateException("Source factories cannot be shared betwe
en contexts"); | |
| 4577 } | |
| 4578 if (_sourceFactory != null) { | |
| 4579 _sourceFactory.context = null; | |
| 4580 } | |
| 4581 factory.context = this; | |
| 4582 _sourceFactory = factory; | |
| 4583 invalidateAllResolutionInformation(); | |
| 4584 } | 4532 } |
| 4533 if (_sourceFactory != null) { |
| 4534 _sourceFactory.context = null; |
| 4535 } |
| 4536 factory.context = this; |
| 4537 _sourceFactory = factory; |
| 4538 invalidateAllResolutionInformation(); |
| 4585 } | 4539 } |
| 4586 | 4540 |
| 4587 /** | 4541 /** |
| 4588 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were | 4542 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were |
| 4589 * computed from data that is now out-of-date, then the results will not be re
corded. | 4543 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 4590 * | 4544 * |
| 4591 * @param task the task that was performed | 4545 * @param task the task that was performed |
| 4592 * @return an entry containing the computed results | 4546 * @return an entry containing the computed results |
| 4593 * @throws AnalysisException if the results could not be recorded | 4547 * @throws AnalysisException if the results could not be recorded |
| 4594 */ | 4548 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4614 DartEntryImpl dartCopy = unitEntry.writableCopy; | 4568 DartEntryImpl dartCopy = unitEntry.writableCopy; |
| 4615 dartCopy.recordResolutionError(); | 4569 dartCopy.recordResolutionError(); |
| 4616 dartCopy.exception = thrownException; | 4570 dartCopy.exception = thrownException; |
| 4617 _cache.put(unitSource, dartCopy); | 4571 _cache.put(unitSource, dartCopy); |
| 4618 _cache.remove(unitSource); | 4572 _cache.remove(unitSource); |
| 4619 if (thrownException != null) { | 4573 if (thrownException != null) { |
| 4620 throw thrownException; | 4574 throw thrownException; |
| 4621 } | 4575 } |
| 4622 return dartCopy; | 4576 return dartCopy; |
| 4623 } | 4577 } |
| 4624 { | 4578 if (allModificationTimesMatch(resolvedLibraries)) { |
| 4625 if (allModificationTimesMatch(resolvedLibraries)) { | 4579 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
| 4626 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 4580 RecordingErrorListener errorListener = resolver.errorListener; |
| 4627 RecordingErrorListener errorListener = resolver.errorListener; | 4581 for (Library library in resolvedLibraries) { |
| 4628 for (Library library in resolvedLibraries) { | 4582 Source librarySource = library.librarySource; |
| 4629 Source librarySource = library.librarySource; | 4583 for (Source source in library.compilationUnitSources) { |
| 4630 for (Source source in library.compilationUnitSources) { | 4584 CompilationUnit unit = library.getAST(source); |
| 4631 CompilationUnit unit = library.getAST(source); | 4585 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 4632 List<AnalysisError> errors = errorListener.getErrors2(source); | 4586 LineInfo lineInfo = getLineInfo(source); |
| 4633 LineInfo lineInfo = getLineInfo(source); | 4587 DartEntry dartEntry = _cache.get(source) as DartEntry; |
| 4634 DartEntry dartEntry = _cache.get(source) as DartEntry; | 4588 int sourceTime = getModificationStamp(source); |
| 4635 int sourceTime = getModificationStamp(source); | 4589 if (dartEntry.modificationTime != sourceTime) { |
| 4636 if (dartEntry.modificationTime != sourceTime) { | 4590 // The source has changed without the context being notified. Simu
late notification. |
| 4637 // The source has changed without the context being notified. Si
mulate notification. | 4591 sourceChanged(source); |
| 4638 sourceChanged(source); | 4592 dartEntry = getReadableDartEntry(source); |
| 4639 dartEntry = getReadableDartEntry(source); | 4593 if (dartEntry == null) { |
| 4640 if (dartEntry == null) { | 4594 throw new AnalysisException.con1("A Dart file became a non-Dart
file: ${source.fullName}"); |
| 4641 throw new AnalysisException.con1("A Dart file became a non-Dar
t file: ${source.fullName}"); | |
| 4642 } | |
| 4643 } | 4595 } |
| 4596 } |
| 4597 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4598 if (thrownException == null) { |
| 4599 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 4600 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 4601 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit); |
| 4602 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, err
ors); |
| 4603 if (source == librarySource) { |
| 4604 recordElementData(dartEntry, dartCopy, library.libraryElement, l
ibrarySource, htmlSource); |
| 4605 } |
| 4606 _cache.storedAst(source); |
| 4607 } else { |
| 4608 dartCopy.recordResolutionError(); |
| 4609 _cache.remove(source); |
| 4610 } |
| 4611 dartCopy.exception = thrownException; |
| 4612 _cache.put(source, dartCopy); |
| 4613 if (source != librarySource) { |
| 4614 _workManager.add(source, SourcePriority.PRIORITY_PART); |
| 4615 } |
| 4616 if (source == unitSource) { |
| 4617 unitEntry = dartCopy; |
| 4618 } |
| 4619 ChangeNoticeImpl notice = getNotice(source); |
| 4620 notice.compilationUnit = unit; |
| 4621 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4622 } |
| 4623 } |
| 4624 } else { |
| 4625 PrintStringWriter writer = new PrintStringWriter(); |
| 4626 writer.println("Library resolution results discarded for"); |
| 4627 for (Library library in resolvedLibraries) { |
| 4628 for (Source source in library.compilationUnitSources) { |
| 4629 DartEntry dartEntry = getReadableDartEntry(source); |
| 4630 if (dartEntry != null) { |
| 4631 int resultTime = library.getModificationTime(source); |
| 4632 writer.println(" ${debuggingString(source)}; sourceTime = ${getMo
dificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.mo
dificationTime}"); |
| 4644 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4633 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4645 if (thrownException == null) { | 4634 if (thrownException == null || resultTime >= 0) { |
| 4646 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 4635 // |
| 4647 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 4636 // The analysis was performed on out-of-date sources. Mark the c
ache so that the |
| 4648 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit)
; | 4637 // sources will be re-analyzed using the up-to-date sources. |
| 4649 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, e
rrors); | 4638 // |
| 4650 if (source == librarySource) { | 4639 dartCopy.recordResolutionNotInProcess(); |
| 4651 recordElementData(dartEntry, dartCopy, library.libraryElement,
librarySource, htmlSource); | |
| 4652 } | |
| 4653 _cache.storedAst(source); | |
| 4654 } else { | 4640 } else { |
| 4641 // |
| 4642 // We could not determine whether the sources were up-to-date or
out-of-date. Mark |
| 4643 // the cache so that we won't attempt to re-analyze the sources
until there's a |
| 4644 // good chance that we'll be able to do so without error. |
| 4645 // |
| 4655 dartCopy.recordResolutionError(); | 4646 dartCopy.recordResolutionError(); |
| 4656 _cache.remove(source); | 4647 _cache.remove(source); |
| 4657 } | 4648 } |
| 4658 dartCopy.exception = thrownException; | 4649 dartCopy.exception = thrownException; |
| 4659 _cache.put(source, dartCopy); | 4650 _cache.put(source, dartCopy); |
| 4660 if (source != librarySource) { | |
| 4661 _workManager.add(source, SourcePriority.PRIORITY_PART); | |
| 4662 } | |
| 4663 if (source == unitSource) { | 4651 if (source == unitSource) { |
| 4664 unitEntry = dartCopy; | 4652 unitEntry = dartCopy; |
| 4665 } | 4653 } |
| 4666 ChangeNoticeImpl notice = getNotice(source); | 4654 } else { |
| 4667 notice.compilationUnit = unit; | 4655 writer.println(" ${debuggingString(source)}; sourceTime = ${getMo
dificationStamp(source)}, no entry"); |
| 4668 notice.setErrors(dartCopy.allErrors, lineInfo); | |
| 4669 } | 4656 } |
| 4670 } | 4657 } |
| 4671 } else { | |
| 4672 PrintStringWriter writer = new PrintStringWriter(); | |
| 4673 writer.println("Library resolution results discarded for"); | |
| 4674 for (Library library in resolvedLibraries) { | |
| 4675 for (Source source in library.compilationUnitSources) { | |
| 4676 DartEntry dartEntry = getReadableDartEntry(source); | |
| 4677 if (dartEntry != null) { | |
| 4678 int resultTime = library.getModificationTime(source); | |
| 4679 writer.println(" ${debuggingString(source)}; sourceTime = ${get
ModificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}"); | |
| 4680 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 4681 if (thrownException == null || resultTime >= 0) { | |
| 4682 // | |
| 4683 // The analysis was performed on out-of-date sources. Mark the
cache so that the | |
| 4684 // sources will be re-analyzed using the up-to-date sources. | |
| 4685 // | |
| 4686 dartCopy.recordResolutionNotInProcess(); | |
| 4687 } else { | |
| 4688 // | |
| 4689 // We could not determine whether the sources were up-to-date
or out-of-date. Mark | |
| 4690 // the cache so that we won't attempt to re-analyze the source
s until there's a | |
| 4691 // good chance that we'll be able to do so without error. | |
| 4692 // | |
| 4693 dartCopy.recordResolutionError(); | |
| 4694 _cache.remove(source); | |
| 4695 } | |
| 4696 dartCopy.exception = thrownException; | |
| 4697 _cache.put(source, dartCopy); | |
| 4698 if (source == unitSource) { | |
| 4699 unitEntry = dartCopy; | |
| 4700 } | |
| 4701 } else { | |
| 4702 writer.println(" ${debuggingString(source)}; sourceTime = ${get
ModificationStamp(source)}, no entry"); | |
| 4703 } | |
| 4704 } | |
| 4705 } | |
| 4706 logInformation(writer.toString()); | |
| 4707 } | 4658 } |
| 4659 logInformation(writer.toString()); |
| 4708 } | 4660 } |
| 4709 } | 4661 } |
| 4710 if (thrownException != null) { | 4662 if (thrownException != null) { |
| 4711 throw thrownException; | 4663 throw thrownException; |
| 4712 } | 4664 } |
| 4713 if (unitEntry == null) { | 4665 if (unitEntry == null) { |
| 4714 unitEntry = getReadableDartEntry(unitSource); | 4666 unitEntry = getReadableDartEntry(unitSource); |
| 4715 if (unitEntry == null) { | 4667 if (unitEntry == null) { |
| 4716 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); | 4668 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); |
| 4717 } | 4669 } |
| 4718 } | 4670 } |
| 4719 return unitEntry; | 4671 return unitEntry; |
| 4720 } | 4672 } |
| 4721 | 4673 |
| 4722 /** | 4674 /** |
| 4723 * Record that we have accessed the AST structure associated with the given so
urce. At the moment, | 4675 * Record that we have accessed the AST structure associated with the given so
urce. At the moment, |
| 4724 * there is no differentiation between the parsed and resolved forms of the AS
T. | 4676 * there is no differentiation between the parsed and resolved forms of the AS
T. |
| 4725 * | 4677 * |
| 4726 * @param source the source whose AST structure was accessed | 4678 * @param source the source whose AST structure was accessed |
| 4727 */ | 4679 */ |
| 4728 void accessedAst(Source source) { | 4680 void accessedAst(Source source) { |
| 4729 { | 4681 _cache.accessedAst(source); |
| 4730 _cache.accessedAst(source); | |
| 4731 } | |
| 4732 } | 4682 } |
| 4733 | 4683 |
| 4734 /** | 4684 /** |
| 4735 * Add all of the sources contained in the given source container to the given
list of sources. | 4685 * Add all of the sources contained in the given source container to the given
list of sources. |
| 4736 * | 4686 * |
| 4737 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 4687 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 4738 * | 4688 * |
| 4739 * @param sources the list to which sources are to be added | 4689 * @param sources the list to which sources are to be added |
| 4740 * @param container the source container containing the sources to be added to
the list | 4690 * @param container the source container containing the sources to be added to
the list |
| 4741 */ | 4691 */ |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5037 } | 4987 } |
| 5038 return htmlEntry; | 4988 return htmlEntry; |
| 5039 } | 4989 } |
| 5040 | 4990 |
| 5041 /** | 4991 /** |
| 5042 * Given the encoded form of a source, use the source factory to reconstitute
the original source. | 4992 * Given the encoded form of a source, use the source factory to reconstitute
the original source. |
| 5043 * | 4993 * |
| 5044 * @param encoding the encoded form of a source | 4994 * @param encoding the encoded form of a source |
| 5045 * @return the source represented by the encoding | 4995 * @return the source represented by the encoding |
| 5046 */ | 4996 */ |
| 5047 Source computeSourceFromEncoding(String encoding) { | 4997 Source computeSourceFromEncoding(String encoding) => _sourceFactory.fromEncodi
ng(encoding); |
| 5048 { | |
| 5049 return _sourceFactory.fromEncoding(encoding); | |
| 5050 } | |
| 5051 } | |
| 5052 | 4998 |
| 5053 /** | 4999 /** |
| 5054 * Return `true` if the given array of sources contains the given source. | 5000 * Return `true` if the given array of sources contains the given source. |
| 5055 * | 5001 * |
| 5056 * @param sources the sources being searched | 5002 * @param sources the sources being searched |
| 5057 * @param targetSource the source being searched for | 5003 * @param targetSource the source being searched for |
| 5058 * @return `true` if the given source is in the array | 5004 * @return `true` if the given source is in the array |
| 5059 */ | 5005 */ |
| 5060 bool contains(List<Source> sources, Source targetSource) { | 5006 bool contains(List<Source> sources, Source targetSource) { |
| 5061 for (Source source in sources) { | 5007 for (Source source in sources) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5115 | 5061 |
| 5116 /** | 5062 /** |
| 5117 * Return an array containing all of the change notices that are waiting to be
returned. If there | 5063 * Return an array containing all of the change notices that are waiting to be
returned. If there |
| 5118 * are no notices, then return either `null` or an empty array, depending on t
he value of | 5064 * are no notices, then return either `null` or an empty array, depending on t
he value of |
| 5119 * the argument. | 5065 * the argument. |
| 5120 * | 5066 * |
| 5121 * @param nullIfEmpty `true` if `null` should be returned when there are no no
tices | 5067 * @param nullIfEmpty `true` if `null` should be returned when there are no no
tices |
| 5122 * @return the change notices that are waiting to be returned | 5068 * @return the change notices that are waiting to be returned |
| 5123 */ | 5069 */ |
| 5124 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) { | 5070 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) { |
| 5125 { | 5071 if (_pendingNotices.isEmpty) { |
| 5126 if (_pendingNotices.isEmpty) { | 5072 if (nullIfEmpty) { |
| 5127 if (nullIfEmpty) { | 5073 return null; |
| 5128 return null; | |
| 5129 } | |
| 5130 return ChangeNoticeImpl.EMPTY_ARRAY; | |
| 5131 } | 5074 } |
| 5132 List<ChangeNotice> notices = new List.from(_pendingNotices.values); | 5075 return ChangeNoticeImpl.EMPTY_ARRAY; |
| 5133 _pendingNotices.clear(); | |
| 5134 return notices; | |
| 5135 } | 5076 } |
| 5077 List<ChangeNotice> notices = new List.from(_pendingNotices.values); |
| 5078 _pendingNotices.clear(); |
| 5079 return notices; |
| 5136 } | 5080 } |
| 5137 | 5081 |
| 5138 /** | 5082 /** |
| 5139 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5083 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5140 * associated with that source. This method assumes that the data can be produ
ced by resolving the | 5084 * associated with that source. This method assumes that the data can be produ
ced by resolving the |
| 5141 * directives in the source if they are not already cached. | 5085 * directives in the source if they are not already cached. |
| 5142 * | 5086 * |
| 5143 * @param source the source representing the Dart file | 5087 * @param source the source representing the Dart file |
| 5144 * @param dartEntry the cache entry associated with the Dart file | 5088 * @param dartEntry the cache entry associated with the Dart file |
| 5145 * @param descriptor the descriptor representing the data to be returned | 5089 * @param descriptor the descriptor representing the data to be returned |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5420 return htmlEntry.getValue(descriptor); | 5364 return htmlEntry.getValue(descriptor); |
| 5421 } | 5365 } |
| 5422 | 5366 |
| 5423 /** | 5367 /** |
| 5424 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, | 5368 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, |
| 5425 * or `null` if there is no more work to be done. | 5369 * or `null` if there is no more work to be done. |
| 5426 * | 5370 * |
| 5427 * @return the next task that needs to be performed | 5371 * @return the next task that needs to be performed |
| 5428 */ | 5372 */ |
| 5429 AnalysisTask get nextAnalysisTask { | 5373 AnalysisTask get nextAnalysisTask { |
| 5430 { | 5374 bool hintsEnabled = _options.hint; |
| 5431 bool hintsEnabled = _options.hint; | 5375 bool sdkErrorsEnabled = _options.generateSdkErrors; |
| 5432 bool sdkErrorsEnabled = _options.generateSdkErrors; | 5376 bool hasBlockedTask = false; |
| 5433 bool hasBlockedTask = false; | 5377 // |
| 5434 // | 5378 // Look for incremental analysis |
| 5435 // Look for incremental analysis | 5379 // |
| 5436 // | 5380 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork()
) { |
| 5437 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork
()) { | 5381 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalysis
Cache); |
| 5438 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys
isCache); | 5382 _incrementalAnalysisCache = null; |
| 5439 _incrementalAnalysisCache = null; | 5383 return task; |
| 5384 } |
| 5385 // |
| 5386 // Look for a priority source that needs to be analyzed. |
| 5387 // |
| 5388 for (Source source in _priorityOrder) { |
| 5389 AnalysisContextImpl_TaskData taskData = getNextNondependentAnalysisTask(so
urce, hintsEnabled, sdkErrorsEnabled); |
| 5390 AnalysisTask task = taskData.task; |
| 5391 if (task != null) { |
| 5440 return task; | 5392 return task; |
| 5393 } else if (taskData.isBlocked) { |
| 5394 hasBlockedTask = true; |
| 5441 } | 5395 } |
| 5442 // | 5396 } |
| 5443 // Look for a priority source that needs to be analyzed. | 5397 // |
| 5444 // | 5398 // Look for a non-priority source that needs to be analyzed. |
| 5445 for (Source source in _priorityOrder) { | 5399 // |
| 5446 AnalysisContextImpl_TaskData taskData = getNextNondependentAnalysisTask(
source, hintsEnabled, sdkErrorsEnabled); | 5400 Source source = _workManager.nextSource; |
| 5447 AnalysisTask task = taskData.task; | 5401 while (source != null) { |
| 5448 if (task != null) { | 5402 AnalysisContextImpl_TaskData taskData = getNextNondependentAnalysisTask(so
urce, hintsEnabled, sdkErrorsEnabled); |
| 5449 return task; | 5403 AnalysisTask task = taskData.task; |
| 5450 } else if (taskData.isBlocked) { | 5404 if (task != null) { |
| 5451 hasBlockedTask = true; | 5405 return task; |
| 5452 } | 5406 } else if (taskData.isBlocked) { |
| 5407 hasBlockedTask = true; |
| 5408 } else { |
| 5409 _workManager.remove(source); |
| 5453 } | 5410 } |
| 5454 // | 5411 source = _workManager.nextSource; |
| 5455 // Look for a non-priority source that needs to be analyzed. | |
| 5456 // | |
| 5457 Source source = _workManager.nextSource; | |
| 5458 while (source != null) { | |
| 5459 AnalysisContextImpl_TaskData taskData = getNextNondependentAnalysisTask(
source, hintsEnabled, sdkErrorsEnabled); | |
| 5460 AnalysisTask task = taskData.task; | |
| 5461 if (task != null) { | |
| 5462 return task; | |
| 5463 } else if (taskData.isBlocked) { | |
| 5464 hasBlockedTask = true; | |
| 5465 } else { | |
| 5466 _workManager.remove(source); | |
| 5467 } | |
| 5468 source = _workManager.nextSource; | |
| 5469 } | |
| 5470 // // | |
| 5471 // // Look for a non-priority source that needs to be analyzed and wa
s missed by the loop above. | |
| 5472 // // | |
| 5473 // for (Map.Entry<Source, SourceEntry> entry : cache.entrySet()) { | |
| 5474 // source = entry.getKey(); | |
| 5475 // TaskData taskData = getNextAnalysisTaskForSource(source, entry.g
etValue(), false, hintsEnabled); | |
| 5476 // AnalysisTask task = taskData.getTask(); | |
| 5477 // if (task != null) { | |
| 5478 // System.out.println("Failed to analyze " + source.getFullName()
); | |
| 5479 // return task; | |
| 5480 // } | |
| 5481 // } | |
| 5482 if (hasBlockedTask) { | |
| 5483 return WaitForAsyncTask.instance; | |
| 5484 } | |
| 5485 return null; | |
| 5486 } | 5412 } |
| 5413 // // |
| 5414 // // Look for a non-priority source that needs to be analyzed and was
missed by the loop above. |
| 5415 // // |
| 5416 // for (Map.Entry<Source, SourceEntry> entry : cache.entrySet()) { |
| 5417 // source = entry.getKey(); |
| 5418 // TaskData taskData = getNextAnalysisTaskForSource(source, entry.get
Value(), false, hintsEnabled); |
| 5419 // AnalysisTask task = taskData.getTask(); |
| 5420 // if (task != null) { |
| 5421 // System.out.println("Failed to analyze " + source.getFullName()); |
| 5422 // return task; |
| 5423 // } |
| 5424 // } |
| 5425 if (hasBlockedTask) { |
| 5426 return WaitForAsyncTask.instance; |
| 5427 } |
| 5428 return null; |
| 5487 } | 5429 } |
| 5488 | 5430 |
| 5489 /** | 5431 /** |
| 5490 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the | 5432 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the |
| 5491 * task that should be performed, or `null` if there is no more work to be don
e for the | 5433 * task that should be performed, or `null` if there is no more work to be don
e for the |
| 5492 * source. | 5434 * source. |
| 5493 * | 5435 * |
| 5494 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5436 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5495 * | 5437 * |
| 5496 * @param source the source to be checked | 5438 * @param source the source to be checked |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5725 } | 5667 } |
| 5726 | 5668 |
| 5727 /** | 5669 /** |
| 5728 * Return the cache entry associated with the given source, or `null` if the s
ource is not a | 5670 * Return the cache entry associated with the given source, or `null` if the s
ource is not a |
| 5729 * Dart file. | 5671 * Dart file. |
| 5730 * | 5672 * |
| 5731 * @param source the source for which a cache entry is being sought | 5673 * @param source the source for which a cache entry is being sought |
| 5732 * @return the source cache entry associated with the given source | 5674 * @return the source cache entry associated with the given source |
| 5733 */ | 5675 */ |
| 5734 DartEntry getReadableDartEntry(Source source) { | 5676 DartEntry getReadableDartEntry(Source source) { |
| 5735 { | 5677 SourceEntry sourceEntry = _cache.get(source); |
| 5736 SourceEntry sourceEntry = _cache.get(source); | 5678 if (sourceEntry == null) { |
| 5737 if (sourceEntry == null) { | 5679 sourceEntry = createSourceEntry(source); |
| 5738 sourceEntry = createSourceEntry(source); | |
| 5739 } | |
| 5740 if (sourceEntry is DartEntry) { | |
| 5741 return sourceEntry as DartEntry; | |
| 5742 } | |
| 5743 return null; | |
| 5744 } | 5680 } |
| 5681 if (sourceEntry is DartEntry) { |
| 5682 return sourceEntry as DartEntry; |
| 5683 } |
| 5684 return null; |
| 5745 } | 5685 } |
| 5746 | 5686 |
| 5747 /** | 5687 /** |
| 5748 * Return the cache entry associated with the given source, or `null` if the s
ource is not | 5688 * Return the cache entry associated with the given source, or `null` if the s
ource is not |
| 5749 * an HTML file. | 5689 * an HTML file. |
| 5750 * | 5690 * |
| 5751 * @param source the source for which a cache entry is being sought | 5691 * @param source the source for which a cache entry is being sought |
| 5752 * @return the source cache entry associated with the given source | 5692 * @return the source cache entry associated with the given source |
| 5753 */ | 5693 */ |
| 5754 HtmlEntry getReadableHtmlEntry(Source source) { | 5694 HtmlEntry getReadableHtmlEntry(Source source) { |
| 5755 { | 5695 SourceEntry sourceEntry = _cache.get(source); |
| 5756 SourceEntry sourceEntry = _cache.get(source); | 5696 if (sourceEntry == null) { |
| 5757 if (sourceEntry == null) { | 5697 sourceEntry = createSourceEntry(source); |
| 5758 sourceEntry = createSourceEntry(source); | |
| 5759 } | |
| 5760 if (sourceEntry is HtmlEntry) { | |
| 5761 return sourceEntry as HtmlEntry; | |
| 5762 } | |
| 5763 return null; | |
| 5764 } | 5698 } |
| 5699 if (sourceEntry is HtmlEntry) { |
| 5700 return sourceEntry as HtmlEntry; |
| 5701 } |
| 5702 return null; |
| 5765 } | 5703 } |
| 5766 | 5704 |
| 5767 /** | 5705 /** |
| 5768 * Return the cache entry associated with the given source, or `null` if there
is no entry | 5706 * Return the cache entry associated with the given source, or `null` if there
is no entry |
| 5769 * associated with the source. | 5707 * associated with the source. |
| 5770 * | 5708 * |
| 5771 * @param source the source for which a cache entry is being sought | 5709 * @param source the source for which a cache entry is being sought |
| 5772 * @return the source cache entry associated with the given source | 5710 * @return the source cache entry associated with the given source |
| 5773 */ | 5711 */ |
| 5774 SourceEntry getReadableSourceEntry(Source source) { | 5712 SourceEntry getReadableSourceEntry(Source source) { |
| 5775 { | 5713 SourceEntry sourceEntry = _cache.get(source); |
| 5776 SourceEntry sourceEntry = _cache.get(source); | 5714 if (sourceEntry == null) { |
| 5777 if (sourceEntry == null) { | 5715 sourceEntry = createSourceEntry(source); |
| 5778 sourceEntry = createSourceEntry(source); | |
| 5779 } | |
| 5780 return sourceEntry; | |
| 5781 } | 5716 } |
| 5717 return sourceEntry; |
| 5782 } | 5718 } |
| 5783 | 5719 |
| 5784 /** | 5720 /** |
| 5785 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 5721 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 5786 * | 5722 * |
| 5787 * @param kind the kind of sources to be returned | 5723 * @param kind the kind of sources to be returned |
| 5788 * @return all of the sources known to this context that have the given kind | 5724 * @return all of the sources known to this context that have the given kind |
| 5789 */ | 5725 */ |
| 5790 List<Source> getSources(SourceKind kind) { | 5726 List<Source> getSources(SourceKind kind) { |
| 5791 List<Source> sources = new List<Source>(); | 5727 List<Source> sources = new List<Source>(); |
| 5792 { | 5728 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 5793 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 5729 if (identical(entry.getValue().kind, kind)) { |
| 5794 if (identical(entry.getValue().kind, kind)) { | 5730 sources.add(entry.getKey()); |
| 5795 sources.add(entry.getKey()); | |
| 5796 } | |
| 5797 } | 5731 } |
| 5798 } | 5732 } |
| 5799 return new List.from(sources); | 5733 return new List.from(sources); |
| 5800 } | 5734 } |
| 5801 | 5735 |
| 5802 /** | 5736 /** |
| 5803 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add | 5737 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add |
| 5804 * the source to the set of sources that need to be processed. This method dup
licates, and must | 5738 * the source to the set of sources that need to be processed. This method dup
licates, and must |
| 5805 * therefore be kept in sync with, | 5739 * therefore be kept in sync with, |
| 5806 * [getNextAnalysisTask]. This method is intended to | 5740 * [getNextAnalysisTask]. This method is intended to |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6174 * | 6108 * |
| 6175 * @param task the task that was performed | 6109 * @param task the task that was performed |
| 6176 * @return an entry containing the computed results | 6110 * @return an entry containing the computed results |
| 6177 * @throws AnalysisException if the results could not be recorded | 6111 * @throws AnalysisException if the results could not be recorded |
| 6178 */ | 6112 */ |
| 6179 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 6113 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 6180 Source source = task.source; | 6114 Source source = task.source; |
| 6181 Source librarySource = task.libraryElement.source; | 6115 Source librarySource = task.libraryElement.source; |
| 6182 AnalysisException thrownException = task.exception; | 6116 AnalysisException thrownException = task.exception; |
| 6183 DartEntry dartEntry = null; | 6117 DartEntry dartEntry = null; |
| 6184 { | 6118 SourceEntry sourceEntry = _cache.get(source); |
| 6185 SourceEntry sourceEntry = _cache.get(source); | 6119 if (sourceEntry == null) { |
| 6186 if (sourceEntry == null) { | 6120 throw new ObsoleteSourceAnalysisException(source); |
| 6187 throw new ObsoleteSourceAnalysisException(source); | 6121 } else if (sourceEntry is! DartEntry) { |
| 6188 } else if (sourceEntry is! DartEntry) { | 6122 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6189 // This shouldn't be possible because we should never have performed the
task if the source | 6123 // didn't represent a Dart file, but check to be safe. |
| 6190 // didn't represent a Dart file, but check to be safe. | 6124 throw new AnalysisException.con1("Internal error: attempting to verify non
-Dart file as a Dart file: ${source.fullName}"); |
| 6191 throw new AnalysisException.con1("Internal error: attempting to verify n
on-Dart file as a Dart file: ${source.fullName}"); | 6125 } |
| 6126 dartEntry = sourceEntry as DartEntry; |
| 6127 int sourceTime = getModificationStamp(source); |
| 6128 int resultTime = task.modificationTime; |
| 6129 if (sourceTime == resultTime) { |
| 6130 if (dartEntry.modificationTime != sourceTime) { |
| 6131 // The source has changed without the context being notified. Simulate n
otification. |
| 6132 sourceChanged(source); |
| 6133 dartEntry = getReadableDartEntry(source); |
| 6134 if (dartEntry == null) { |
| 6135 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6136 } |
| 6192 } | 6137 } |
| 6193 dartEntry = sourceEntry as DartEntry; | 6138 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6194 int sourceTime = getModificationStamp(source); | 6139 if (thrownException == null) { |
| 6195 int resultTime = task.modificationTime; | 6140 dartCopy.setValue2(DartEntry.VERIFICATION_ERRORS, librarySource, task.er
rors); |
| 6196 if (sourceTime == resultTime) { | 6141 ChangeNoticeImpl notice = getNotice(source); |
| 6197 if (dartEntry.modificationTime != sourceTime) { | 6142 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6198 // The source has changed without the context being notified. Simulate
notification. | |
| 6199 sourceChanged(source); | |
| 6200 dartEntry = getReadableDartEntry(source); | |
| 6201 if (dartEntry == null) { | |
| 6202 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | |
| 6203 } | |
| 6204 } | |
| 6205 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 6206 if (thrownException == null) { | |
| 6207 dartCopy.setValue2(DartEntry.VERIFICATION_ERRORS, librarySource, task.
errors); | |
| 6208 ChangeNoticeImpl notice = getNotice(source); | |
| 6209 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 6210 } else { | |
| 6211 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache
State.ERROR); | |
| 6212 } | |
| 6213 dartCopy.exception = thrownException; | |
| 6214 _cache.put(source, dartCopy); | |
| 6215 dartEntry = dartCopy; | |
| 6216 } else { | 6143 } else { |
| 6217 logInformation2("Generated errors discarded for ${debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); | 6144 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, CacheSt
ate.ERROR); |
| 6218 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 6219 if (thrownException == null || resultTime >= 0) { | |
| 6220 // | |
| 6221 // The analysis was performed on out-of-date sources. Mark the cache s
o that the source | |
| 6222 // will be re-verified using the up-to-date sources. | |
| 6223 // | |
| 6224 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySo
urce, CacheState.INVALID); | |
| 6225 removeFromParts(source, dartEntry); | |
| 6226 dartCopy.invalidateAllInformation(); | |
| 6227 dartCopy.modificationTime = sourceTime; | |
| 6228 _cache.removedAst(source); | |
| 6229 _workManager.add(source, SourcePriority.UNKNOWN); | |
| 6230 } else { | |
| 6231 // | |
| 6232 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6233 // cache so that we won't attempt to re-verify the source until there'
s a good chance | |
| 6234 // that we'll be able to do so without error. | |
| 6235 // | |
| 6236 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache
State.ERROR); | |
| 6237 } | |
| 6238 dartCopy.exception = thrownException; | |
| 6239 _cache.put(source, dartCopy); | |
| 6240 dartEntry = dartCopy; | |
| 6241 } | 6145 } |
| 6146 dartCopy.exception = thrownException; |
| 6147 _cache.put(source, dartCopy); |
| 6148 dartEntry = dartCopy; |
| 6149 } else { |
| 6150 logInformation2("Generated errors discarded for ${debuggingString(source)}
; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntr
y.modificationTime}", thrownException); |
| 6151 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6152 if (thrownException == null || resultTime >= 0) { |
| 6153 // |
| 6154 // The analysis was performed on out-of-date sources. Mark the cache so
that the source |
| 6155 // will be re-verified using the up-to-date sources. |
| 6156 // |
| 6157 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour
ce, CacheState.INVALID); |
| 6158 removeFromParts(source, dartEntry); |
| 6159 dartCopy.invalidateAllInformation(); |
| 6160 dartCopy.modificationTime = sourceTime; |
| 6161 _cache.removedAst(source); |
| 6162 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6163 } else { |
| 6164 // |
| 6165 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6166 // cache so that we won't attempt to re-verify the source until there's
a good chance |
| 6167 // that we'll be able to do so without error. |
| 6168 // |
| 6169 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, CacheSt
ate.ERROR); |
| 6170 } |
| 6171 dartCopy.exception = thrownException; |
| 6172 _cache.put(source, dartCopy); |
| 6173 dartEntry = dartCopy; |
| 6242 } | 6174 } |
| 6243 if (thrownException != null) { | 6175 if (thrownException != null) { |
| 6244 throw thrownException; | 6176 throw thrownException; |
| 6245 } | 6177 } |
| 6246 return dartEntry; | 6178 return dartEntry; |
| 6247 } | 6179 } |
| 6248 | 6180 |
| 6249 /** | 6181 /** |
| 6250 * Record the results produced by performing a [GenerateDartHintsTask]. If the
results were | 6182 * Record the results produced by performing a [GenerateDartHintsTask]. If the
results were |
| 6251 * computed from data that is now out-of-date, then the results will not be re
corded. | 6183 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6252 * | 6184 * |
| 6253 * @param task the task that was performed | 6185 * @param task the task that was performed |
| 6254 * @return an entry containing the computed results | 6186 * @return an entry containing the computed results |
| 6255 * @throws AnalysisException if the results could not be recorded | 6187 * @throws AnalysisException if the results could not be recorded |
| 6256 */ | 6188 */ |
| 6257 DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task) { | 6189 DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 6258 Source librarySource = task.libraryElement.source; | 6190 Source librarySource = task.libraryElement.source; |
| 6259 AnalysisException thrownException = task.exception; | 6191 AnalysisException thrownException = task.exception; |
| 6260 DartEntry libraryEntry = null; | 6192 DartEntry libraryEntry = null; |
| 6261 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; | 6193 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; |
| 6262 if (hintMap == null) { | 6194 if (hintMap == null) { |
| 6263 { | 6195 // We don't have any information about which sources to mark as invalid ot
her than the library |
| 6264 // We don't have any information about which sources to mark as invalid
other than the library | 6196 // source. |
| 6265 // source. | 6197 SourceEntry sourceEntry = _cache.get(librarySource); |
| 6266 SourceEntry sourceEntry = _cache.get(librarySource); | 6198 if (sourceEntry == null) { |
| 6267 if (sourceEntry == null) { | 6199 throw new ObsoleteSourceAnalysisException(librarySource); |
| 6268 throw new ObsoleteSourceAnalysisException(librarySource); | 6200 } else if (sourceEntry is! DartEntry) { |
| 6269 } else if (sourceEntry is! DartEntry) { | 6201 // This shouldn't be possible because we should never have performed the
task if the source |
| 6270 // This shouldn't be possible because we should never have performed t
he task if the source | 6202 // didn't represent a Dart file, but check to be safe. |
| 6271 // didn't represent a Dart file, but check to be safe. | 6203 throw new AnalysisException.con1("Internal error: attempting to generate
hints for non-Dart file as a Dart file: ${librarySource.fullName}"); |
| 6272 throw new AnalysisException.con1("Internal error: attempting to genera
te hints for non-Dart file as a Dart file: ${librarySource.fullName}"); | |
| 6273 } | |
| 6274 if (thrownException == null) { | |
| 6275 thrownException = new AnalysisException.con1("GenerateDartHintsTask re
turned a null hint map without throwing an exception: ${librarySource.fullName}"
); | |
| 6276 } | |
| 6277 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy; | |
| 6278 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR); | |
| 6279 dartCopy.exception = thrownException; | |
| 6280 _cache.put(librarySource, dartCopy); | |
| 6281 } | 6204 } |
| 6205 if (thrownException == null) { |
| 6206 thrownException = new AnalysisException.con1("GenerateDartHintsTask retu
rned a null hint map without throwing an exception: ${librarySource.fullName}"); |
| 6207 } |
| 6208 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy; |
| 6209 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR); |
| 6210 dartCopy.exception = thrownException; |
| 6211 _cache.put(librarySource, dartCopy); |
| 6282 throw thrownException; | 6212 throw thrownException; |
| 6283 } | 6213 } |
| 6284 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE
ntrySet(hintMap)) { | 6214 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE
ntrySet(hintMap)) { |
| 6285 Source unitSource = entry.getKey(); | 6215 Source unitSource = entry.getKey(); |
| 6286 TimestampedData<List<AnalysisError>> results = entry.getValue(); | 6216 TimestampedData<List<AnalysisError>> results = entry.getValue(); |
| 6287 { | 6217 SourceEntry sourceEntry = _cache.get(unitSource); |
| 6288 SourceEntry sourceEntry = _cache.get(unitSource); | 6218 if (sourceEntry is! DartEntry) { |
| 6289 if (sourceEntry is! DartEntry) { | 6219 // This shouldn't be possible because we should never have performed the
task if the source |
| 6290 // This shouldn't be possible because we should never have performed t
he task if the source | 6220 // didn't represent a Dart file, but check to be safe. |
| 6291 // didn't represent a Dart file, but check to be safe. | 6221 throw new AnalysisException.con1("Internal error: attempting to parse no
n-Dart file as a Dart file: ${unitSource.fullName}"); |
| 6292 throw new AnalysisException.con1("Internal error: attempting to parse
non-Dart file as a Dart file: ${unitSource.fullName}"); | 6222 } |
| 6223 DartEntry dartEntry = sourceEntry as DartEntry; |
| 6224 if (unitSource == librarySource) { |
| 6225 libraryEntry = dartEntry; |
| 6226 } |
| 6227 int sourceTime = getModificationStamp(unitSource); |
| 6228 int resultTime = results.modificationTime; |
| 6229 if (sourceTime == resultTime) { |
| 6230 if (dartEntry.modificationTime != sourceTime) { |
| 6231 // The source has changed without the context being notified. Simulate
notification. |
| 6232 sourceChanged(unitSource); |
| 6233 dartEntry = getReadableDartEntry(unitSource); |
| 6234 if (dartEntry == null) { |
| 6235 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); |
| 6236 } |
| 6293 } | 6237 } |
| 6294 DartEntry dartEntry = sourceEntry as DartEntry; | 6238 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6295 if (unitSource == librarySource) { | 6239 if (thrownException == null) { |
| 6296 libraryEntry = dartEntry; | 6240 dartCopy.setValue2(DartEntry.HINTS, librarySource, results.data); |
| 6241 ChangeNoticeImpl notice = getNotice(unitSource); |
| 6242 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 6243 } else { |
| 6244 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR); |
| 6297 } | 6245 } |
| 6298 int sourceTime = getModificationStamp(unitSource); | 6246 dartCopy.exception = thrownException; |
| 6299 int resultTime = results.modificationTime; | 6247 _cache.put(unitSource, dartCopy); |
| 6300 if (sourceTime == resultTime) { | 6248 dartEntry = dartCopy; |
| 6301 if (dartEntry.modificationTime != sourceTime) { | 6249 } else { |
| 6302 // The source has changed without the context being notified. Simula
te notification. | 6250 logInformation2("Generated hints discarded for ${debuggingString(unitSou
rce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dar
tEntry.modificationTime}", thrownException); |
| 6303 sourceChanged(unitSource); | 6251 if (identical(dartEntry.getState2(DartEntry.HINTS, librarySource), Cache
State.IN_PROCESS)) { |
| 6304 dartEntry = getReadableDartEntry(unitSource); | |
| 6305 if (dartEntry == null) { | |
| 6306 throw new AnalysisException.con1("A Dart file became a non-Dart fi
le: ${unitSource.fullName}"); | |
| 6307 } | |
| 6308 } | |
| 6309 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6252 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6310 if (thrownException == null) { | 6253 if (thrownException == null || resultTime >= 0) { |
| 6311 dartCopy.setValue2(DartEntry.HINTS, librarySource, results.data); | 6254 // |
| 6312 ChangeNoticeImpl notice = getNotice(unitSource); | 6255 // The analysis was performed on out-of-date sources. Mark the cache
so that the sources |
| 6313 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.L
INE_INFO)); | 6256 // will be re-analyzed using the up-to-date sources. |
| 6257 // |
| 6258 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca
cheState.INVALID); |
| 6259 removeFromParts(unitSource, dartEntry); |
| 6260 dartCopy.invalidateAllInformation(); |
| 6261 dartCopy.modificationTime = sourceTime; |
| 6262 _cache.removedAst(unitSource); |
| 6263 _workManager.add(unitSource, SourcePriority.UNKNOWN); |
| 6314 } else { | 6264 } else { |
| 6265 // |
| 6266 // We could not determine whether the sources were up-to-date or out
-of-date. Mark the |
| 6267 // cache so that we won't attempt to re-analyze the sources until th
ere's a good chance |
| 6268 // that we'll be able to do so without error. |
| 6269 // |
| 6315 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR)
; | 6270 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR)
; |
| 6316 } | 6271 } |
| 6317 dartCopy.exception = thrownException; | 6272 dartCopy.exception = thrownException; |
| 6318 _cache.put(unitSource, dartCopy); | 6273 _cache.put(unitSource, dartCopy); |
| 6319 dartEntry = dartCopy; | 6274 dartEntry = dartCopy; |
| 6320 } else { | |
| 6321 logInformation2("Generated hints discarded for ${debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); | |
| 6322 if (identical(dartEntry.getState2(DartEntry.HINTS, librarySource), Cac
heState.IN_PROCESS)) { | |
| 6323 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 6324 if (thrownException == null || resultTime >= 0) { | |
| 6325 // | |
| 6326 // The analysis was performed on out-of-date sources. Mark the cac
he so that the sources | |
| 6327 // will be re-analyzed using the up-to-date sources. | |
| 6328 // | |
| 6329 // dartCopy.setState(DartEntry.HINTS, librarySource,
CacheState.INVALID); | |
| 6330 removeFromParts(unitSource, dartEntry); | |
| 6331 dartCopy.invalidateAllInformation(); | |
| 6332 dartCopy.modificationTime = sourceTime; | |
| 6333 _cache.removedAst(unitSource); | |
| 6334 _workManager.add(unitSource, SourcePriority.UNKNOWN); | |
| 6335 } else { | |
| 6336 // | |
| 6337 // We could not determine whether the sources were up-to-date or o
ut-of-date. Mark the | |
| 6338 // cache so that we won't attempt to re-analyze the sources until
there's a good chance | |
| 6339 // that we'll be able to do so without error. | |
| 6340 // | |
| 6341 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERRO
R); | |
| 6342 } | |
| 6343 dartCopy.exception = thrownException; | |
| 6344 _cache.put(unitSource, dartCopy); | |
| 6345 dartEntry = dartCopy; | |
| 6346 } | |
| 6347 } | 6275 } |
| 6348 } | 6276 } |
| 6349 } | 6277 } |
| 6350 if (thrownException != null) { | 6278 if (thrownException != null) { |
| 6351 throw thrownException; | 6279 throw thrownException; |
| 6352 } | 6280 } |
| 6353 return libraryEntry; | 6281 return libraryEntry; |
| 6354 } | 6282 } |
| 6355 | 6283 |
| 6356 /** | 6284 /** |
| 6357 * Record the results produced by performing a [GetContentTask]. | 6285 * Record the results produced by performing a [GetContentTask]. |
| 6358 * | 6286 * |
| 6359 * @param task the task that was performed | 6287 * @param task the task that was performed |
| 6360 * @return an entry containing the computed results | 6288 * @return an entry containing the computed results |
| 6361 * @throws AnalysisException if the results could not be recorded | 6289 * @throws AnalysisException if the results could not be recorded |
| 6362 */ | 6290 */ |
| 6363 SourceEntry recordGetContentsTask(GetContentTask task) { | 6291 SourceEntry recordGetContentsTask(GetContentTask task) { |
| 6364 if (!task.isComplete) { | 6292 if (!task.isComplete) { |
| 6365 return null; | 6293 return null; |
| 6366 } | 6294 } |
| 6367 Source source = task.source; | 6295 Source source = task.source; |
| 6368 AnalysisException thrownException = task.exception; | 6296 AnalysisException thrownException = task.exception; |
| 6369 SourceEntry sourceEntry = null; | 6297 SourceEntry sourceEntry = null; |
| 6370 { | 6298 sourceEntry = _cache.get(source); |
| 6371 sourceEntry = _cache.get(source); | 6299 if (sourceEntry == null) { |
| 6372 if (sourceEntry == null) { | 6300 throw new ObsoleteSourceAnalysisException(source); |
| 6373 throw new ObsoleteSourceAnalysisException(source); | |
| 6374 } | |
| 6375 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | |
| 6376 if (thrownException == null) { | |
| 6377 sourceCopy.modificationTime = task.modificationTime; | |
| 6378 sourceCopy.setValue(SourceEntry.CONTENT, task.content); | |
| 6379 } else { | |
| 6380 sourceCopy.exception = thrownException; | |
| 6381 sourceCopy.recordContentError(); | |
| 6382 _workManager.remove(source); | |
| 6383 } | |
| 6384 _cache.put(source, sourceCopy); | |
| 6385 sourceEntry = sourceCopy; | |
| 6386 } | 6301 } |
| 6302 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 6303 if (thrownException == null) { |
| 6304 sourceCopy.modificationTime = task.modificationTime; |
| 6305 sourceCopy.setValue(SourceEntry.CONTENT, task.content); |
| 6306 } else { |
| 6307 sourceCopy.exception = thrownException; |
| 6308 sourceCopy.recordContentError(); |
| 6309 _workManager.remove(source); |
| 6310 } |
| 6311 _cache.put(source, sourceCopy); |
| 6312 sourceEntry = sourceCopy; |
| 6387 if (thrownException != null) { | 6313 if (thrownException != null) { |
| 6388 throw thrownException; | 6314 throw thrownException; |
| 6389 } | 6315 } |
| 6390 return sourceEntry; | 6316 return sourceEntry; |
| 6391 } | 6317 } |
| 6392 | 6318 |
| 6393 /** | 6319 /** |
| 6394 * Record the results produced by performing a [IncrementalAnalysisTask]. | 6320 * Record the results produced by performing a [IncrementalAnalysisTask]. |
| 6395 * | 6321 * |
| 6396 * @param task the task that was performed | 6322 * @param task the task that was performed |
| 6397 * @return an entry containing the computed results | 6323 * @return an entry containing the computed results |
| 6398 * @throws AnalysisException if the results could not be recorded | 6324 * @throws AnalysisException if the results could not be recorded |
| 6399 */ | 6325 */ |
| 6400 DartEntry recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { | 6326 DartEntry recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { |
| 6401 { | 6327 CompilationUnit unit = task.compilationUnit; |
| 6402 CompilationUnit unit = task.compilationUnit; | 6328 if (unit != null) { |
| 6403 if (unit != null) { | 6329 ChangeNoticeImpl notice = getNotice(task.source); |
| 6404 ChangeNoticeImpl notice = getNotice(task.source); | 6330 notice.compilationUnit = unit; |
| 6405 notice.compilationUnit = unit; | 6331 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); |
| 6406 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.ca
che, unit); | |
| 6407 } | |
| 6408 } | 6332 } |
| 6409 return null; | 6333 return null; |
| 6410 } | 6334 } |
| 6411 | 6335 |
| 6412 /** | 6336 /** |
| 6413 * Record the results produced by performing a [ParseDartTask]. If the results
were computed | 6337 * Record the results produced by performing a [ParseDartTask]. If the results
were computed |
| 6414 * from data that is now out-of-date, then the results will not be recorded. | 6338 * from data that is now out-of-date, then the results will not be recorded. |
| 6415 * | 6339 * |
| 6416 * @param task the task that was performed | 6340 * @param task the task that was performed |
| 6417 * @return an entry containing the computed results | 6341 * @return an entry containing the computed results |
| 6418 * @throws AnalysisException if the results could not be recorded | 6342 * @throws AnalysisException if the results could not be recorded |
| 6419 */ | 6343 */ |
| 6420 DartEntry recordParseDartTaskResults(ParseDartTask task) { | 6344 DartEntry recordParseDartTaskResults(ParseDartTask task) { |
| 6421 Source source = task.source; | 6345 Source source = task.source; |
| 6422 AnalysisException thrownException = task.exception; | 6346 AnalysisException thrownException = task.exception; |
| 6423 DartEntry dartEntry = null; | 6347 DartEntry dartEntry = null; |
| 6424 { | 6348 SourceEntry sourceEntry = _cache.get(source); |
| 6425 SourceEntry sourceEntry = _cache.get(source); | 6349 if (sourceEntry == null) { |
| 6426 if (sourceEntry == null) { | 6350 throw new ObsoleteSourceAnalysisException(source); |
| 6427 throw new ObsoleteSourceAnalysisException(source); | 6351 } else if (sourceEntry is! DartEntry) { |
| 6428 } else if (sourceEntry is! DartEntry) { | 6352 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6429 // This shouldn't be possible because we should never have performed the
task if the source | 6353 // didn't represent a Dart file, but check to be safe. |
| 6430 // didn't represent a Dart file, but check to be safe. | 6354 throw new AnalysisException.con1("Internal error: attempting to parse non-
Dart file as a Dart file: ${source.fullName}"); |
| 6431 throw new AnalysisException.con1("Internal error: attempting to parse no
n-Dart file as a Dart file: ${source.fullName}"); | 6355 } |
| 6356 dartEntry = sourceEntry as DartEntry; |
| 6357 int sourceTime = getModificationStamp(source); |
| 6358 int resultTime = task.modificationTime; |
| 6359 if (sourceTime == resultTime) { |
| 6360 if (dartEntry.modificationTime != sourceTime) { |
| 6361 // The source has changed without the context being notified. Simulate n
otification. |
| 6362 sourceChanged(source); |
| 6363 dartEntry = getReadableDartEntry(source); |
| 6364 if (dartEntry == null) { |
| 6365 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6366 } |
| 6432 } | 6367 } |
| 6433 dartEntry = sourceEntry as DartEntry; | 6368 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6434 int sourceTime = getModificationStamp(source); | 6369 if (thrownException == null) { |
| 6435 int resultTime = task.modificationTime; | 6370 if (task.hasPartOfDirective() && !task.hasLibraryDirective()) { |
| 6436 if (sourceTime == resultTime) { | 6371 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 6437 if (dartEntry.modificationTime != sourceTime) { | 6372 dartCopy.removeContainingLibrary(source); |
| 6438 // The source has changed without the context being notified. Simulate
notification. | 6373 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 6439 sourceChanged(source); | 6374 } else { |
| 6440 dartEntry = getReadableDartEntry(source); | 6375 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 6441 if (dartEntry == null) { | 6376 dartCopy.containingLibrary = source; |
| 6442 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | 6377 _workManager.add(source, SourcePriority.LIBRARY); |
| 6443 } | |
| 6444 } | 6378 } |
| 6445 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6379 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); |
| 6446 if (thrownException == null) { | 6380 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); |
| 6447 if (task.hasPartOfDirective() && !task.hasLibraryDirective()) { | 6381 _cache.storedAst(source); |
| 6448 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 6382 ChangeNoticeImpl notice = getNotice(source); |
| 6449 dartCopy.removeContainingLibrary(source); | 6383 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6450 _workManager.add(source, SourcePriority.NORMAL_PART); | 6384 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache |
| 6451 } else { | 6385 // is structurally equivalent to the fully parsed unit |
| 6452 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 6386 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); |
| 6453 dartCopy.containingLibrary = source; | |
| 6454 _workManager.add(source, SourcePriority.LIBRARY); | |
| 6455 } | |
| 6456 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); | |
| 6457 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); | |
| 6458 _cache.storedAst(source); | |
| 6459 ChangeNoticeImpl notice = getNotice(source); | |
| 6460 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 6461 // Verify that the incrementally parsed and resolved unit in the incre
mental cache | |
| 6462 // is structurally equivalent to the fully parsed unit | |
| 6463 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_
incrementalAnalysisCache, source, task.compilationUnit); | |
| 6464 } else { | |
| 6465 removeFromParts(source, dartEntry); | |
| 6466 dartCopy.recordParseError(); | |
| 6467 _cache.removedAst(source); | |
| 6468 } | |
| 6469 dartCopy.exception = thrownException; | |
| 6470 _cache.put(source, dartCopy); | |
| 6471 dartEntry = dartCopy; | |
| 6472 } else { | 6387 } else { |
| 6473 logInformation2("Parse results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry
.modificationTime}", thrownException); | 6388 removeFromParts(source, dartEntry); |
| 6474 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6389 dartCopy.recordParseError(); |
| 6475 if (thrownException == null || resultTime >= 0) { | 6390 _cache.removedAst(source); |
| 6476 // | |
| 6477 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 6478 // will be re-analyzed using the up-to-date sources. | |
| 6479 // | |
| 6480 // dartCopy.recordParseNotInProcess(); | |
| 6481 removeFromParts(source, dartEntry); | |
| 6482 dartCopy.invalidateAllInformation(); | |
| 6483 dartCopy.modificationTime = sourceTime; | |
| 6484 _cache.removedAst(source); | |
| 6485 _workManager.add(source, SourcePriority.UNKNOWN); | |
| 6486 } else { | |
| 6487 // | |
| 6488 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6489 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 6490 // that we'll be able to do so without error. | |
| 6491 // | |
| 6492 dartCopy.recordParseError(); | |
| 6493 } | |
| 6494 dartCopy.exception = thrownException; | |
| 6495 _cache.put(source, dartCopy); | |
| 6496 dartEntry = dartCopy; | |
| 6497 } | 6391 } |
| 6392 dartCopy.exception = thrownException; |
| 6393 _cache.put(source, dartCopy); |
| 6394 dartEntry = dartCopy; |
| 6395 } else { |
| 6396 logInformation2("Parse results discarded for ${debuggingString(source)}; s
ourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m
odificationTime}", thrownException); |
| 6397 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6398 if (thrownException == null || resultTime >= 0) { |
| 6399 // |
| 6400 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6401 // will be re-analyzed using the up-to-date sources. |
| 6402 // |
| 6403 // dartCopy.recordParseNotInProcess(); |
| 6404 removeFromParts(source, dartEntry); |
| 6405 dartCopy.invalidateAllInformation(); |
| 6406 dartCopy.modificationTime = sourceTime; |
| 6407 _cache.removedAst(source); |
| 6408 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6409 } else { |
| 6410 // |
| 6411 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6412 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6413 // that we'll be able to do so without error. |
| 6414 // |
| 6415 dartCopy.recordParseError(); |
| 6416 } |
| 6417 dartCopy.exception = thrownException; |
| 6418 _cache.put(source, dartCopy); |
| 6419 dartEntry = dartCopy; |
| 6498 } | 6420 } |
| 6499 if (thrownException != null) { | 6421 if (thrownException != null) { |
| 6500 throw thrownException; | 6422 throw thrownException; |
| 6501 } | 6423 } |
| 6502 return dartEntry; | 6424 return dartEntry; |
| 6503 } | 6425 } |
| 6504 | 6426 |
| 6505 /** | 6427 /** |
| 6506 * Record the results produced by performing a [ParseHtmlTask]. If the results
were computed | 6428 * Record the results produced by performing a [ParseHtmlTask]. If the results
were computed |
| 6507 * from data that is now out-of-date, then the results will not be recorded. | 6429 * from data that is now out-of-date, then the results will not be recorded. |
| 6508 * | 6430 * |
| 6509 * @param task the task that was performed | 6431 * @param task the task that was performed |
| 6510 * @return an entry containing the computed results | 6432 * @return an entry containing the computed results |
| 6511 * @throws AnalysisException if the results could not be recorded | 6433 * @throws AnalysisException if the results could not be recorded |
| 6512 */ | 6434 */ |
| 6513 HtmlEntry recordParseHtmlTaskResults(ParseHtmlTask task) { | 6435 HtmlEntry recordParseHtmlTaskResults(ParseHtmlTask task) { |
| 6514 Source source = task.source; | 6436 Source source = task.source; |
| 6515 AnalysisException thrownException = task.exception; | 6437 AnalysisException thrownException = task.exception; |
| 6516 HtmlEntry htmlEntry = null; | 6438 HtmlEntry htmlEntry = null; |
| 6517 { | 6439 SourceEntry sourceEntry = _cache.get(source); |
| 6518 SourceEntry sourceEntry = _cache.get(source); | 6440 if (sourceEntry == null) { |
| 6519 if (sourceEntry == null) { | 6441 throw new ObsoleteSourceAnalysisException(source); |
| 6520 throw new ObsoleteSourceAnalysisException(source); | 6442 } else if (sourceEntry is! HtmlEntry) { |
| 6521 } else if (sourceEntry is! HtmlEntry) { | 6443 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6522 // This shouldn't be possible because we should never have performed the
task if the source | 6444 // didn't represent an HTML file, but check to be safe. |
| 6523 // didn't represent an HTML file, but check to be safe. | 6445 throw new AnalysisException.con1("Internal error: attempting to parse non-
HTML file as a HTML file: ${source.fullName}"); |
| 6524 throw new AnalysisException.con1("Internal error: attempting to parse no
n-HTML file as a HTML file: ${source.fullName}"); | 6446 } |
| 6447 htmlEntry = sourceEntry as HtmlEntry; |
| 6448 int sourceTime = getModificationStamp(source); |
| 6449 int resultTime = task.modificationTime; |
| 6450 if (sourceTime == resultTime) { |
| 6451 if (htmlEntry.modificationTime != sourceTime) { |
| 6452 // The source has changed without the context being notified. Simulate n
otification. |
| 6453 sourceChanged(source); |
| 6454 htmlEntry = getReadableHtmlEntry(source); |
| 6455 if (htmlEntry == null) { |
| 6456 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6457 } |
| 6525 } | 6458 } |
| 6526 htmlEntry = sourceEntry as HtmlEntry; | 6459 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 6527 int sourceTime = getModificationStamp(source); | 6460 if (thrownException == null) { |
| 6528 int resultTime = task.modificationTime; | 6461 LineInfo lineInfo = task.lineInfo; |
| 6529 if (sourceTime == resultTime) { | 6462 ht.HtmlUnit unit = task.htmlUnit; |
| 6530 if (htmlEntry.modificationTime != sourceTime) { | 6463 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 6531 // The source has changed without the context being notified. Simulate
notification. | 6464 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
| 6532 sourceChanged(source); | 6465 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); |
| 6533 htmlEntry = getReadableHtmlEntry(source); | 6466 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); |
| 6534 if (htmlEntry == null) { | 6467 _cache.storedAst(source); |
| 6535 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | 6468 ChangeNoticeImpl notice = getNotice(source); |
| 6536 } | 6469 notice.setErrors(htmlCopy.allErrors, lineInfo); |
| 6537 } | |
| 6538 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | |
| 6539 if (thrownException == null) { | |
| 6540 LineInfo lineInfo = task.lineInfo; | |
| 6541 ht.HtmlUnit unit = task.htmlUnit; | |
| 6542 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | |
| 6543 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | |
| 6544 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); | |
| 6545 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra
ries); | |
| 6546 _cache.storedAst(source); | |
| 6547 ChangeNoticeImpl notice = getNotice(source); | |
| 6548 notice.setErrors(htmlCopy.allErrors, lineInfo); | |
| 6549 } else { | |
| 6550 htmlCopy.recordParseError(); | |
| 6551 _cache.removedAst(source); | |
| 6552 } | |
| 6553 htmlCopy.exception = thrownException; | |
| 6554 _cache.put(source, htmlCopy); | |
| 6555 htmlEntry = htmlCopy; | |
| 6556 } else { | 6470 } else { |
| 6557 logInformation2("Parse results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); | 6471 htmlCopy.recordParseError(); |
| 6558 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 6472 _cache.removedAst(source); |
| 6559 if (thrownException == null || resultTime >= 0) { | |
| 6560 // | |
| 6561 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 6562 // will be re-analyzed using the up-to-date sources. | |
| 6563 // | |
| 6564 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState
.IN_PROCESS) { | |
| 6565 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVA
LID); | |
| 6566 // } | |
| 6567 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState
.IN_PROCESS) { | |
| 6568 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVA
LID); | |
| 6569 // } | |
| 6570 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == C
acheState.IN_PROCESS) { | |
| 6571 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheS
tate.INVALID); | |
| 6572 // } | |
| 6573 htmlCopy.invalidateAllInformation(); | |
| 6574 htmlCopy.modificationTime = sourceTime; | |
| 6575 _cache.removedAst(source); | |
| 6576 } else { | |
| 6577 // | |
| 6578 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6579 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 6580 // that we'll be able to do so without error. | |
| 6581 // | |
| 6582 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); | |
| 6583 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); | |
| 6584 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); | |
| 6585 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); | |
| 6586 } | |
| 6587 htmlCopy.exception = thrownException; | |
| 6588 _cache.put(source, htmlCopy); | |
| 6589 htmlEntry = htmlCopy; | |
| 6590 } | 6473 } |
| 6474 htmlCopy.exception = thrownException; |
| 6475 _cache.put(source, htmlCopy); |
| 6476 htmlEntry = htmlCopy; |
| 6477 } else { |
| 6478 logInformation2("Parse results discarded for ${debuggingString(source)}; s
ourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry.m
odificationTime}", thrownException); |
| 6479 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 6480 if (thrownException == null || resultTime >= 0) { |
| 6481 // |
| 6482 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6483 // will be re-analyzed using the up-to-date sources. |
| 6484 // |
| 6485 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I
N_PROCESS) { |
| 6486 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI
D); |
| 6487 // } |
| 6488 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I
N_PROCESS) { |
| 6489 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALI
D); |
| 6490 // } |
| 6491 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == Cac
heState.IN_PROCESS) { |
| 6492 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheSta
te.INVALID); |
| 6493 // } |
| 6494 htmlCopy.invalidateAllInformation(); |
| 6495 htmlCopy.modificationTime = sourceTime; |
| 6496 _cache.removedAst(source); |
| 6497 } else { |
| 6498 // |
| 6499 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6500 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6501 // that we'll be able to do so without error. |
| 6502 // |
| 6503 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 6504 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); |
| 6505 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); |
| 6506 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); |
| 6507 } |
| 6508 htmlCopy.exception = thrownException; |
| 6509 _cache.put(source, htmlCopy); |
| 6510 htmlEntry = htmlCopy; |
| 6591 } | 6511 } |
| 6592 if (thrownException != null) { | 6512 if (thrownException != null) { |
| 6593 throw thrownException; | 6513 throw thrownException; |
| 6594 } | 6514 } |
| 6595 return htmlEntry; | 6515 return htmlEntry; |
| 6596 } | 6516 } |
| 6597 | 6517 |
| 6598 /** | 6518 /** |
| 6599 * Record the results produced by performing a [ResolveAngularComponentTemplat
eTask]. If the | 6519 * Record the results produced by performing a [ResolveAngularComponentTemplat
eTask]. If the |
| 6600 * results were computed from data that is now out-of-date, then the results w
ill not be recorded. | 6520 * results were computed from data that is now out-of-date, then the results w
ill not be recorded. |
| 6601 * | 6521 * |
| 6602 * @param task the task that was performed | 6522 * @param task the task that was performed |
| 6603 * @throws AnalysisException if the results could not be recorded | 6523 * @throws AnalysisException if the results could not be recorded |
| 6604 */ | 6524 */ |
| 6605 HtmlEntry recordResolveAngularComponentTemplateTaskResults(ResolveAngularCompo
nentTemplateTask task) { | 6525 HtmlEntry recordResolveAngularComponentTemplateTaskResults(ResolveAngularCompo
nentTemplateTask task) { |
| 6606 Source source = task.source; | 6526 Source source = task.source; |
| 6607 AnalysisException thrownException = task.exception; | 6527 AnalysisException thrownException = task.exception; |
| 6608 HtmlEntry htmlEntry = null; | 6528 HtmlEntry htmlEntry = null; |
| 6609 { | 6529 SourceEntry sourceEntry = _cache.get(source); |
| 6610 SourceEntry sourceEntry = _cache.get(source); | 6530 if (sourceEntry == null) { |
| 6611 if (sourceEntry == null) { | 6531 throw new ObsoleteSourceAnalysisException(source); |
| 6612 throw new ObsoleteSourceAnalysisException(source); | 6532 } else if (sourceEntry is! HtmlEntry) { |
| 6613 } else if (sourceEntry is! HtmlEntry) { | 6533 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6614 // This shouldn't be possible because we should never have performed the
task if the source | 6534 // didn't represent an HTML file, but check to be safe. |
| 6615 // didn't represent an HTML file, but check to be safe. | 6535 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); |
| 6616 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); | 6536 } |
| 6537 htmlEntry = sourceEntry as HtmlEntry; |
| 6538 int sourceTime = getModificationStamp(source); |
| 6539 int resultTime = task.modificationTime; |
| 6540 if (sourceTime == resultTime) { |
| 6541 if (htmlEntry.modificationTime != sourceTime) { |
| 6542 // The source has changed without the context being notified. Simulate n
otification. |
| 6543 sourceChanged(source); |
| 6544 htmlEntry = getReadableHtmlEntry(source); |
| 6545 if (htmlEntry == null) { |
| 6546 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6547 } |
| 6617 } | 6548 } |
| 6618 htmlEntry = sourceEntry as HtmlEntry; | 6549 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6619 int sourceTime = getModificationStamp(source); | 6550 if (thrownException == null) { |
| 6620 int resultTime = task.modificationTime; | 6551 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); |
| 6621 if (sourceTime == resultTime) { | 6552 // notify about errors |
| 6622 if (htmlEntry.modificationTime != sourceTime) { | 6553 ChangeNoticeImpl notice = getNotice(source); |
| 6623 // The source has changed without the context being notified. Simulate
notification. | 6554 notice.htmlUnit = task.resolvedUnit; |
| 6624 sourceChanged(source); | 6555 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6625 htmlEntry = getReadableHtmlEntry(source); | |
| 6626 if (htmlEntry == null) { | |
| 6627 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | |
| 6628 } | |
| 6629 } | |
| 6630 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | |
| 6631 if (thrownException == null) { | |
| 6632 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); | |
| 6633 // notify about errors | |
| 6634 ChangeNoticeImpl notice = getNotice(source); | |
| 6635 notice.htmlUnit = task.resolvedUnit; | |
| 6636 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 6637 } else { | |
| 6638 htmlCopy.recordResolutionError(); | |
| 6639 } | |
| 6640 htmlCopy.exception = thrownException; | |
| 6641 _cache.put(source, htmlCopy); | |
| 6642 htmlEntry = htmlCopy; | |
| 6643 } else { | 6556 } else { |
| 6644 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6557 htmlCopy.recordResolutionError(); |
| 6645 if (thrownException == null || resultTime >= 0) { | |
| 6646 // | |
| 6647 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 6648 // will be re-analyzed using the up-to-date sources. | |
| 6649 // | |
| 6650 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheSt
ate.IN_PROCESS) { | |
| 6651 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.I
NVALID); | |
| 6652 // } | |
| 6653 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { | |
| 6654 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; | |
| 6655 // } | |
| 6656 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { | |
| 6657 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); | |
| 6658 // } | |
| 6659 htmlCopy.invalidateAllInformation(); | |
| 6660 htmlCopy.modificationTime = sourceTime; | |
| 6661 _cache.removedAst(source); | |
| 6662 } else { | |
| 6663 // | |
| 6664 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6665 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 6666 // that we'll be able to do so without error. | |
| 6667 // | |
| 6668 htmlCopy.recordResolutionError(); | |
| 6669 } | |
| 6670 htmlCopy.exception = thrownException; | |
| 6671 _cache.put(source, htmlCopy); | |
| 6672 htmlEntry = htmlCopy; | |
| 6673 } | 6558 } |
| 6559 htmlCopy.exception = thrownException; |
| 6560 _cache.put(source, htmlCopy); |
| 6561 htmlEntry = htmlCopy; |
| 6562 } else { |
| 6563 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6564 if (thrownException == null || resultTime >= 0) { |
| 6565 // |
| 6566 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6567 // will be re-analyzed using the up-to-date sources. |
| 6568 // |
| 6569 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat
e.IN_PROCESS) { |
| 6570 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV
ALID); |
| 6571 // } |
| 6572 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR
OCESS) { |
| 6573 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 6574 // } |
| 6575 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS
tate.IN_PROCESS) { |
| 6576 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.
INVALID); |
| 6577 // } |
| 6578 htmlCopy.invalidateAllInformation(); |
| 6579 htmlCopy.modificationTime = sourceTime; |
| 6580 _cache.removedAst(source); |
| 6581 } else { |
| 6582 // |
| 6583 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6584 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6585 // that we'll be able to do so without error. |
| 6586 // |
| 6587 htmlCopy.recordResolutionError(); |
| 6588 } |
| 6589 htmlCopy.exception = thrownException; |
| 6590 _cache.put(source, htmlCopy); |
| 6591 htmlEntry = htmlCopy; |
| 6674 } | 6592 } |
| 6675 if (thrownException != null) { | 6593 if (thrownException != null) { |
| 6676 throw thrownException; | 6594 throw thrownException; |
| 6677 } | 6595 } |
| 6678 return htmlEntry; | 6596 return htmlEntry; |
| 6679 } | 6597 } |
| 6680 | 6598 |
| 6681 /** | 6599 /** |
| 6682 * Record the results produced by performing a [ResolveAngularEntryHtmlTask].
If the results | 6600 * Record the results produced by performing a [ResolveAngularEntryHtmlTask].
If the results |
| 6683 * were computed from data that is now out-of-date, then the results will not
be recorded. | 6601 * were computed from data that is now out-of-date, then the results will not
be recorded. |
| 6684 * | 6602 * |
| 6685 * @param task the task that was performed | 6603 * @param task the task that was performed |
| 6686 * @throws AnalysisException if the results could not be recorded | 6604 * @throws AnalysisException if the results could not be recorded |
| 6687 */ | 6605 */ |
| 6688 HtmlEntry recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTask
task) { | 6606 HtmlEntry recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTask
task) { |
| 6689 Source source = task.source; | 6607 Source source = task.source; |
| 6690 AnalysisException thrownException = task.exception; | 6608 AnalysisException thrownException = task.exception; |
| 6691 HtmlEntry htmlEntry = null; | 6609 HtmlEntry htmlEntry = null; |
| 6692 { | 6610 SourceEntry sourceEntry = _cache.get(source); |
| 6693 SourceEntry sourceEntry = _cache.get(source); | 6611 if (sourceEntry == null) { |
| 6694 if (sourceEntry == null) { | 6612 throw new ObsoleteSourceAnalysisException(source); |
| 6695 throw new ObsoleteSourceAnalysisException(source); | 6613 } else if (sourceEntry is! HtmlEntry) { |
| 6696 } else if (sourceEntry is! HtmlEntry) { | 6614 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6697 // This shouldn't be possible because we should never have performed the
task if the source | 6615 // didn't represent an HTML file, but check to be safe. |
| 6698 // didn't represent an HTML file, but check to be safe. | 6616 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); |
| 6699 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); | 6617 } |
| 6618 htmlEntry = sourceEntry as HtmlEntry; |
| 6619 int sourceTime = getModificationStamp(source); |
| 6620 int resultTime = task.modificationTime; |
| 6621 if (sourceTime == resultTime) { |
| 6622 if (htmlEntry.modificationTime != sourceTime) { |
| 6623 // The source has changed without the context being notified. Simulate n
otification. |
| 6624 sourceChanged(source); |
| 6625 htmlEntry = getReadableHtmlEntry(source); |
| 6626 if (htmlEntry == null) { |
| 6627 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6628 } |
| 6700 } | 6629 } |
| 6701 htmlEntry = sourceEntry as HtmlEntry; | 6630 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6702 int sourceTime = getModificationStamp(source); | 6631 if (thrownException == null) { |
| 6703 int resultTime = task.modificationTime; | 6632 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 6704 if (sourceTime == resultTime) { | 6633 recordAngularEntryPoint(htmlCopy, task); |
| 6705 if (htmlEntry.modificationTime != sourceTime) { | 6634 _cache.storedAst(source); |
| 6706 // The source has changed without the context being notified. Simulate
notification. | 6635 ChangeNoticeImpl notice = getNotice(source); |
| 6707 sourceChanged(source); | 6636 notice.htmlUnit = task.resolvedUnit; |
| 6708 htmlEntry = getReadableHtmlEntry(source); | 6637 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6709 if (htmlEntry == null) { | |
| 6710 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | |
| 6711 } | |
| 6712 } | |
| 6713 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | |
| 6714 if (thrownException == null) { | |
| 6715 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | |
| 6716 recordAngularEntryPoint(htmlCopy, task); | |
| 6717 _cache.storedAst(source); | |
| 6718 ChangeNoticeImpl notice = getNotice(source); | |
| 6719 notice.htmlUnit = task.resolvedUnit; | |
| 6720 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 6721 } else { | |
| 6722 htmlCopy.recordResolutionError(); | |
| 6723 } | |
| 6724 htmlCopy.exception = thrownException; | |
| 6725 _cache.put(source, htmlCopy); | |
| 6726 htmlEntry = htmlCopy; | |
| 6727 } else { | 6638 } else { |
| 6728 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6639 htmlCopy.recordResolutionError(); |
| 6729 if (thrownException == null || resultTime >= 0) { | |
| 6730 // | |
| 6731 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 6732 // will be re-analyzed using the up-to-date sources. | |
| 6733 // | |
| 6734 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheSt
ate.IN_PROCESS) { | |
| 6735 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.I
NVALID); | |
| 6736 // } | |
| 6737 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { | |
| 6738 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; | |
| 6739 // } | |
| 6740 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { | |
| 6741 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); | |
| 6742 // } | |
| 6743 htmlCopy.invalidateAllInformation(); | |
| 6744 htmlCopy.modificationTime = sourceTime; | |
| 6745 _cache.removedAst(source); | |
| 6746 } else { | |
| 6747 // | |
| 6748 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6749 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 6750 // that we'll be able to do so without error. | |
| 6751 // | |
| 6752 htmlCopy.recordResolutionError(); | |
| 6753 } | |
| 6754 htmlCopy.exception = thrownException; | |
| 6755 _cache.put(source, htmlCopy); | |
| 6756 htmlEntry = htmlCopy; | |
| 6757 } | 6640 } |
| 6641 htmlCopy.exception = thrownException; |
| 6642 _cache.put(source, htmlCopy); |
| 6643 htmlEntry = htmlCopy; |
| 6644 } else { |
| 6645 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6646 if (thrownException == null || resultTime >= 0) { |
| 6647 // |
| 6648 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6649 // will be re-analyzed using the up-to-date sources. |
| 6650 // |
| 6651 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat
e.IN_PROCESS) { |
| 6652 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV
ALID); |
| 6653 // } |
| 6654 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR
OCESS) { |
| 6655 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 6656 // } |
| 6657 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS
tate.IN_PROCESS) { |
| 6658 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.
INVALID); |
| 6659 // } |
| 6660 htmlCopy.invalidateAllInformation(); |
| 6661 htmlCopy.modificationTime = sourceTime; |
| 6662 _cache.removedAst(source); |
| 6663 } else { |
| 6664 // |
| 6665 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6666 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6667 // that we'll be able to do so without error. |
| 6668 // |
| 6669 htmlCopy.recordResolutionError(); |
| 6670 } |
| 6671 htmlCopy.exception = thrownException; |
| 6672 _cache.put(source, htmlCopy); |
| 6673 htmlEntry = htmlCopy; |
| 6758 } | 6674 } |
| 6759 if (thrownException != null) { | 6675 if (thrownException != null) { |
| 6760 throw thrownException; | 6676 throw thrownException; |
| 6761 } | 6677 } |
| 6762 return htmlEntry; | 6678 return htmlEntry; |
| 6763 } | 6679 } |
| 6764 | 6680 |
| 6765 /** | 6681 /** |
| 6766 * Record the results produced by performing a [ResolveDartDependenciesTask].
If the results | 6682 * Record the results produced by performing a [ResolveDartDependenciesTask].
If the results |
| 6767 * were computed from data that is now out-of-date, then the results will not
be recorded. | 6683 * were computed from data that is now out-of-date, then the results will not
be recorded. |
| 6768 * | 6684 * |
| 6769 * @param task the task that was performed | 6685 * @param task the task that was performed |
| 6770 * @return an entry containing the computed results | 6686 * @return an entry containing the computed results |
| 6771 * @throws AnalysisException if the results could not be recorded | 6687 * @throws AnalysisException if the results could not be recorded |
| 6772 */ | 6688 */ |
| 6773 DartEntry recordResolveDartDependenciesTaskResults(ResolveDartDependenciesTask
task) { | 6689 DartEntry recordResolveDartDependenciesTaskResults(ResolveDartDependenciesTask
task) { |
| 6774 Source source = task.source; | 6690 Source source = task.source; |
| 6775 AnalysisException thrownException = task.exception; | 6691 AnalysisException thrownException = task.exception; |
| 6776 DartEntry dartEntry = null; | 6692 DartEntry dartEntry = null; |
| 6777 { | 6693 SourceEntry sourceEntry = _cache.get(source); |
| 6778 SourceEntry sourceEntry = _cache.get(source); | 6694 if (sourceEntry == null) { |
| 6779 if (sourceEntry == null) { | 6695 throw new ObsoleteSourceAnalysisException(source); |
| 6780 throw new ObsoleteSourceAnalysisException(source); | 6696 } else if (sourceEntry is! DartEntry) { |
| 6781 } else if (sourceEntry is! DartEntry) { | 6697 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6782 // This shouldn't be possible because we should never have performed the
task if the source | 6698 // didn't represent a Dart file, but check to be safe. |
| 6783 // didn't represent a Dart file, but check to be safe. | 6699 throw new AnalysisException.con1("Internal error: attempting to resolve Da
rt dependencies in a non-Dart file: ${source.fullName}"); |
| 6784 throw new AnalysisException.con1("Internal error: attempting to resolve
Dart dependencies in a non-Dart file: ${source.fullName}"); | 6700 } |
| 6701 dartEntry = sourceEntry as DartEntry; |
| 6702 int sourceTime = getModificationStamp(source); |
| 6703 int resultTime = task.modificationTime; |
| 6704 if (sourceTime == resultTime) { |
| 6705 if (dartEntry.modificationTime != sourceTime) { |
| 6706 // The source has changed without the context being notified. Simulate n
otification. |
| 6707 sourceChanged(source); |
| 6708 dartEntry = getReadableDartEntry(source); |
| 6709 if (dartEntry == null) { |
| 6710 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6711 } |
| 6785 } | 6712 } |
| 6786 dartEntry = sourceEntry as DartEntry; | 6713 removeFromParts(source, dartEntry); |
| 6787 int sourceTime = getModificationStamp(source); | 6714 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6788 int resultTime = task.modificationTime; | 6715 if (thrownException == null) { |
| 6789 if (sourceTime == resultTime) { | 6716 List<Source> newParts = task.includedSources; |
| 6790 if (dartEntry.modificationTime != sourceTime) { | 6717 for (int i = 0; i < newParts.length; i++) { |
| 6791 // The source has changed without the context being notified. Simulate
notification. | 6718 Source partSource = newParts[i]; |
| 6792 sourceChanged(source); | 6719 DartEntry partEntry = getReadableDartEntry(partSource); |
| 6793 dartEntry = getReadableDartEntry(source); | 6720 if (partEntry != null && partEntry != dartEntry) { |
| 6794 if (dartEntry == null) { | 6721 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6795 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | 6722 partCopy.addContainingLibrary(source); |
| 6723 _cache.put(partSource, partCopy); |
| 6796 } | 6724 } |
| 6797 } | 6725 } |
| 6726 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); |
| 6727 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); |
| 6728 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); |
| 6729 } else { |
| 6730 dartCopy.recordDependencyError(); |
| 6731 } |
| 6732 dartCopy.exception = thrownException; |
| 6733 _cache.put(source, dartCopy); |
| 6734 dartEntry = dartCopy; |
| 6735 } else { |
| 6736 logInformation2("Dependency resolution results discarded for ${debuggingSt
ring(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime
= ${dartEntry.modificationTime}", thrownException); |
| 6737 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6738 if (thrownException == null || resultTime >= 0) { |
| 6739 // |
| 6740 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6741 // will be re-analyzed using the up-to-date sources. |
| 6742 // |
| 6743 // dartCopy.recordDependencyNotInProcess(); |
| 6798 removeFromParts(source, dartEntry); | 6744 removeFromParts(source, dartEntry); |
| 6799 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6745 dartCopy.invalidateAllInformation(); |
| 6800 if (thrownException == null) { | 6746 dartCopy.modificationTime = sourceTime; |
| 6801 List<Source> newParts = task.includedSources; | 6747 _cache.removedAst(source); |
| 6802 for (int i = 0; i < newParts.length; i++) { | 6748 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6803 Source partSource = newParts[i]; | |
| 6804 DartEntry partEntry = getReadableDartEntry(partSource); | |
| 6805 if (partEntry != null && partEntry != dartEntry) { | |
| 6806 DartEntryImpl partCopy = partEntry.writableCopy; | |
| 6807 partCopy.addContainingLibrary(source); | |
| 6808 _cache.put(partSource, partCopy); | |
| 6809 } | |
| 6810 } | |
| 6811 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); | |
| 6812 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); | |
| 6813 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); | |
| 6814 } else { | |
| 6815 dartCopy.recordDependencyError(); | |
| 6816 } | |
| 6817 dartCopy.exception = thrownException; | |
| 6818 _cache.put(source, dartCopy); | |
| 6819 dartEntry = dartCopy; | |
| 6820 } else { | 6749 } else { |
| 6821 logInformation2("Dependency resolution results discarded for ${debugging
String(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTi
me = ${dartEntry.modificationTime}", thrownException); | 6750 // |
| 6822 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6751 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6823 if (thrownException == null || resultTime >= 0) { | 6752 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6824 // | 6753 // that we'll be able to do so without error. |
| 6825 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | 6754 // |
| 6826 // will be re-analyzed using the up-to-date sources. | 6755 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.ERROR); |
| 6827 // | 6756 dartCopy.setState(DartEntry.IMPORTED_LIBRARIES, CacheState.ERROR); |
| 6828 // dartCopy.recordDependencyNotInProcess(); | 6757 dartCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.ERROR); |
| 6829 removeFromParts(source, dartEntry); | |
| 6830 dartCopy.invalidateAllInformation(); | |
| 6831 dartCopy.modificationTime = sourceTime; | |
| 6832 _cache.removedAst(source); | |
| 6833 _workManager.add(source, SourcePriority.UNKNOWN); | |
| 6834 } else { | |
| 6835 // | |
| 6836 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6837 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 6838 // that we'll be able to do so without error. | |
| 6839 // | |
| 6840 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.ERROR); | |
| 6841 dartCopy.setState(DartEntry.IMPORTED_LIBRARIES, CacheState.ERROR); | |
| 6842 dartCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.ERROR); | |
| 6843 } | |
| 6844 dartCopy.exception = thrownException; | |
| 6845 _cache.put(source, dartCopy); | |
| 6846 dartEntry = dartCopy; | |
| 6847 } | 6758 } |
| 6759 dartCopy.exception = thrownException; |
| 6760 _cache.put(source, dartCopy); |
| 6761 dartEntry = dartCopy; |
| 6848 } | 6762 } |
| 6849 if (thrownException != null) { | 6763 if (thrownException != null) { |
| 6850 throw thrownException; | 6764 throw thrownException; |
| 6851 } | 6765 } |
| 6852 return dartEntry; | 6766 return dartEntry; |
| 6853 } | 6767 } |
| 6854 | 6768 |
| 6855 /** | 6769 /** |
| 6856 * Record the results produced by performing a [ResolveDartUnitTask]. If the r
esults were | 6770 * Record the results produced by performing a [ResolveDartUnitTask]. If the r
esults were |
| 6857 * computed from data that is now out-of-date, then the results will not be re
corded. | 6771 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6858 * | 6772 * |
| 6859 * @param task the task that was performed | 6773 * @param task the task that was performed |
| 6860 * @return an entry containing the computed results | 6774 * @return an entry containing the computed results |
| 6861 * @throws AnalysisException if the results could not be recorded | 6775 * @throws AnalysisException if the results could not be recorded |
| 6862 */ | 6776 */ |
| 6863 DartEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { | 6777 DartEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { |
| 6864 Source unitSource = task.source; | 6778 Source unitSource = task.source; |
| 6865 Source librarySource = task.librarySource; | 6779 Source librarySource = task.librarySource; |
| 6866 AnalysisException thrownException = task.exception; | 6780 AnalysisException thrownException = task.exception; |
| 6867 DartEntry dartEntry = null; | 6781 DartEntry dartEntry = null; |
| 6868 { | 6782 SourceEntry sourceEntry = _cache.get(unitSource); |
| 6869 SourceEntry sourceEntry = _cache.get(unitSource); | 6783 if (sourceEntry == null) { |
| 6870 if (sourceEntry == null) { | 6784 throw new ObsoleteSourceAnalysisException(unitSource); |
| 6871 throw new ObsoleteSourceAnalysisException(unitSource); | 6785 } else if (sourceEntry is! DartEntry) { |
| 6872 } else if (sourceEntry is! DartEntry) { | 6786 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6873 // This shouldn't be possible because we should never have performed the
task if the source | 6787 // didn't represent a Dart file, but check to be safe. |
| 6874 // didn't represent a Dart file, but check to be safe. | 6788 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-Dart file as a Dart file: ${unitSource.fullName}"); |
| 6875 throw new AnalysisException.con1("Internal error: attempting to resolve
non-Dart file as a Dart file: ${unitSource.fullName}"); | 6789 } |
| 6790 dartEntry = sourceEntry as DartEntry; |
| 6791 int sourceTime = getModificationStamp(unitSource); |
| 6792 int resultTime = task.modificationTime; |
| 6793 if (sourceTime == resultTime) { |
| 6794 if (dartEntry.modificationTime != sourceTime) { |
| 6795 // The source has changed without the context being notified. Simulate n
otification. |
| 6796 sourceChanged(unitSource); |
| 6797 dartEntry = getReadableDartEntry(unitSource); |
| 6798 if (dartEntry == null) { |
| 6799 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
| 6800 } |
| 6876 } | 6801 } |
| 6877 dartEntry = sourceEntry as DartEntry; | 6802 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6878 int sourceTime = getModificationStamp(unitSource); | 6803 if (thrownException == null) { |
| 6879 int resultTime = task.modificationTime; | 6804 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, task.resolved
Unit); |
| 6880 if (sourceTime == resultTime) { | 6805 _cache.storedAst(unitSource); |
| 6881 if (dartEntry.modificationTime != sourceTime) { | |
| 6882 // The source has changed without the context being notified. Simulate
notification. | |
| 6883 sourceChanged(unitSource); | |
| 6884 dartEntry = getReadableDartEntry(unitSource); | |
| 6885 if (dartEntry == null) { | |
| 6886 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); | |
| 6887 } | |
| 6888 } | |
| 6889 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 6890 if (thrownException == null) { | |
| 6891 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, task.resolv
edUnit); | |
| 6892 _cache.storedAst(unitSource); | |
| 6893 } else { | |
| 6894 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
ERROR); | |
| 6895 _cache.removedAst(unitSource); | |
| 6896 } | |
| 6897 dartCopy.exception = thrownException; | |
| 6898 _cache.put(unitSource, dartCopy); | |
| 6899 dartEntry = dartCopy; | |
| 6900 } else { | 6806 } else { |
| 6901 logInformation2("Resolution results discarded for ${debuggingString(unit
Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${
dartEntry.modificationTime}", thrownException); | 6807 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.ER
ROR); |
| 6902 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6808 _cache.removedAst(unitSource); |
| 6903 if (thrownException == null || resultTime >= 0) { | |
| 6904 // | |
| 6905 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 6906 // will be re-analyzed using the up-to-date sources. | |
| 6907 // | |
| 6908 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheSta
te.IN_PROCESS) { | |
| 6909 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource
, CacheState.INVALID); | |
| 6910 // } | |
| 6911 removeFromParts(unitSource, dartEntry); | |
| 6912 dartCopy.invalidateAllInformation(); | |
| 6913 dartCopy.modificationTime = sourceTime; | |
| 6914 _cache.removedAst(unitSource); | |
| 6915 _workManager.add(unitSource, SourcePriority.UNKNOWN); | |
| 6916 } else { | |
| 6917 // | |
| 6918 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 6919 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 6920 // that we'll be able to do so without error. | |
| 6921 // | |
| 6922 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
ERROR); | |
| 6923 } | |
| 6924 dartCopy.exception = thrownException; | |
| 6925 _cache.put(unitSource, dartCopy); | |
| 6926 dartEntry = dartCopy; | |
| 6927 } | 6809 } |
| 6810 dartCopy.exception = thrownException; |
| 6811 _cache.put(unitSource, dartCopy); |
| 6812 dartEntry = dartCopy; |
| 6813 } else { |
| 6814 logInformation2("Resolution results discarded for ${debuggingString(unitSo
urce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${da
rtEntry.modificationTime}", thrownException); |
| 6815 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6816 if (thrownException == null || resultTime >= 0) { |
| 6817 // |
| 6818 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6819 // will be re-analyzed using the up-to-date sources. |
| 6820 // |
| 6821 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState
.IN_PROCESS) { |
| 6822 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource,
CacheState.INVALID); |
| 6823 // } |
| 6824 removeFromParts(unitSource, dartEntry); |
| 6825 dartCopy.invalidateAllInformation(); |
| 6826 dartCopy.modificationTime = sourceTime; |
| 6827 _cache.removedAst(unitSource); |
| 6828 _workManager.add(unitSource, SourcePriority.UNKNOWN); |
| 6829 } else { |
| 6830 // |
| 6831 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6832 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6833 // that we'll be able to do so without error. |
| 6834 // |
| 6835 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.ER
ROR); |
| 6836 } |
| 6837 dartCopy.exception = thrownException; |
| 6838 _cache.put(unitSource, dartCopy); |
| 6839 dartEntry = dartCopy; |
| 6928 } | 6840 } |
| 6929 if (thrownException != null) { | 6841 if (thrownException != null) { |
| 6930 throw thrownException; | 6842 throw thrownException; |
| 6931 } | 6843 } |
| 6932 return dartEntry; | 6844 return dartEntry; |
| 6933 } | 6845 } |
| 6934 | 6846 |
| 6935 /** | 6847 /** |
| 6936 * Record the results produced by performing a [ResolveHtmlTask]. If the resul
ts were | 6848 * Record the results produced by performing a [ResolveHtmlTask]. If the resul
ts were |
| 6937 * computed from data that is now out-of-date, then the results will not be re
corded. | 6849 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6938 * | 6850 * |
| 6939 * @param task the task that was performed | 6851 * @param task the task that was performed |
| 6940 * @return an entry containing the computed results | 6852 * @return an entry containing the computed results |
| 6941 * @throws AnalysisException if the results could not be recorded | 6853 * @throws AnalysisException if the results could not be recorded |
| 6942 */ | 6854 */ |
| 6943 HtmlEntry recordResolveHtmlTaskResults(ResolveHtmlTask task) { | 6855 HtmlEntry recordResolveHtmlTaskResults(ResolveHtmlTask task) { |
| 6944 Source source = task.source; | 6856 Source source = task.source; |
| 6945 AnalysisException thrownException = task.exception; | 6857 AnalysisException thrownException = task.exception; |
| 6946 HtmlEntry htmlEntry = null; | 6858 HtmlEntry htmlEntry = null; |
| 6947 { | 6859 SourceEntry sourceEntry = _cache.get(source); |
| 6948 SourceEntry sourceEntry = _cache.get(source); | 6860 if (sourceEntry == null) { |
| 6949 if (sourceEntry == null) { | 6861 throw new ObsoleteSourceAnalysisException(source); |
| 6950 throw new ObsoleteSourceAnalysisException(source); | 6862 } else if (sourceEntry is! HtmlEntry) { |
| 6951 } else if (sourceEntry is! HtmlEntry) { | 6863 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6952 // This shouldn't be possible because we should never have performed the
task if the source | 6864 // didn't represent an HTML file, but check to be safe. |
| 6953 // didn't represent an HTML file, but check to be safe. | 6865 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); |
| 6954 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); | 6866 } |
| 6867 htmlEntry = sourceEntry as HtmlEntry; |
| 6868 int sourceTime = getModificationStamp(source); |
| 6869 int resultTime = task.modificationTime; |
| 6870 if (sourceTime == resultTime) { |
| 6871 if (htmlEntry.modificationTime != sourceTime) { |
| 6872 // The source has changed without the context being notified. Simulate n
otification. |
| 6873 sourceChanged(source); |
| 6874 htmlEntry = getReadableHtmlEntry(source); |
| 6875 if (htmlEntry == null) { |
| 6876 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6877 } |
| 6955 } | 6878 } |
| 6956 htmlEntry = sourceEntry as HtmlEntry; | 6879 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6957 int sourceTime = getModificationStamp(source); | 6880 if (thrownException == null) { |
| 6958 int resultTime = task.modificationTime; | 6881 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 6959 if (sourceTime == resultTime) { | 6882 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 6960 if (htmlEntry.modificationTime != sourceTime) { | 6883 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); |
| 6961 // The source has changed without the context being notified. Simulate
notification. | 6884 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); |
| 6962 sourceChanged(source); | 6885 _cache.storedAst(source); |
| 6963 htmlEntry = getReadableHtmlEntry(source); | 6886 ChangeNoticeImpl notice = getNotice(source); |
| 6964 if (htmlEntry == null) { | 6887 notice.htmlUnit = task.resolvedUnit; |
| 6965 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | 6888 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6966 } | |
| 6967 } | |
| 6968 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | |
| 6969 if (thrownException == null) { | |
| 6970 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 6971 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | |
| 6972 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); | |
| 6973 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); | |
| 6974 _cache.storedAst(source); | |
| 6975 ChangeNoticeImpl notice = getNotice(source); | |
| 6976 notice.htmlUnit = task.resolvedUnit; | |
| 6977 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 6978 } else { | |
| 6979 htmlCopy.recordResolutionError(); | |
| 6980 _cache.removedAst(source); | |
| 6981 } | |
| 6982 htmlCopy.exception = thrownException; | |
| 6983 _cache.put(source, htmlCopy); | |
| 6984 htmlEntry = htmlCopy; | |
| 6985 } else { | 6889 } else { |
| 6986 logInformation2("Resolution results discarded for ${debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); | 6890 htmlCopy.recordResolutionError(); |
| 6987 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6891 _cache.removedAst(source); |
| 6988 if (thrownException == null || resultTime >= 0) { | |
| 6989 // | |
| 6990 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 6991 // will be re-analyzed using the up-to-date sources. | |
| 6992 // | |
| 6993 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { | |
| 6994 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; | |
| 6995 // } | |
| 6996 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { | |
| 6997 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); | |
| 6998 // } | |
| 6999 htmlCopy.invalidateAllInformation(); | |
| 7000 htmlCopy.modificationTime = sourceTime; | |
| 7001 _cache.removedAst(source); | |
| 7002 } else { | |
| 7003 // | |
| 7004 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 7005 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 7006 // that we'll be able to do so without error. | |
| 7007 // | |
| 7008 htmlCopy.recordResolutionError(); | |
| 7009 } | |
| 7010 htmlCopy.exception = thrownException; | |
| 7011 _cache.put(source, htmlCopy); | |
| 7012 htmlEntry = htmlCopy; | |
| 7013 } | 6892 } |
| 6893 htmlCopy.exception = thrownException; |
| 6894 _cache.put(source, htmlCopy); |
| 6895 htmlEntry = htmlCopy; |
| 6896 } else { |
| 6897 logInformation2("Resolution results discarded for ${debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEn
try.modificationTime}", thrownException); |
| 6898 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6899 if (thrownException == null || resultTime >= 0) { |
| 6900 // |
| 6901 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6902 // will be re-analyzed using the up-to-date sources. |
| 6903 // |
| 6904 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR
OCESS) { |
| 6905 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 6906 // } |
| 6907 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS
tate.IN_PROCESS) { |
| 6908 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.
INVALID); |
| 6909 // } |
| 6910 htmlCopy.invalidateAllInformation(); |
| 6911 htmlCopy.modificationTime = sourceTime; |
| 6912 _cache.removedAst(source); |
| 6913 } else { |
| 6914 // |
| 6915 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6916 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6917 // that we'll be able to do so without error. |
| 6918 // |
| 6919 htmlCopy.recordResolutionError(); |
| 6920 } |
| 6921 htmlCopy.exception = thrownException; |
| 6922 _cache.put(source, htmlCopy); |
| 6923 htmlEntry = htmlCopy; |
| 7014 } | 6924 } |
| 7015 if (thrownException != null) { | 6925 if (thrownException != null) { |
| 7016 throw thrownException; | 6926 throw thrownException; |
| 7017 } | 6927 } |
| 7018 return htmlEntry; | 6928 return htmlEntry; |
| 7019 } | 6929 } |
| 7020 | 6930 |
| 7021 /** | 6931 /** |
| 7022 * Record the results produced by performing a [ScanDartTask]. If the results
were computed | 6932 * Record the results produced by performing a [ScanDartTask]. If the results
were computed |
| 7023 * from data that is now out-of-date, then the results will not be recorded. | 6933 * from data that is now out-of-date, then the results will not be recorded. |
| 7024 * | 6934 * |
| 7025 * @param task the task that was performed | 6935 * @param task the task that was performed |
| 7026 * @return an entry containing the computed results | 6936 * @return an entry containing the computed results |
| 7027 * @throws AnalysisException if the results could not be recorded | 6937 * @throws AnalysisException if the results could not be recorded |
| 7028 */ | 6938 */ |
| 7029 DartEntry recordScanDartTaskResults(ScanDartTask task) { | 6939 DartEntry recordScanDartTaskResults(ScanDartTask task) { |
| 7030 Source source = task.source; | 6940 Source source = task.source; |
| 7031 AnalysisException thrownException = task.exception; | 6941 AnalysisException thrownException = task.exception; |
| 7032 DartEntry dartEntry = null; | 6942 DartEntry dartEntry = null; |
| 7033 { | 6943 SourceEntry sourceEntry = _cache.get(source); |
| 7034 SourceEntry sourceEntry = _cache.get(source); | 6944 if (sourceEntry == null) { |
| 7035 if (sourceEntry == null) { | 6945 throw new ObsoleteSourceAnalysisException(source); |
| 7036 throw new ObsoleteSourceAnalysisException(source); | 6946 } else if (sourceEntry is! DartEntry) { |
| 7037 } else if (sourceEntry is! DartEntry) { | 6947 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 7038 // This shouldn't be possible because we should never have performed the
task if the source | 6948 // didn't represent a Dart file, but check to be safe. |
| 7039 // didn't represent a Dart file, but check to be safe. | 6949 throw new AnalysisException.con1("Internal error: attempting to parse non-
Dart file as a Dart file: ${source.fullName}"); |
| 7040 throw new AnalysisException.con1("Internal error: attempting to parse no
n-Dart file as a Dart file: ${source.fullName}"); | 6950 } |
| 6951 dartEntry = sourceEntry as DartEntry; |
| 6952 int sourceTime = getModificationStamp(source); |
| 6953 int resultTime = task.modificationTime; |
| 6954 if (sourceTime == resultTime) { |
| 6955 if (dartEntry.modificationTime != sourceTime) { |
| 6956 // The source has changed without the context being notified. Simulate n
otification. |
| 6957 sourceChanged(source); |
| 6958 dartEntry = getReadableDartEntry(source); |
| 6959 if (dartEntry == null) { |
| 6960 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6961 } |
| 7041 } | 6962 } |
| 7042 dartEntry = sourceEntry as DartEntry; | 6963 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 7043 int sourceTime = getModificationStamp(source); | 6964 if (thrownException == null) { |
| 7044 int resultTime = task.modificationTime; | 6965 LineInfo lineInfo = task.lineInfo; |
| 7045 if (sourceTime == resultTime) { | 6966 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 7046 if (dartEntry.modificationTime != sourceTime) { | 6967 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); |
| 7047 // The source has changed without the context being notified. Simulate
notification. | 6968 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); |
| 7048 sourceChanged(source); | 6969 _cache.storedAst(source); |
| 7049 dartEntry = getReadableDartEntry(source); | 6970 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 7050 if (dartEntry == null) { | 6971 ChangeNoticeImpl notice = getNotice(source); |
| 7051 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | 6972 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 7052 } | |
| 7053 } | |
| 7054 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 7055 if (thrownException == null) { | |
| 7056 LineInfo lineInfo = task.lineInfo; | |
| 7057 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | |
| 7058 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); | |
| 7059 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); | |
| 7060 _cache.storedAst(source); | |
| 7061 _workManager.add(source, SourcePriority.NORMAL_PART); | |
| 7062 ChangeNoticeImpl notice = getNotice(source); | |
| 7063 notice.setErrors(dartEntry.allErrors, lineInfo); | |
| 7064 } else { | |
| 7065 removeFromParts(source, dartEntry); | |
| 7066 dartCopy.recordScanError(); | |
| 7067 _cache.removedAst(source); | |
| 7068 } | |
| 7069 dartCopy.exception = thrownException; | |
| 7070 _cache.put(source, dartCopy); | |
| 7071 dartEntry = dartCopy; | |
| 7072 } else { | 6973 } else { |
| 7073 logInformation2("Scan results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}", thrownException); | 6974 removeFromParts(source, dartEntry); |
| 7074 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6975 dartCopy.recordScanError(); |
| 7075 if (thrownException == null || resultTime >= 0) { | 6976 _cache.removedAst(source); |
| 7076 // | |
| 7077 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | |
| 7078 // will be re-analyzed using the up-to-date sources. | |
| 7079 // | |
| 7080 // dartCopy.recordScanNotInProcess(); | |
| 7081 removeFromParts(source, dartEntry); | |
| 7082 dartCopy.invalidateAllInformation(); | |
| 7083 dartCopy.modificationTime = sourceTime; | |
| 7084 _cache.removedAst(source); | |
| 7085 _workManager.add(source, SourcePriority.UNKNOWN); | |
| 7086 } else { | |
| 7087 // | |
| 7088 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | |
| 7089 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | |
| 7090 // that we'll be able to do so without error. | |
| 7091 // | |
| 7092 dartCopy.recordScanError(); | |
| 7093 } | |
| 7094 dartCopy.exception = thrownException; | |
| 7095 _cache.put(source, dartCopy); | |
| 7096 dartEntry = dartCopy; | |
| 7097 } | 6977 } |
| 6978 dartCopy.exception = thrownException; |
| 6979 _cache.put(source, dartCopy); |
| 6980 dartEntry = dartCopy; |
| 6981 } else { |
| 6982 logInformation2("Scan results discarded for ${debuggingString(source)}; so
urceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.mo
dificationTime}", thrownException); |
| 6983 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6984 if (thrownException == null || resultTime >= 0) { |
| 6985 // |
| 6986 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6987 // will be re-analyzed using the up-to-date sources. |
| 6988 // |
| 6989 // dartCopy.recordScanNotInProcess(); |
| 6990 removeFromParts(source, dartEntry); |
| 6991 dartCopy.invalidateAllInformation(); |
| 6992 dartCopy.modificationTime = sourceTime; |
| 6993 _cache.removedAst(source); |
| 6994 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6995 } else { |
| 6996 // |
| 6997 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6998 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6999 // that we'll be able to do so without error. |
| 7000 // |
| 7001 dartCopy.recordScanError(); |
| 7002 } |
| 7003 dartCopy.exception = thrownException; |
| 7004 _cache.put(source, dartCopy); |
| 7005 dartEntry = dartCopy; |
| 7098 } | 7006 } |
| 7099 if (thrownException != null) { | 7007 if (thrownException != null) { |
| 7100 throw thrownException; | 7008 throw thrownException; |
| 7101 } | 7009 } |
| 7102 return dartEntry; | 7010 return dartEntry; |
| 7103 } | 7011 } |
| 7104 | 7012 |
| 7105 /** | 7013 /** |
| 7106 * Remove the given library from the list of containing libraries for all of t
he parts referenced | 7014 * Remove the given library from the list of containing libraries for all of t
he parts referenced |
| 7107 * by the given entry. | 7015 * by the given entry. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7266 * invalid so that the source will be re-analyzed. | 7174 * invalid so that the source will be re-analyzed. |
| 7267 * | 7175 * |
| 7268 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7176 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7269 * | 7177 * |
| 7270 * @return `true` if at least one entry was invalid | 7178 * @return `true` if at least one entry was invalid |
| 7271 */ | 7179 */ |
| 7272 bool validateCacheConsistency() { | 7180 bool validateCacheConsistency() { |
| 7273 int consistencyCheckStart = JavaSystem.nanoTime(); | 7181 int consistencyCheckStart = JavaSystem.nanoTime(); |
| 7274 List<Source> missingSources = new List<Source>(); | 7182 List<Source> missingSources = new List<Source>(); |
| 7275 int inconsistentCount = 0; | 7183 int inconsistentCount = 0; |
| 7276 { | 7184 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 7277 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 7185 Source source = entry.getKey(); |
| 7278 Source source = entry.getKey(); | 7186 SourceEntry sourceEntry = entry.getValue(); |
| 7279 SourceEntry sourceEntry = entry.getValue(); | 7187 int sourceTime = getModificationStamp(source); |
| 7280 int sourceTime = getModificationStamp(source); | 7188 if (sourceTime != sourceEntry.modificationTime) { |
| 7281 if (sourceTime != sourceEntry.modificationTime) { | 7189 sourceChanged(source); |
| 7282 sourceChanged(source); | 7190 inconsistentCount++; |
| 7283 inconsistentCount++; | 7191 } |
| 7284 } | 7192 if (sourceEntry.exception != null) { |
| 7285 if (sourceEntry.exception != null) { | 7193 if (!exists(source)) { |
| 7286 if (!exists(source)) { | 7194 missingSources.add(source); |
| 7287 missingSources.add(source); | |
| 7288 } | |
| 7289 } | 7195 } |
| 7290 } | 7196 } |
| 7291 } | 7197 } |
| 7292 int consistencyCheckEnd = JavaSystem.nanoTime(); | 7198 int consistencyCheckEnd = JavaSystem.nanoTime(); |
| 7293 PrintStringWriter writer = new PrintStringWriter(); | 7199 PrintStringWriter writer = new PrintStringWriter(); |
| 7294 writer.print("Consistency check took "); | 7200 writer.print("Consistency check took "); |
| 7295 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | 7201 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
| 7296 writer.println(" ms and found"); | 7202 writer.println(" ms and found"); |
| 7297 writer.print(" "); | 7203 writer.print(" "); |
| 7298 writer.print(inconsistentCount); | 7204 writer.print(inconsistentCount); |
| (...skipping 4752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12051 | 11957 |
| 12052 void logError2(String message, Exception exception) { | 11958 void logError2(String message, Exception exception) { |
| 12053 } | 11959 } |
| 12054 | 11960 |
| 12055 void logInformation(String message) { | 11961 void logInformation(String message) { |
| 12056 } | 11962 } |
| 12057 | 11963 |
| 12058 void logInformation3(String message, Exception exception) { | 11964 void logInformation3(String message, Exception exception) { |
| 12059 } | 11965 } |
| 12060 } | 11966 } |
| OLD | NEW |