| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library analyzer.src.task.dart_work_manager; | 5 library analyzer.src.task.dart_work_manager; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart' | 10 import 'package:analyzer/src/generated/engine.dart' |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 SourceKind kind = outputs[SOURCE_KIND]; | 221 SourceKind kind = outputs[SOURCE_KIND]; |
| 222 if (kind != null) { | 222 if (kind != null) { |
| 223 unknownSourceQueue.remove(target); | 223 unknownSourceQueue.remove(target); |
| 224 if (kind == SourceKind.LIBRARY) { | 224 if (kind == SourceKind.LIBRARY) { |
| 225 librarySourceQueue.add(target); | 225 librarySourceQueue.add(target); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 // Update notice. | 229 // Update notice. |
| 230 if (_isDartSource(target)) { | 230 if (_isDartSource(target)) { |
| 231 bool hasErrorResult = false; | 231 bool shouldSetErrors = false; |
| 232 outputs.forEach((ResultDescriptor descriptor, value) { | 232 outputs.forEach((ResultDescriptor descriptor, value) { |
| 233 if (descriptor == PARSED_UNIT && value != null) { | 233 if (descriptor == PARSED_UNIT && value != null) { |
| 234 context.getNotice(target).parsedDartUnit = value; | 234 context.getNotice(target).parsedDartUnit = value; |
| 235 shouldSetErrors = true; |
| 235 } | 236 } |
| 236 hasErrorResult = hasErrorResult || _isErrorResult(descriptor); | 237 if (_isErrorResult(descriptor)) { |
| 238 shouldSetErrors = true; |
| 239 } |
| 237 }); | 240 }); |
| 238 if (hasErrorResult) { | 241 if (shouldSetErrors) { |
| 239 AnalysisErrorInfo info = getErrors(target); | 242 AnalysisErrorInfo info = getErrors(target); |
| 240 context.getNotice(target).setErrors(info.errors, info.lineInfo); | 243 context.getNotice(target).setErrors(info.errors, info.lineInfo); |
| 241 } | 244 } |
| 242 } | 245 } |
| 243 if (target is LibrarySpecificUnit) { | 246 if (target is LibrarySpecificUnit) { |
| 244 Source source = target.source; | 247 Source source = target.source; |
| 245 bool hasErrorResult = false; | 248 bool shouldSetErrors = false; |
| 246 outputs.forEach((ResultDescriptor descriptor, value) { | 249 outputs.forEach((ResultDescriptor descriptor, value) { |
| 247 if (descriptor == RESOLVED_UNIT && value != null) { | 250 if (descriptor == RESOLVED_UNIT && value != null) { |
| 248 context.getNotice(source).resolvedDartUnit = value; | 251 context.getNotice(source).resolvedDartUnit = value; |
| 252 shouldSetErrors = true; |
| 249 } | 253 } |
| 250 hasErrorResult = hasErrorResult || _isErrorResult(descriptor); | 254 if (_isErrorResult(descriptor)) { |
| 255 shouldSetErrors = true; |
| 256 } |
| 251 }); | 257 }); |
| 252 if (hasErrorResult) { | 258 if (shouldSetErrors) { |
| 253 AnalysisErrorInfo info = getErrors(source); | 259 AnalysisErrorInfo info = getErrors(source); |
| 254 context.getNotice(source).setErrors(info.errors, info.lineInfo); | 260 context.getNotice(source).setErrors(info.errors, info.lineInfo); |
| 255 } | 261 } |
| 256 } | 262 } |
| 257 } | 263 } |
| 258 | 264 |
| 259 /** | 265 /** |
| 260 * Returns `true` if the given [result] of the given [target] needs | 266 * Returns `true` if the given [result] of the given [target] needs |
| 261 * computing, i.e. it is not in the valid and not in the error state. | 267 * computing, i.e. it is not in the valid and not in the error state. |
| 262 */ | 268 */ |
| 263 bool _needsComputing(AnalysisTarget target, ResultDescriptor result) { | 269 bool _needsComputing(AnalysisTarget target, ResultDescriptor result) { |
| 264 CacheState state = analysisCache.getState(target, result); | 270 CacheState state = analysisCache.getState(target, result); |
| 265 return state != CacheState.VALID && state != CacheState.ERROR; | 271 return state != CacheState.VALID && state != CacheState.ERROR; |
| 266 } | 272 } |
| 267 | 273 |
| 268 static bool _isDartSource(AnalysisTarget target) { | 274 static bool _isDartSource(AnalysisTarget target) { |
| 269 return target is Source && AnalysisEngine.isDartFileName(target.fullName); | 275 return target is Source && AnalysisEngine.isDartFileName(target.fullName); |
| 270 } | 276 } |
| 271 | 277 |
| 272 static bool _isErrorResult(ResultDescriptor descriptor) { | 278 static bool _isErrorResult(ResultDescriptor descriptor) { |
| 273 return _SOURCE_ERRORS.contains(descriptor) || | 279 return _SOURCE_ERRORS.contains(descriptor) || |
| 274 _UNIT_ERRORS.contains(descriptor); | 280 _UNIT_ERRORS.contains(descriptor); |
| 275 } | 281 } |
| 276 } | 282 } |
| OLD | NEW |