| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 String toString() => description; | 163 String toString() => description; |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * 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 |
| 167 * [AnalysisException]. | 167 * [AnalysisException]. |
| 168 * | 168 * |
| 169 * Clients should not override this method. | 169 * Clients should not override this method. |
| 170 */ | 170 */ |
| 171 void _safelyPerform() { | 171 void _safelyPerform() { |
| 172 try { | 172 try { |
| 173 // |
| 174 // Report that this task is being performed. |
| 175 // |
| 176 String contextName = context.name; |
| 177 if (contextName == null) { |
| 178 contextName = 'unnamed'; |
| 179 } |
| 180 AnalysisEngine.instance.instrumentationService.logAnalysisTask( |
| 181 contextName, |
| 182 description); |
| 183 // |
| 184 // Gather statistics on the performance of the task. |
| 185 // |
| 173 int count = countMap[runtimeType]; | 186 int count = countMap[runtimeType]; |
| 174 countMap[runtimeType] = count == null ? 1 : count + 1; | 187 countMap[runtimeType] = count == null ? 1 : count + 1; |
| 175 Stopwatch stopwatch = stopwatchMap[runtimeType]; | 188 Stopwatch stopwatch = stopwatchMap[runtimeType]; |
| 176 if (stopwatch == null) { | 189 if (stopwatch == null) { |
| 177 stopwatch = new Stopwatch(); | 190 stopwatch = new Stopwatch(); |
| 178 stopwatchMap[runtimeType] = stopwatch; | 191 stopwatchMap[runtimeType] = stopwatch; |
| 179 } | 192 } |
| 180 stopwatch.start(); | 193 stopwatch.start(); |
| 194 // |
| 195 // Actually perform the task. |
| 196 // |
| 181 try { | 197 try { |
| 182 internalPerform(); | 198 internalPerform(); |
| 183 } finally { | 199 } finally { |
| 184 stopwatch.stop(); | 200 stopwatch.stop(); |
| 185 } | 201 } |
| 186 } on AnalysisException catch (exception) { | 202 } on AnalysisException catch (exception) { |
| 187 rethrow; | 203 rethrow; |
| 188 } catch (exception, stackTrace) { | 204 } catch (exception, stackTrace) { |
| 189 throw new AnalysisException( | 205 throw new AnalysisException( |
| 190 'Unexpected exception while performing $description', | 206 'Unexpected exception while performing $description', |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 * be computed, or `false` if the inputs have been computed. | 356 * be computed, or `false` if the inputs have been computed. |
| 341 * | 357 * |
| 342 * It is safe to invoke [moveNext] after it has returned `false`. In this case | 358 * It is safe to invoke [moveNext] after it has returned `false`. In this case |
| 343 * [moveNext] has no effect and will again return `false`. | 359 * [moveNext] has no effect and will again return `false`. |
| 344 * | 360 * |
| 345 * Throws a [StateError] if the value of the current result has not been | 361 * Throws a [StateError] if the value of the current result has not been |
| 346 * provided using [currentValue]. | 362 * provided using [currentValue]. |
| 347 */ | 363 */ |
| 348 bool moveNext(); | 364 bool moveNext(); |
| 349 } | 365 } |
| OLD | NEW |