| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library operation; |
| 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| 9 |
| 10 |
| 11 /** |
| 12 * The enumeration [ServerOperationPriority] defines the priority levels used |
| 13 * to organize [ServerOperation]s in an optimal order. A smaller ordinal value |
| 14 * equates to a higher priority. |
| 15 */ |
| 16 class ServerOperationPriority { |
| 17 final int ordinal; |
| 18 final String name; |
| 19 |
| 20 static const int COUNT = 4; |
| 21 |
| 22 static const ServerOperationPriority ANALYSIS_CONTINUE = const ServerOperation
Priority._(0, "ANALYSIS_CONTINUE"); |
| 23 static const ServerOperationPriority ANALYSIS = const ServerOperationPriority.
_(1, "ANALYSIS"); |
| 24 static const ServerOperationPriority SEARCH = const ServerOperationPriority._(
2, "SEARCH"); |
| 25 static const ServerOperationPriority REFACTORING = const ServerOperationPriori
ty._(3, "REFACTORING"); |
| 26 |
| 27 @override |
| 28 String toString() => name; |
| 29 |
| 30 const ServerOperationPriority._(this.ordinal, this.name); |
| 31 } |
| 32 |
| 33 |
| 34 /** |
| 35 * The class [ServerOperation] defines the behavior of objects used to perform |
| 36 * operations on a [AnalysisServer]. |
| 37 */ |
| 38 abstract class ServerOperation { |
| 39 /** |
| 40 * Returns the priority of this operation. |
| 41 */ |
| 42 ServerOperationPriority get priority; |
| 43 |
| 44 /** |
| 45 * Performs the operation implemented by this operation. |
| 46 */ |
| 47 void perform(AnalysisServer server); |
| 48 } |
| 49 |
| 50 |
| 51 /** |
| 52 * Instances of [PerformAnalysisOperation] perform a single analysis task. |
| 53 */ |
| 54 class PerformAnalysisOperation extends ServerOperation { |
| 55 final AnalysisContext context; |
| 56 final bool isContinue; |
| 57 |
| 58 PerformAnalysisOperation(this.context, this.isContinue); |
| 59 |
| 60 @override |
| 61 ServerOperationPriority get priority { |
| 62 if (isContinue) { |
| 63 return ServerOperationPriority.ANALYSIS_CONTINUE; |
| 64 } else { |
| 65 return ServerOperationPriority.ANALYSIS; |
| 66 } |
| 67 } |
| 68 |
| 69 @override |
| 70 void perform(AnalysisServer server) { |
| 71 server.internalPerformAnalysis(context); |
| 72 } |
| 73 } |
| OLD | NEW |