Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 647033002: Remove more multi-thread support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 3942 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 * @param librarySource the source for the library used to record information 3953 * @param librarySource the source for the library used to record information
3954 * @param htmlSource the source for the HTML library 3954 * @param htmlSource the source for the HTML library
3955 */ 3955 */
3956 void _recordElementData(DartEntry dartEntry, LibraryElement library, Source li brarySource, Source htmlSource) { 3956 void _recordElementData(DartEntry dartEntry, LibraryElement library, Source li brarySource, Source htmlSource) {
3957 dartEntry.setValue(DartEntry.ELEMENT, library); 3957 dartEntry.setValue(DartEntry.ELEMENT, library);
3958 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 3958 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
3959 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>())); 3959 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>()));
3960 } 3960 }
3961 3961
3962 /** 3962 /**
3963 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were 3963 * Record the results produced by performing a [task] and return the cache
3964 * computed from data that is now out-of-date, then the results will not be re corded. 3964 * entry associated with the results.
3965 *
3966 * @param task the task that was performed
3967 * @return an entry containing the computed results
3968 * @throws AnalysisException if the results could not be recorded
3969 */ 3965 */
3970 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { 3966 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) {
3971 Source source = task.source; 3967 Source source = task.source;
3968 DartEntry dartEntry = _cache.get(source);
3972 Source librarySource = task.libraryElement.source; 3969 Source librarySource = task.libraryElement.source;
3973 CaughtException thrownException = task.exception; 3970 CaughtException thrownException = task.exception;
3974 SourceEntry sourceEntry = _cache.get(source);
3975 if (sourceEntry == null) {
3976 throw new ObsoleteSourceAnalysisException(source);
3977 } else if (sourceEntry is! DartEntry) {
3978 // This shouldn't be possible because we should never have performed the t ask if the source
3979 // didn't represent a Dart file, but check to be safe.
3980 throw new AnalysisException("Internal error: attempting to verify non-Dart file as a Dart file: ${source.fullName}");
3981 }
3982 DartEntry dartEntry = sourceEntry;
3983 int sourceTime = getModificationStamp(source);
scheglov 2014/10/10 19:52:56 The source cannot be modified in _contentCache. Bu
Brian Wilkerson 2014/10/10 20:24:55 Yes, that was my conclusion as well. The original
3984 int resultTime = task.modificationTime;
3985 if (sourceTime == resultTime) {
3986 if (dartEntry.modificationTime != sourceTime) {
3987 // The source has changed without the context being notified. Simulate n otification.
3988 _sourceChanged(source);
3989 dartEntry = _getReadableDartEntry(source);
3990 if (dartEntry == null) {
3991 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
3992 }
3993 }
3994 if (thrownException == null) {
3995 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource , task.errors);
3996 ChangeNoticeImpl notice = _getNotice(source);
3997 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LIN E_INFO));
3998 } else {
3999 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownExceptio n);
4000 }
4001 } else {
4002 _logInformation2("Generated errors discarded for ${_debuggingString(source )}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn try.modificationTime}", thrownException);
4003 if (thrownException == null || resultTime >= 0) {
4004 //
4005 // The analysis was performed on out-of-date sources. Mark the cache so that the source
4006 // will be re-verified using the up-to-date sources.
4007 //
4008 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour ce, CacheState.INVALID);
4009 _removeFromParts(source, dartEntry);
4010 dartEntry.invalidateAllInformation();
4011 dartEntry.modificationTime = sourceTime;
4012 _cache.removedAst(source);
4013 _workManager.add(source, SourcePriority.UNKNOWN);
4014 } else {
4015 //
4016 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4017 // cache so that we won't attempt to re-verify the source until there's a good chance
4018 // that we'll be able to do so without error.
4019 //
4020 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownExceptio n);
4021 }
4022 }
4023 if (thrownException != null) { 3971 if (thrownException != null) {
3972 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownException) ;
4024 throw new AnalysisException('<rethrow>', thrownException); 3973 throw new AnalysisException('<rethrow>', thrownException);
4025 } 3974 }
3975 dartEntry.setValueInLibrary(
3976 DartEntry.VERIFICATION_ERRORS,
3977 librarySource,
3978 task.errors);
3979 ChangeNoticeImpl notice = _getNotice(source);
3980 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
3981 notice.setErrors(dartEntry.allErrors, lineInfo);
4026 return dartEntry; 3982 return dartEntry;
4027 } 3983 }
4028 3984
4029 /** 3985 /**
4030 * Record the results produced by performing a [GenerateDartHintsTask]. If the results were 3986 * Record the results produced by performing a [task] and return the cache
4031 * computed from data that is now out-of-date, then the results will not be re corded. 3987 * entry associated with the results.
4032 *
4033 * @param task the task that was performed
4034 * @return an entry containing the computed results
4035 * @throws AnalysisException if the results could not be recorded
4036 */ 3988 */
4037 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { 3989 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) {
4038 Source librarySource = task.libraryElement.source; 3990 Source librarySource = task.libraryElement.source;
4039 CaughtException thrownException = task.exception; 3991 CaughtException thrownException = task.exception;
4040 DartEntry libraryEntry = null; 3992 DartEntry libraryEntry = null;
4041 HashMap<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap ; 3993 HashMap<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap ;
4042 if (hintMap == null) { 3994 if (hintMap == null) {
4043 // We don't have any information about which sources to mark as invalid ot her than the library 3995 // We don't have any information about which sources to mark as invalid
4044 // source. 3996 // other than the library source.
4045 SourceEntry sourceEntry = _cache.get(librarySource); 3997 DartEntry libraryEntry = _cache.get(librarySource);
4046 if (sourceEntry == null) { 3998 if (thrownException == null) {
4047 throw new ObsoleteSourceAnalysisException(librarySource); 3999 String message = "GenerateDartHintsTask returned a null hint map "
4048 } else if (sourceEntry is! DartEntry) { 4000 "without throwing an exception: ${librarySource.fullName}";
4049 // This shouldn't be possible because we should never have performed the task if the source 4001 thrownException = new CaughtException(new AnalysisException(message), nu ll);
4050 // didn't represent a Dart file, but check to be safe.
4051 throw new AnalysisException("Internal error: attempting to generate hint s for non-Dart file as a Dart file: ${librarySource.fullName}");
4052 } 4002 }
4053 if (thrownException == null) { 4003 libraryEntry.recordHintErrorInLibrary(librarySource, thrownException);
4054 thrownException = new CaughtException(new AnalysisException("GenerateDar tHintsTask returned a null hint map without throwing an exception: ${librarySour ce.fullName}"), null);
4055 }
4056 (sourceEntry as DartEntry).recordHintErrorInLibrary(librarySource, thrownE xception);
4057 throw new AnalysisException('<rethrow>', thrownException); 4004 throw new AnalysisException('<rethrow>', thrownException);
4058 } 4005 }
4059 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 4006 hintMap.forEach((Source unitSource, TimestampedData<List<AnalysisError>> res ults) {
4060 Source unitSource = entry.getKey(); 4007 DartEntry dartEntry = _cache.get(unitSource);
4061 TimestampedData<List<AnalysisError>> results = entry.getValue();
4062 SourceEntry sourceEntry = _cache.get(unitSource);
4063 if (sourceEntry is! DartEntry) {
4064 // This shouldn't be possible because we should never have performed the task if the source
4065 // didn't represent a Dart file, but check to be safe.
4066 throw new AnalysisException("Internal error: attempting to parse non-Dar t file as a Dart file: ${unitSource.fullName}");
4067 }
4068 DartEntry dartEntry = sourceEntry;
4069 if (unitSource == librarySource) { 4008 if (unitSource == librarySource) {
4070 libraryEntry = dartEntry; 4009 libraryEntry = dartEntry;
4071 } 4010 }
4072 int sourceTime = getModificationStamp(unitSource); 4011 if (thrownException == null) {
4073 int resultTime = results.modificationTime; 4012 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, results.data );
4074 if (sourceTime == resultTime) { 4013 ChangeNoticeImpl notice = _getNotice(unitSource);
4075 if (dartEntry.modificationTime != sourceTime) { 4014 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4076 // The source has changed without the context being notified. Simulate notification. 4015 notice.setErrors(dartEntry.allErrors, lineInfo);
4077 _sourceChanged(unitSource);
4078 dartEntry = _getReadableDartEntry(unitSource);
4079 if (dartEntry == null) {
4080 throw new AnalysisException("A Dart file became a non-Dart file: ${u nitSource.fullName}");
4081 }
4082 }
4083 if (thrownException == null) {
4084 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, results.da ta);
4085 ChangeNoticeImpl notice = _getNotice(unitSource);
4086 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.L INE_INFO));
4087 } else {
4088 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4089 }
4090 } else { 4016 } else {
4091 _logInformation2("Generated hints discarded for ${_debuggingString(unitS ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d artEntry.modificationTime}", thrownException); 4017 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4092 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == Cache State.IN_PROCESS) {
4093 if (thrownException == null || resultTime >= 0) {
4094 //
4095 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4096 // will be re-analyzed using the up-to-date sources.
4097 //
4098 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca cheState.INVALID);
4099 _removeFromParts(unitSource, dartEntry);
4100 dartEntry.invalidateAllInformation();
4101 dartEntry.modificationTime = sourceTime;
4102 _cache.removedAst(unitSource);
4103 _workManager.add(unitSource, SourcePriority.UNKNOWN);
4104 } else {
4105 //
4106 // We could not determine whether the sources were up-to-date or out -of-date. Mark the
4107 // cache so that we won't attempt to re-analyze the sources until th ere's a good chance
4108 // that we'll be able to do so without error.
4109 //
4110 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4111 }
4112 }
4113 } 4018 }
4114 } 4019 });
4115 if (thrownException != null) { 4020 if (thrownException != null) {
4116 throw new AnalysisException('<rethrow>', thrownException); 4021 throw new AnalysisException('<rethrow>', thrownException);
4117 } 4022 }
4118 return libraryEntry; 4023 return libraryEntry;
4119 } 4024 }
4120 4025
4121 /** 4026 /**
4122 * Record the results produced by performing a [GetContentTask]. 4027 * Record the results produced by performing a [task] and return the cache
4123 * 4028 * entry associated with the results.
4124 * @param task the task that was performed
4125 * @return an entry containing the computed results
4126 * @throws AnalysisException if the results could not be recorded
4127 */ 4029 */
4128 SourceEntry _recordGetContentsTask(GetContentTask task) { 4030 SourceEntry _recordGetContentsTask(GetContentTask task) {
4129 if (!task.isComplete) { 4031 if (!task.isComplete) {
4130 return null; 4032 return null;
4131 } 4033 }
4132 Source source = task.source; 4034 Source source = task.source;
4035 SourceEntry sourceEntry = _cache.get(source);
4133 CaughtException thrownException = task.exception; 4036 CaughtException thrownException = task.exception;
4134 SourceEntry sourceEntry = _cache.get(source); 4037 if (thrownException != null) {
4135 if (sourceEntry == null) {
4136 throw new ObsoleteSourceAnalysisException(source);
4137 }
4138 if (thrownException == null) {
4139 sourceEntry.modificationTime = task.modificationTime;
4140 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4141 } else {
4142 sourceEntry.recordContentError(thrownException); 4038 sourceEntry.recordContentError(thrownException);
4143 _workManager.remove(source); 4039 _workManager.remove(source);
4144 }
4145 if (thrownException != null) {
4146 throw new AnalysisException('<rethrow>', thrownException); 4040 throw new AnalysisException('<rethrow>', thrownException);
4147 } 4041 }
4042 sourceEntry.modificationTime = task.modificationTime;
4043 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4148 return sourceEntry; 4044 return sourceEntry;
4149 } 4045 }
4150 4046
4151 /** 4047 /**
4152 * Record the results produced by performing a [IncrementalAnalysisTask]. 4048 * Record the results produced by performing a [IncrementalAnalysisTask].
4153 * 4049 *
4154 * @param task the task that was performed 4050 * @param task the task that was performed
4155 * @return an entry containing the computed results 4051 * @return an entry containing the computed results
4156 * @throws AnalysisException if the results could not be recorded 4052 * @throws AnalysisException if the results could not be recorded
4157 */ 4053 */
4158 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { 4054 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) {
4159 CompilationUnit unit = task.compilationUnit; 4055 CompilationUnit unit = task.compilationUnit;
4160 if (unit != null) { 4056 if (unit != null) {
4161 ChangeNoticeImpl notice = _getNotice(task.source); 4057 ChangeNoticeImpl notice = _getNotice(task.source);
4162 notice.compilationUnit = unit; 4058 notice.compilationUnit = unit;
4163 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach e, unit); 4059 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(
4060 task.cache,
4061 unit);
4164 } 4062 }
4165 return null; 4063 return null;
4166 } 4064 }
4167 4065
4168 /** 4066 /**
4169 * Record the results produced by performing a [ParseDartTask]. If the results were computed 4067 * Record the results produced by performing a [task] and return the cache
4170 * from data that is now out-of-date, then the results will not be recorded. 4068 * entry associated with the results.
4171 *
4172 * @param task the task that was performed
4173 * @return an entry containing the computed results
4174 * @throws AnalysisException if the results could not be recorded
4175 */ 4069 */
4176 DartEntry _recordParseDartTaskResults(ParseDartTask task) { 4070 DartEntry _recordParseDartTaskResults(ParseDartTask task) {
4177 Source source = task.source; 4071 Source source = task.source;
4178 CaughtException thrownException = task.exception; 4072 DartEntry dartEntry = _cache.get(source);
4179 SourceEntry sourceEntry = _cache.get(source); 4073 _removeFromParts(source, dartEntry);
4180 if (sourceEntry == null) { 4074 CaughtException thrownException = task.exception;
4181 throw new ObsoleteSourceAnalysisException(source); 4075 if (thrownException != null) {
4182 } else if (sourceEntry is! DartEntry) { 4076 _removeFromParts(source, dartEntry);
4183 // This shouldn't be possible because we should never have performed the t ask if the source 4077 dartEntry.recordParseError(thrownException);
4184 // didn't represent a Dart file, but check to be safe. 4078 _cache.removedAst(source);
4185 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4079 throw new AnalysisException('<rethrow>', thrownException);
4186 } 4080 }
4187 DartEntry dartEntry = sourceEntry as DartEntry; 4081 if (task.hasNonPartOfDirective) {
4188 int sourceTime = getModificationStamp(source); 4082 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4189 int resultTime = task.modificationTime; 4083 dartEntry.containingLibrary = source;
4190 if (sourceTime == resultTime) { 4084 _workManager.add(source, SourcePriority.LIBRARY);
4191 if (dartEntry.modificationTime != sourceTime) { 4085 } else if (task.hasPartOfDirective) {
4192 // The source has changed without the context being notified. Simulate n otification. 4086 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4193 _sourceChanged(source); 4087 dartEntry.removeContainingLibrary(source);
4194 dartEntry = _getReadableDartEntry(source); 4088 _workManager.add(source, SourcePriority.NORMAL_PART);
4195 if (dartEntry == null) { 4089 } else {
4196 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4090 // The file contains no directives.
4197 } 4091 List<Source> containingLibraries = dartEntry.containingLibraries;
4092 if (containingLibraries.length > 1
4093 || (containingLibraries.length == 1
4094 && containingLibraries[0] != source)) {
4095 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4096 dartEntry.removeContainingLibrary(source);
4097 _workManager.add(source, SourcePriority.NORMAL_PART);
4098 } else {
4099 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4100 dartEntry.containingLibrary = source;
4101 _workManager.add(source, SourcePriority.LIBRARY);
4198 } 4102 }
4199 _removeFromParts(source, dartEntry); 4103 }
4200 if (thrownException == null) { 4104 List<Source> newParts = task.includedSources;
4201 if (task.hasNonPartOfDirective) { 4105 for (int i = 0; i < newParts.length; i++) {
4202 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 4106 Source partSource = newParts[i];
4203 dartEntry.containingLibrary = source; 4107 DartEntry partEntry = _getReadableDartEntry(partSource);
4204 _workManager.add(source, SourcePriority.LIBRARY); 4108 if (partEntry != null && !identical(partEntry, dartEntry)) {
4205 } else if (task.hasPartOfDirective) { 4109 // TODO(brianwilkerson) Change the kind of the "part" if it was marked
4206 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); 4110 // as a library and it has no directives.
4207 dartEntry.removeContainingLibrary(source); 4111 partEntry.addContainingLibrary(source);
4208 _workManager.add(source, SourcePriority.NORMAL_PART);
4209 } else {
4210 // The file contains no directives.
4211 List<Source> containingLibraries = dartEntry.containingLibraries;
4212 if (containingLibraries.length > 1 || (containingLibraries.length == 1 && containingLibraries[0] != source)) {
4213 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4214 dartEntry.removeContainingLibrary(source);
4215 _workManager.add(source, SourcePriority.NORMAL_PART);
4216 } else {
4217 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4218 dartEntry.containingLibrary = source;
4219 _workManager.add(source, SourcePriority.LIBRARY);
4220 }
4221 }
4222 List<Source> newParts = task.includedSources;
4223 for (int i = 0; i < newParts.length; i++) {
4224 Source partSource = newParts[i];
4225 DartEntry partEntry = _getReadableDartEntry(partSource);
4226 if (partEntry != null && !identical(partEntry, dartEntry)) {
4227 // TODO(brianwilkerson) Change the kind of the "part" if it was mark ed as a library
4228 // and it has no directives.
4229 partEntry.addContainingLibrary(source);
4230 }
4231 }
4232 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4233 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors);
4234 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4235 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
4236 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts);
4237 _cache.storedAst(source);
4238 ChangeNoticeImpl notice = _getNotice(source);
4239 notice.setErrors(dartEntry.allErrors, task.lineInfo);
4240 // Verify that the incrementally parsed and resolved unit in the increme ntal cache
4241 // is structurally equivalent to the fully parsed unit
4242 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in crementalAnalysisCache, source, task.compilationUnit);
4243 } else {
4244 _removeFromParts(source, dartEntry);
4245 dartEntry.recordParseError(thrownException);
4246 _cache.removedAst(source);
4247 } 4112 }
4248 } else { 4113 }
4249 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry .modificationTime}", thrownException); 4114 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4250 if (thrownException == null || resultTime >= 0) { 4115 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors);
4251 // 4116 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4252 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4117 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
4253 // will be re-analyzed using the up-to-date sources. 4118 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts);
4254 // 4119 _cache.storedAst(source);
4255 // dartCopy.recordParseNotInProcess(); 4120 ChangeNoticeImpl notice = _getNotice(source);
4256 _removeFromParts(source, dartEntry); 4121 notice.setErrors(dartEntry.allErrors, task.lineInfo);
4257 dartEntry.invalidateAllInformation(); 4122 // Verify that the incrementally parsed and resolved unit in the incremental
4258 dartEntry.modificationTime = sourceTime; 4123 // cache is structurally equivalent to the fully parsed unit
4259 _cache.removedAst(source); 4124 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(
4260 _workManager.add(source, SourcePriority.UNKNOWN); 4125 _incrementalAnalysisCache,
4261 } else { 4126 source,
4262 // 4127 task.compilationUnit);
4263 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4264 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4265 // that we'll be able to do so without error.
4266 //
4267 dartEntry.recordParseError(thrownException);
4268 }
4269 }
4270 if (thrownException != null) {
4271 throw new AnalysisException('<rethrow>', thrownException);
4272 }
4273 return dartEntry; 4128 return dartEntry;
4274 } 4129 }
4275 4130
4276 /** 4131 /**
4277 * Record the results produced by performing a [ParseHtmlTask]. If the results were computed 4132 * Record the results produced by performing a [task] and return the cache
4278 * from data that is now out-of-date, then the results will not be recorded. 4133 * entry associated with the results.
4279 *
4280 * @param task the task that was performed
4281 * @return an entry containing the computed results
4282 * @throws AnalysisException if the results could not be recorded
4283 */ 4134 */
4284 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) { 4135 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) {
4285 Source source = task.source; 4136 Source source = task.source;
4286 CaughtException thrownException = task.exception; 4137 HtmlEntry htmlEntry = _cache.get(source);
4287 SourceEntry sourceEntry = _cache.get(source); 4138 CaughtException thrownException = task.exception;
4288 if (sourceEntry == null) { 4139 if (thrownException != null) {
4289 throw new ObsoleteSourceAnalysisException(source); 4140 htmlEntry.recordParseError(thrownException);
4290 } else if (sourceEntry is! HtmlEntry) { 4141 _cache.removedAst(source);
4291 // This shouldn't be possible because we should never have performed the t ask if the source 4142 throw new AnalysisException('<rethrow>', thrownException);
4292 // didn't represent an HTML file, but check to be safe. 4143 }
4293 throw new AnalysisException("Internal error: attempting to parse non-HTML file as a HTML file: ${source.fullName}"); 4144 LineInfo lineInfo = task.lineInfo;
4294 } 4145 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4295 HtmlEntry htmlEntry = sourceEntry; 4146 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, task.htmlUnit);
4296 int sourceTime = getModificationStamp(source); 4147 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors);
4297 int resultTime = task.modificationTime; 4148 htmlEntry.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibraries) ;
4298 if (sourceTime == resultTime) { 4149 _cache.storedAst(source);
4299 if (htmlEntry.modificationTime != sourceTime) { 4150 ChangeNoticeImpl notice = _getNotice(source);
4300 // The source has changed without the context being notified. Simulate n otification. 4151 notice.setErrors(htmlEntry.allErrors, lineInfo);
4301 _sourceChanged(source); 4152 return htmlEntry;
4302 htmlEntry = _getReadableHtmlEntry(source); 4153 }
4303 if (htmlEntry == null) { 4154
4304 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4155 /**
4305 } 4156 * Record the results produced by performing a [task] and return the cache
4306 } 4157 * entry associated with the results.
4307 if (thrownException == null) {
4308 LineInfo lineInfo = task.lineInfo;
4309 ht.HtmlUnit unit = task.htmlUnit;
4310 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4311 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, unit);
4312 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors);
4313 htmlEntry.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrar ies);
4314 _cache.storedAst(source);
4315 ChangeNoticeImpl notice = _getNotice(source);
4316 notice.setErrors(htmlEntry.allErrors, lineInfo);
4317 } else {
4318 htmlEntry.recordParseError(thrownException);
4319 _cache.removedAst(source);
4320 }
4321 } else {
4322 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException);
4323 if (thrownException == null || resultTime >= 0) {
4324 //
4325 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4326 // will be re-analyzed using the up-to-date sources.
4327 //
4328 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I N_PROCESS) {
4329 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI D);
4330 // }
4331 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I N_PROCESS) {
4332 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALI D);
4333 // }
4334 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == Cac heState.IN_PROCESS) {
4335 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheSta te.INVALID);
4336 // }
4337 htmlEntry.invalidateAllInformation();
4338 htmlEntry.modificationTime = sourceTime;
4339 _cache.removedAst(source);
4340 } else {
4341 //
4342 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4343 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4344 // that we'll be able to do so without error.
4345 //
4346 htmlEntry.recordParseError(thrownException);
4347 }
4348 }
4349 if (thrownException != null) {
4350 throw new AnalysisException('<rethrow>', thrownException);
4351 }
4352 return htmlEntry;
4353 }
4354
4355 /**
4356 * Record the results produced by performing a [PolymerBuildHtmlTask]. If the results were
4357 * computed from data that is now out-of-date, then the results will not be re corded.
4358 *
4359 * @param task the task that was performed
4360 * @throws AnalysisException if the results could not be recorded
4361 */ 4158 */
4362 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) { 4159 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) {
4363 Source source = task.source; 4160 Source source = task.source;
4364 CaughtException thrownException = task.exception; 4161 HtmlEntry htmlEntry = _cache.get(source);
4365 SourceEntry sourceEntry = _cache.get(source); 4162 CaughtException thrownException = task.exception;
4366 if (sourceEntry == null) { 4163 if (thrownException != null) {
4367 throw new ObsoleteSourceAnalysisException(source); 4164 htmlEntry.recordResolutionError(thrownException);
4368 } else if (sourceEntry is! HtmlEntry) { 4165 throw new AnalysisException('<rethrow>', thrownException);
4369 // This shouldn't be possible because we should never have performed the t ask if the source 4166 }
4370 // didn't represent an HTML file, but check to be safe. 4167 htmlEntry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors);
4371 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4168 // notify about errors
4372 } 4169 ChangeNoticeImpl notice = _getNotice(source);
4373 HtmlEntry htmlEntry = sourceEntry; 4170 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4374 int sourceTime = getModificationStamp(source); 4171 notice.setErrors(htmlEntry.allErrors, lineInfo);
4375 int resultTime = task.modificationTime; 4172 return htmlEntry;
4376 if (sourceTime == resultTime) { 4173 }
4377 if (htmlEntry.modificationTime != sourceTime) { 4174
4378 // The source has changed without the context being notified. Simulate n otification. 4175 /**
4379 _sourceChanged(source); 4176 * Record the results produced by performing a [task] and return the cache
4380 htmlEntry = _getReadableHtmlEntry(source); 4177 * entry associated with the results.
4381 if (htmlEntry == null) {
4382 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4383 }
4384 }
4385 if (thrownException == null) {
4386 htmlEntry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors);
4387 // notify about errors
4388 ChangeNoticeImpl notice = _getNotice(source);
4389 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4390 } else {
4391 htmlEntry.recordResolutionError(thrownException);
4392 }
4393 } else {
4394 if (thrownException == null || resultTime >= 0) {
4395 //
4396 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4397 // will be re-analyzed using the up-to-date sources.
4398 //
4399 htmlEntry.invalidateAllInformation();
4400 htmlEntry.modificationTime = sourceTime;
4401 _cache.removedAst(source);
4402 } else {
4403 //
4404 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4405 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4406 // that we'll be able to do so without error.
4407 //
4408 htmlEntry.recordResolutionError(thrownException);
4409 }
4410 }
4411 if (thrownException != null) {
4412 throw new AnalysisException('<rethrow>', thrownException);
4413 }
4414 return htmlEntry;
4415 }
4416
4417 /**
4418 * Record the results produced by performing a [PolymerResolveHtmlTask]. If th e results were
4419 * computed from data that is now out-of-date, then the results will not be re corded.
4420 *
4421 * @param task the task that was performed
4422 * @throws AnalysisException if the results could not be recorded
4423 */ 4178 */
4424 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) { 4179 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) {
4425 Source source = task.source; 4180 Source source = task.source;
4426 CaughtException thrownException = task.exception; 4181 HtmlEntry htmlEntry = _cache.get(source);
4427 SourceEntry sourceEntry = _cache.get(source); 4182 CaughtException thrownException = task.exception;
4428 if (sourceEntry == null) { 4183 if (thrownException != null) {
4429 throw new ObsoleteSourceAnalysisException(source); 4184 htmlEntry.recordResolutionError(thrownException);
4430 } else if (sourceEntry is! HtmlEntry) { 4185 throw new AnalysisException('<rethrow>', thrownException);
4431 // This shouldn't be possible because we should never have performed the t ask if the source 4186 }
4432 // didn't represent an HTML file, but check to be safe. 4187 htmlEntry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors);
4433 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4188 // notify about errors
4434 } 4189 ChangeNoticeImpl notice = _getNotice(source);
4435 HtmlEntry htmlEntry = sourceEntry; 4190 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4436 int sourceTime = getModificationStamp(source); 4191 notice.setErrors(htmlEntry.allErrors, lineInfo);
4437 int resultTime = task.modificationTime; 4192 return htmlEntry;
4438 if (sourceTime == resultTime) { 4193 }
4439 if (htmlEntry.modificationTime != sourceTime) { 4194
4440 // The source has changed without the context being notified. Simulate n otification. 4195 /**
4441 _sourceChanged(source); 4196 * Record the results produced by performing a [task] and return the cache
4442 htmlEntry = _getReadableHtmlEntry(source); 4197 * entry associated with the results.
4443 if (htmlEntry == null) {
4444 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4445 }
4446 }
4447 if (thrownException == null) {
4448 htmlEntry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors);
4449 // notify about errors
4450 ChangeNoticeImpl notice = _getNotice(source);
4451 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4452 } else {
4453 htmlEntry.recordResolutionError(thrownException);
4454 }
4455 } else {
4456 if (thrownException == null || resultTime >= 0) {
4457 //
4458 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4459 // will be re-analyzed using the up-to-date sources.
4460 //
4461 htmlEntry.invalidateAllInformation();
4462 htmlEntry.modificationTime = sourceTime;
4463 _cache.removedAst(source);
4464 } else {
4465 //
4466 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4467 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4468 // that we'll be able to do so without error.
4469 //
4470 htmlEntry.recordResolutionError(thrownException);
4471 }
4472 }
4473 if (thrownException != null) {
4474 throw new AnalysisException('<rethrow>', thrownException);
4475 }
4476 return htmlEntry;
4477 }
4478
4479 /**
4480 * Record the results produced by performing a [ResolveAngularComponentTemplat eTask]. If the
4481 * results were computed from data that is now out-of-date, then the results w ill not be recorded.
4482 *
4483 * @param task the task that was performed
4484 * @throws AnalysisException if the results could not be recorded
4485 */ 4198 */
4486 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) { 4199 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) {
4487 Source source = task.source; 4200 Source source = task.source;
4488 CaughtException thrownException = task.exception; 4201 HtmlEntry htmlEntry = _cache.get(source);
4489 SourceEntry sourceEntry = _cache.get(source); 4202 CaughtException thrownException = task.exception;
4490 if (sourceEntry == null) { 4203 if (thrownException != null) {
4491 throw new ObsoleteSourceAnalysisException(source); 4204 htmlEntry.recordResolutionError(thrownException);
4492 } else if (sourceEntry is! HtmlEntry) { 4205 throw new AnalysisException('<rethrow>', thrownException);
4493 // This shouldn't be possible because we should never have performed the t ask if the source 4206 }
4494 // didn't represent an HTML file, but check to be safe. 4207 htmlEntry.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
4495 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4208 // notify about errors
4496 } 4209 ChangeNoticeImpl notice = _getNotice(source);
4497 HtmlEntry htmlEntry = sourceEntry; 4210 notice.htmlUnit = task.resolvedUnit;
4498 int sourceTime = getModificationStamp(source); 4211 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4499 int resultTime = task.modificationTime; 4212 notice.setErrors(htmlEntry.allErrors, lineInfo);
4500 if (sourceTime == resultTime) { 4213 return htmlEntry;
4501 if (htmlEntry.modificationTime != sourceTime) { 4214 }
4502 // The source has changed without the context being notified. Simulate n otification. 4215
4503 _sourceChanged(source); 4216 /**
4504 htmlEntry = _getReadableHtmlEntry(source); 4217 * Record the results produced by performing a [task] and return the cache
4505 if (htmlEntry == null) { 4218 * entry associated with the results.
4506 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4507 }
4508 }
4509 if (thrownException == null) {
4510 htmlEntry.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
4511 // notify about errors
4512 ChangeNoticeImpl notice = _getNotice(source);
4513 notice.htmlUnit = task.resolvedUnit;
4514 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4515 } else {
4516 htmlEntry.recordResolutionError(thrownException);
4517 }
4518 } else {
4519 if (thrownException == null || resultTime >= 0) {
4520 //
4521 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4522 // will be re-analyzed using the up-to-date sources.
4523 //
4524 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
4525 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
4526 // }
4527 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4528 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4529 // }
4530 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4531 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4532 // }
4533 htmlEntry.invalidateAllInformation();
4534 htmlEntry.modificationTime = sourceTime;
4535 _cache.removedAst(source);
4536 } else {
4537 //
4538 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4539 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4540 // that we'll be able to do so without error.
4541 //
4542 htmlEntry.recordResolutionError(thrownException);
4543 }
4544 }
4545 if (thrownException != null) {
4546 throw new AnalysisException('<rethrow>', thrownException);
4547 }
4548 return htmlEntry;
4549 }
4550
4551 /**
4552 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results
4553 * were computed from data that is now out-of-date, then the results will not be recorded.
4554 *
4555 * @param task the task that was performed
4556 * @throws AnalysisException if the results could not be recorded
4557 */ 4219 */
4558 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) { 4220 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) {
4559 Source source = task.source; 4221 Source source = task.source;
4560 CaughtException thrownException = task.exception; 4222 HtmlEntry htmlEntry = _cache.get(source);
4561 SourceEntry sourceEntry = _cache.get(source); 4223 CaughtException thrownException = task.exception;
4562 if (sourceEntry == null) { 4224 if (thrownException != null) {
4563 throw new ObsoleteSourceAnalysisException(source); 4225 htmlEntry.recordResolutionError(thrownException);
4564 } else if (sourceEntry is! HtmlEntry) { 4226 throw new AnalysisException('<rethrow>', thrownException);
4565 // This shouldn't be possible because we should never have performed the t ask if the source 4227 }
4566 // didn't represent an HTML file, but check to be safe. 4228 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4567 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4229 _recordAngularEntryPoint(htmlEntry, task);
4568 } 4230 _cache.storedAst(source);
4569 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 4231 ChangeNoticeImpl notice = _getNotice(source);
4570 int sourceTime = getModificationStamp(source); 4232 notice.htmlUnit = task.resolvedUnit;
4571 int resultTime = task.modificationTime; 4233 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4572 if (sourceTime == resultTime) { 4234 notice.setErrors(htmlEntry.allErrors, lineInfo);
4573 if (htmlEntry.modificationTime != sourceTime) { 4235 return htmlEntry;
4574 // The source has changed without the context being notified. Simulate n otification. 4236 }
4575 _sourceChanged(source); 4237
4576 htmlEntry = _getReadableHtmlEntry(source); 4238 /**
4577 if (htmlEntry == null) { 4239 * Record the results produced by performing a [task] and return the cache
4578 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4240 * entry associated with the results.
4579 }
4580 }
4581 if (thrownException == null) {
4582 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4583 _recordAngularEntryPoint(htmlEntry, task);
4584 _cache.storedAst(source);
4585 ChangeNoticeImpl notice = _getNotice(source);
4586 notice.htmlUnit = task.resolvedUnit;
4587 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4588 } else {
4589 htmlEntry.recordResolutionError(thrownException);
4590 }
4591 } else {
4592 if (thrownException == null || resultTime >= 0) {
4593 //
4594 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4595 // will be re-analyzed using the up-to-date sources.
4596 //
4597 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
4598 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
4599 // }
4600 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4601 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4602 // }
4603 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4604 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4605 // }
4606 htmlEntry.invalidateAllInformation();
4607 htmlEntry.modificationTime = sourceTime;
4608 _cache.removedAst(source);
4609 } else {
4610 //
4611 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4612 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4613 // that we'll be able to do so without error.
4614 //
4615 htmlEntry.recordResolutionError(thrownException);
4616 }
4617 }
4618 if (thrownException != null) {
4619 throw new AnalysisException('<rethrow>', thrownException);
4620 }
4621 return htmlEntry;
4622 }
4623
4624 /**
4625 * Record the results produced by performing a [ResolveDartUnitTask]. If the r esults were
4626 * computed from data that is now out-of-date, then the results will not be re corded.
4627 *
4628 * @param task the task that was performed
4629 * @return an entry containing the computed results
4630 * @throws AnalysisException if the results could not be recorded
4631 */ 4241 */
4632 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { 4242 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) {
4633 Source unitSource = task.source; 4243 Source unitSource = task.source;
4244 DartEntry dartEntry = _cache.get(unitSource);
4634 Source librarySource = task.librarySource; 4245 Source librarySource = task.librarySource;
4635 CaughtException thrownException = task.exception; 4246 CaughtException thrownException = task.exception;
4636 SourceEntry sourceEntry = _cache.get(unitSource); 4247 if (thrownException != null) {
4637 if (sourceEntry == null) { 4248 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException);
4638 throw new ObsoleteSourceAnalysisException(unitSource); 4249 _cache.removedAst(unitSource);
4639 } else if (sourceEntry is! DartEntry) { 4250 throw new AnalysisException('<rethrow>', thrownException);
4640 // This shouldn't be possible because we should never have performed the t ask if the source 4251 }
4641 // didn't represent a Dart file, but check to be safe. 4252 dartEntry.setValueInLibrary(
4642 throw new AnalysisException("Internal error: attempting to resolve non-Dar t file as a Dart file: ${unitSource.fullName}"); 4253 DartEntry.RESOLVED_UNIT,
4643 } 4254 librarySource,
4644 DartEntry dartEntry = sourceEntry as DartEntry; 4255 task.resolvedUnit);
4645 int sourceTime = getModificationStamp(unitSource); 4256 _cache.storedAst(unitSource);
4646 int resultTime = task.modificationTime;
4647 if (sourceTime == resultTime) {
4648 if (dartEntry.modificationTime != sourceTime) {
4649 // The source has changed without the context being notified. Simulate n otification.
4650 _sourceChanged(unitSource);
4651 dartEntry = _getReadableDartEntry(unitSource);
4652 if (dartEntry == null) {
4653 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
4654 }
4655 }
4656 if (thrownException == null) {
4657 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task .resolvedUnit);
4658 _cache.storedAst(unitSource);
4659 } else {
4660 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException) ;
4661 _cache.removedAst(unitSource);
4662 }
4663 } else {
4664 _logInformation2("Resolution results discarded for ${_debuggingString(unit Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${ dartEntry.modificationTime}", thrownException);
4665 if (thrownException == null || resultTime >= 0) {
4666 //
4667 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4668 // will be re-analyzed using the up-to-date sources.
4669 //
4670 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState .IN_PROCESS) {
4671 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource, CacheState.INVALID);
4672 // }
4673 _removeFromParts(unitSource, dartEntry);
4674 dartEntry.invalidateAllInformation();
4675 dartEntry.modificationTime = sourceTime;
4676 _cache.removedAst(unitSource);
4677 _workManager.add(unitSource, SourcePriority.UNKNOWN);
4678 } else {
4679 //
4680 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4681 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4682 // that we'll be able to do so without error.
4683 //
4684 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException) ;
4685 }
4686 }
4687 if (thrownException != null) {
4688 throw new AnalysisException('<rethrow>', thrownException);
4689 }
4690 return dartEntry; 4257 return dartEntry;
4691 } 4258 }
4692 4259
4693 /** 4260 /**
4694 * Record the results produced by performing a [ResolveHtmlTask]. If the resul ts were 4261 * Record the results produced by performing a [task] and return the cache
4695 * computed from data that is now out-of-date, then the results will not be re corded. 4262 * entry associated with the results.
4696 *
4697 * @param task the task that was performed
4698 * @return an entry containing the computed results
4699 * @throws AnalysisException if the results could not be recorded
4700 */ 4263 */
4701 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { 4264 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) {
4702 Source source = task.source; 4265 Source source = task.source;
4703 CaughtException thrownException = task.exception; 4266 HtmlEntry htmlEntry = _cache.get(source);
4704 SourceEntry sourceEntry = _cache.get(source); 4267 CaughtException thrownException = task.exception;
4705 if (sourceEntry == null) { 4268 if (thrownException != null) {
4706 throw new ObsoleteSourceAnalysisException(source); 4269 htmlEntry.recordResolutionError(thrownException);
4707 } else if (sourceEntry is! HtmlEntry) { 4270 _cache.removedAst(source);
4708 // This shouldn't be possible because we should never have performed the t ask if the source 4271 throw new AnalysisException('<rethrow>', thrownException);
4709 // didn't represent an HTML file, but check to be safe. 4272 }
4710 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4273 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
4711 } 4274 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4712 HtmlEntry htmlEntry = sourceEntry; 4275 htmlEntry.setValue(HtmlEntry.ELEMENT, task.element);
4713 int sourceTime = getModificationStamp(source); 4276 htmlEntry.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors);
4714 int resultTime = task.modificationTime; 4277 _cache.storedAst(source);
4715 if (sourceTime == resultTime) { 4278 ChangeNoticeImpl notice = _getNotice(source);
4716 if (htmlEntry.modificationTime != sourceTime) { 4279 notice.htmlUnit = task.resolvedUnit;
4717 // The source has changed without the context being notified. Simulate n otification. 4280 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4718 _sourceChanged(source); 4281 notice.setErrors(htmlEntry.allErrors, lineInfo);
4719 htmlEntry = _getReadableHtmlEntry(source); 4282 return htmlEntry;
4720 if (htmlEntry == null) { 4283 }
4721 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4284
4722 } 4285 /**
4723 } 4286 * Record the results produced by performing a [task] and return the cache
4724 if (thrownException == null) { 4287 * entry associated with the results.
4725 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
4726 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4727 htmlEntry.setValue(HtmlEntry.ELEMENT, task.element);
4728 htmlEntry.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors);
4729 _cache.storedAst(source);
4730 ChangeNoticeImpl notice = _getNotice(source);
4731 notice.htmlUnit = task.resolvedUnit;
4732 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4733 } else {
4734 htmlEntry.recordResolutionError(thrownException);
4735 _cache.removedAst(source);
4736 }
4737 } else {
4738 _logInformation2("Resolution results discarded for ${_debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException);
4739 if (thrownException == null || resultTime >= 0) {
4740 //
4741 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4742 // will be re-analyzed using the up-to-date sources.
4743 //
4744 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4745 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4746 // }
4747 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4748 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4749 // }
4750 htmlEntry.invalidateAllInformation();
4751 htmlEntry.modificationTime = sourceTime;
4752 _cache.removedAst(source);
4753 } else {
4754 //
4755 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4756 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4757 // that we'll be able to do so without error.
4758 //
4759 htmlEntry.recordResolutionError(thrownException);
4760 }
4761 }
4762 if (thrownException != null) {
4763 throw new AnalysisException('<rethrow>', thrownException);
4764 }
4765 return htmlEntry;
4766 }
4767
4768 /**
4769 * Record the results produced by performing a [ScanDartTask]. If the results were computed
4770 * from data that is now out-of-date, then the results will not be recorded.
4771 *
4772 * @param task the task that was performed
4773 * @return an entry containing the computed results
4774 * @throws AnalysisException if the results could not be recorded
4775 */ 4288 */
4776 DartEntry _recordScanDartTaskResults(ScanDartTask task) { 4289 DartEntry _recordScanDartTaskResults(ScanDartTask task) {
4777 Source source = task.source; 4290 Source source = task.source;
4778 CaughtException thrownException = task.exception; 4291 DartEntry dartEntry = _cache.get(source);
4779 SourceEntry sourceEntry = _cache.get(source); 4292 CaughtException thrownException = task.exception;
4780 if (sourceEntry == null) { 4293 if (thrownException != null) {
4781 throw new ObsoleteSourceAnalysisException(source); 4294 _removeFromParts(source, dartEntry);
4782 } else if (sourceEntry is! DartEntry) { 4295 dartEntry.recordScanError(thrownException);
4783 // This shouldn't be possible because we should never have performed the t ask if the source 4296 _cache.removedAst(source);
4784 // didn't represent a Dart file, but check to be safe. 4297 throw new AnalysisException('<rethrow>', thrownException);
4785 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4298 }
4786 } 4299 LineInfo lineInfo = task.lineInfo;
4787 DartEntry dartEntry = sourceEntry; 4300 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4788 int sourceTime = getModificationStamp(source); 4301 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream);
4789 int resultTime = task.modificationTime; 4302 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors);
4790 if (sourceTime == resultTime) { 4303 _cache.storedAst(source);
4791 if (dartEntry.modificationTime != sourceTime) { 4304 ChangeNoticeImpl notice = _getNotice(source);
4792 // The source has changed without the context being notified. Simulate n otification. 4305 notice.setErrors(dartEntry.allErrors, lineInfo);
4793 _sourceChanged(source);
4794 dartEntry = _getReadableDartEntry(source);
4795 if (dartEntry == null) {
4796 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
4797 }
4798 }
4799 if (thrownException == null) {
4800 LineInfo lineInfo = task.lineInfo;
4801 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4802 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream);
4803 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors);
4804 _cache.storedAst(source);
4805 ChangeNoticeImpl notice = _getNotice(source);
4806 notice.setErrors(dartEntry.allErrors, lineInfo);
4807 } else {
4808 _removeFromParts(source, dartEntry);
4809 dartEntry.recordScanError(thrownException);
4810 _cache.removedAst(source);
4811 }
4812 } else {
4813 _logInformation2("Scan results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry. modificationTime}", thrownException);
4814 if (thrownException == null || resultTime >= 0) {
4815 //
4816 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4817 // will be re-analyzed using the up-to-date sources.
4818 //
4819 // dartCopy.recordScanNotInProcess();
4820 _removeFromParts(source, dartEntry);
4821 dartEntry.invalidateAllInformation();
4822 dartEntry.modificationTime = sourceTime;
4823 _cache.removedAst(source);
4824 _workManager.add(source, SourcePriority.UNKNOWN);
4825 } else {
4826 //
4827 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4828 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4829 // that we'll be able to do so without error.
4830 //
4831 dartEntry.recordScanError(thrownException);
4832 }
4833 }
4834 if (thrownException != null) {
4835 throw new AnalysisException('<rethrow>', thrownException);
4836 }
4837 return dartEntry; 4306 return dartEntry;
4838 } 4307 }
4839 4308
4840 /** 4309 /**
4841 * Remove the given library from the list of containing libraries for all of t he parts referenced 4310 * Remove the given library from the list of containing libraries for all of t he parts referenced
4842 * by the given entry. 4311 * by the given entry.
4843 * 4312 *
4844 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4313 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4845 * 4314 *
4846 * @param librarySource the library to be removed 4315 * @param librarySource the library to be removed
(...skipping 10307 matching lines...) Expand 10 before | Expand all | Expand 10 after
15154 _index++; 14623 _index++;
15155 if (_index >= _manager._workQueues[_queueIndex].length) { 14624 if (_index >= _manager._workQueues[_queueIndex].length) {
15156 _index = 0; 14625 _index = 0;
15157 _queueIndex++; 14626 _queueIndex++;
15158 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) { 14627 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) {
15159 _queueIndex++; 14628 _queueIndex++;
15160 } 14629 }
15161 } 14630 }
15162 } 14631 }
15163 } 14632 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698