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 import 'package:analysis_server/src/analysis_server.dart'; | |
6 import 'package:analyzer/src/generated/engine.dart'; | |
7 import 'package:analyzer/src/generated/source.dart'; | |
8 | |
9 /** | |
10 * [MergeableOperation] can decide whether other operation can be merged into | |
11 * it, so that it should not be added as a separate operation. | |
12 */ | |
13 abstract class MergeableOperation extends ServerOperation { | |
14 MergeableOperation(AnalysisContext context) : super(context); | |
15 | |
16 /** | |
17 * Attempt to merge the given [other] operation into this one, return `true` | |
18 * in case of success, so that [other] should not be added as a separate | |
19 * operation. | |
20 */ | |
21 bool merge(ServerOperation other); | |
22 } | |
23 | |
24 /** | |
25 * The class [ServerOperation] defines the behavior of objects used to perform | |
26 * operations on a [AnalysisServer]. | |
27 */ | |
28 abstract class ServerOperation { | |
29 /** | |
30 * The context for this operation. Operations will be automatically | |
31 * de-queued when their context is destroyed. | |
32 */ | |
33 final AnalysisContext context; | |
34 | |
35 ServerOperation(this.context); | |
36 | |
37 /** | |
38 * Returns the priority of this operation. | |
39 */ | |
40 ServerOperationPriority get priority; | |
41 | |
42 /** | |
43 * Performs the operation implemented by this operation. | |
44 */ | |
45 void perform(AnalysisServer server); | |
46 } | |
47 | |
48 /** | |
49 * The enumeration [ServerOperationPriority] defines the priority levels used | |
50 * to organize [ServerOperation]s in an optimal order. A smaller ordinal value | |
51 * equates to a higher priority. | |
52 */ | |
53 class ServerOperationPriority { | |
54 static const int COUNT = 6; | |
55 | |
56 static const ServerOperationPriority ANALYSIS_NOTIFICATION = | |
57 const ServerOperationPriority._(0, "ANALYSIS_NOTIFICATION"); | |
58 | |
59 static const ServerOperationPriority ANALYSIS_INDEX = | |
60 const ServerOperationPriority._(1, "ANALYSIS_INDEX"); | |
61 | |
62 static const ServerOperationPriority PRIORITY_ANALYSIS_CONTINUE = | |
63 const ServerOperationPriority._(2, "PRIORITY_ANALYSIS_CONTINUE"); | |
64 | |
65 static const ServerOperationPriority PRIORITY_ANALYSIS = | |
66 const ServerOperationPriority._(3, "PRIORITY_ANALYSIS"); | |
67 | |
68 static const ServerOperationPriority ANALYSIS_CONTINUE = | |
69 const ServerOperationPriority._(4, "ANALYSIS_CONTINUE"); | |
70 | |
71 static const ServerOperationPriority ANALYSIS = | |
72 const ServerOperationPriority._(5, "ANALYSIS"); | |
73 | |
74 final int ordinal; | |
75 final String name; | |
76 | |
77 const ServerOperationPriority._(this.ordinal, this.name); | |
78 | |
79 @override | |
80 String toString() => name; | |
81 } | |
82 | |
83 /** | |
84 * [SourceSensitiveOperation] can decide if the operation should be discarded | |
85 * before a change is applied to a [Source]. | |
86 */ | |
87 abstract class SourceSensitiveOperation extends ServerOperation { | |
88 SourceSensitiveOperation(AnalysisContext context) : super(context); | |
89 | |
90 /** | |
91 * The given [source] is about to be changed. | |
92 * Check if this [SourceSensitiveOperation] should be discarded. | |
93 */ | |
94 bool shouldBeDiscardedOnSourceChange(Source source); | |
95 } | |
OLD | NEW |