| 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 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 9 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 10 import 'package:analyzer/src/generated/java_engine.dart'; | 10 import 'package:analyzer/src/generated/java_engine.dart'; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * An object used to compute one or more analysis results associated with a | 45 * An object used to compute one or more analysis results associated with a |
| 46 * single target. | 46 * single target. |
| 47 * | 47 * |
| 48 * Clients are expected to extend this class when creating new tasks. | 48 * Clients are expected to extend this class when creating new tasks. |
| 49 */ | 49 */ |
| 50 abstract class AnalysisTask { | 50 abstract class AnalysisTask { |
| 51 /** | 51 /** |
| 52 * A table mapping the types of analysis tasks to the number of times each |
| 53 * kind of task has been performed. |
| 54 */ |
| 55 static final Map<Type, int> countMap = new HashMap<Type, int>(); |
| 56 |
| 57 /** |
| 52 * A table mapping the types of analysis tasks to stopwatches used to compute | 58 * A table mapping the types of analysis tasks to stopwatches used to compute |
| 53 * how much time was spent executing each kind of task. | 59 * how much time was spent executing each kind of task. |
| 54 */ | 60 */ |
| 55 static final Map<Type, Stopwatch> stopwatchMap = | 61 static final Map<Type, Stopwatch> stopwatchMap = |
| 56 new HashMap<Type, Stopwatch>(); | 62 new HashMap<Type, Stopwatch>(); |
| 57 | 63 |
| 58 /** | 64 /** |
| 59 * The context in which the task is to be performed. | 65 * The context in which the task is to be performed. |
| 60 */ | 66 */ |
| 61 final AnalysisContext context; | 67 final AnalysisContext context; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 String toString() => description; | 163 String toString() => description; |
| 158 | 164 |
| 159 /** | 165 /** |
| 160 * Perform this analysis task, ensuring that all exceptions are wrapped in an | 166 * Perform this analysis task, ensuring that all exceptions are wrapped in an |
| 161 * [AnalysisException]. | 167 * [AnalysisException]. |
| 162 * | 168 * |
| 163 * Clients should not override this method. | 169 * Clients should not override this method. |
| 164 */ | 170 */ |
| 165 void _safelyPerform() { | 171 void _safelyPerform() { |
| 166 try { | 172 try { |
| 173 int count = countMap[runtimeType]; |
| 174 countMap[runtimeType] = count == null ? 1 : count + 1; |
| 167 Stopwatch stopwatch = stopwatchMap[runtimeType]; | 175 Stopwatch stopwatch = stopwatchMap[runtimeType]; |
| 168 if (stopwatch == null) { | 176 if (stopwatch == null) { |
| 169 stopwatch = new Stopwatch(); | 177 stopwatch = new Stopwatch(); |
| 170 stopwatchMap[runtimeType] = stopwatch; | 178 stopwatchMap[runtimeType] = stopwatch; |
| 171 } | 179 } |
| 172 stopwatch.start(); | 180 stopwatch.start(); |
| 173 try { | 181 try { |
| 174 internalPerform(); | 182 internalPerform(); |
| 175 } finally { | 183 } finally { |
| 176 stopwatch.stop(); | 184 stopwatch.stop(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 * be computed, or `false` if the inputs have been computed. | 340 * be computed, or `false` if the inputs have been computed. |
| 333 * | 341 * |
| 334 * It is safe to invoke [moveNext] after it has returned `false`. In this case | 342 * It is safe to invoke [moveNext] after it has returned `false`. In this case |
| 335 * [moveNext] has no effect and will again return `false`. | 343 * [moveNext] has no effect and will again return `false`. |
| 336 * | 344 * |
| 337 * Throws a [StateError] if the value of the current result has not been | 345 * Throws a [StateError] if the value of the current result has not been |
| 338 * provided using [currentValue]. | 346 * provided using [currentValue]. |
| 339 */ | 347 */ |
| 340 bool moveNext(); | 348 bool moveNext(); |
| 341 } | 349 } |
| OLD | NEW |