| 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.task.model; | 5 library analyzer.task.model; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:developer'; | 8 import 'dart:developer'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 10 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * An object used to compute one or more analysis results associated with a | 75 * An object used to compute one or more analysis results associated with a |
| 76 * single target. | 76 * single target. |
| 77 * | 77 * |
| 78 * Clients must extend this class when creating new tasks. | 78 * Clients must extend this class when creating new tasks. |
| 79 */ | 79 */ |
| 80 abstract class AnalysisTask { | 80 abstract class AnalysisTask { |
| 81 /** | 81 /** |
| 82 * A queue storing the last 10 task descriptions for diagnostic purposes. |
| 83 */ |
| 84 static final LimitedQueue<String> LAST_TASKS = new LimitedQueue<String>(10); |
| 85 |
| 86 /** |
| 82 * A table mapping the types of analysis tasks to the number of times each | 87 * A table mapping the types of analysis tasks to the number of times each |
| 83 * kind of task has been performed. | 88 * kind of task has been performed. |
| 84 */ | 89 */ |
| 85 static final Map<Type, int> countMap = new HashMap<Type, int>(); | 90 static final Map<Type, int> countMap = new HashMap<Type, int>(); |
| 86 | 91 |
| 87 /** | 92 /** |
| 88 * A table mapping the types of analysis tasks to user tags used to collect | 93 * A table mapping the types of analysis tasks to user tags used to collect |
| 89 * timing data for the Observatory. | 94 * timing data for the Observatory. |
| 90 */ | 95 */ |
| 91 static Map<Type, UserTag> tagMap = new HashMap<Type, UserTag>(); | 96 static Map<Type, UserTag> tagMap = new HashMap<Type, UserTag>(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 264 |
| 260 /** | 265 /** |
| 261 * Perform this analysis task, ensuring that all exceptions are wrapped in an | 266 * Perform this analysis task, ensuring that all exceptions are wrapped in an |
| 262 * [AnalysisException]. | 267 * [AnalysisException]. |
| 263 * | 268 * |
| 264 * Clients may not override this method. | 269 * Clients may not override this method. |
| 265 */ | 270 */ |
| 266 void _safelyPerform() { | 271 void _safelyPerform() { |
| 267 try { | 272 try { |
| 268 // | 273 // |
| 274 // Store task description for diagnostics. |
| 275 // |
| 276 LAST_TASKS.add(description); |
| 277 |
| 278 // |
| 269 // Report that this task is being performed. | 279 // Report that this task is being performed. |
| 270 // | 280 // |
| 271 String contextName = context.name; | 281 String contextName = context.name; |
| 272 if (contextName == null) { | 282 if (contextName == null) { |
| 273 contextName = 'unnamed'; | 283 contextName = 'unnamed'; |
| 274 } | 284 } |
| 275 AnalysisEngine.instance.instrumentationService | 285 AnalysisEngine.instance.instrumentationService |
| 276 .logAnalysisTask(contextName, this); | 286 .logAnalysisTask(contextName, this); |
| 277 // | 287 // |
| 278 // Gather statistics on the performance of the task. | 288 // Gather statistics on the performance of the task. |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 /** | 735 /** |
| 726 * A work should be done, but without any special urgency. | 736 * A work should be done, but without any special urgency. |
| 727 */ | 737 */ |
| 728 NORMAL, | 738 NORMAL, |
| 729 | 739 |
| 730 /** | 740 /** |
| 731 * Nothing to do. | 741 * Nothing to do. |
| 732 */ | 742 */ |
| 733 NONE | 743 NONE |
| 734 } | 744 } |
| OLD | NEW |