OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 operation; | 5 library operation; |
6 | 6 |
7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
9 | 10 |
10 /** | 11 /** |
11 * The class [ServerOperation] defines the behavior of objects used to perform | 12 * The class [ServerOperation] defines the behavior of objects used to perform |
12 * operations on a [AnalysisServer]. | 13 * operations on a [AnalysisServer]. |
13 */ | 14 */ |
14 abstract class ServerOperation { | 15 abstract class ServerOperation { |
15 /** | 16 /** |
| 17 * The context for this operation. Operations will be automatically |
| 18 * de-queued when their context is destroyed. |
| 19 */ |
| 20 final AnalysisContext context; |
| 21 |
| 22 ServerOperation(this.context); |
| 23 |
| 24 /** |
16 * Returns the priority of this operation. | 25 * Returns the priority of this operation. |
17 */ | 26 */ |
18 ServerOperationPriority get priority; | 27 ServerOperationPriority get priority; |
19 | 28 |
20 /** | 29 /** |
21 * Performs the operation implemented by this operation. | 30 * Performs the operation implemented by this operation. |
22 */ | 31 */ |
23 void perform(AnalysisServer server); | 32 void perform(AnalysisServer server); |
24 } | 33 } |
25 | 34 |
(...skipping 30 matching lines...) Expand all Loading... |
56 | 65 |
57 @override | 66 @override |
58 String toString() => name; | 67 String toString() => name; |
59 } | 68 } |
60 | 69 |
61 /** | 70 /** |
62 * [SourceSensitiveOperation] can decide if the operation should be discarded | 71 * [SourceSensitiveOperation] can decide if the operation should be discarded |
63 * before a change is applied to a [Source]. | 72 * before a change is applied to a [Source]. |
64 */ | 73 */ |
65 abstract class SourceSensitiveOperation extends ServerOperation { | 74 abstract class SourceSensitiveOperation extends ServerOperation { |
| 75 SourceSensitiveOperation(AnalysisContext context) : super(context); |
| 76 |
66 /** | 77 /** |
67 * The given [source] is about to be changed. | 78 * The given [source] is about to be changed. |
68 * Check if this [SourceSensitiveOperation] should be discarded. | 79 * Check if this [SourceSensitiveOperation] should be discarded. |
69 */ | 80 */ |
70 bool shouldBeDiscardedOnSourceChange(Source source); | 81 bool shouldBeDiscardedOnSourceChange(Source source); |
71 } | 82 } |
OLD | NEW |