OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017, 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:analyzer/src/generated/java_core.dart'; | |
6 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | |
7 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; | |
8 import 'package:analyzer_plugin/utilities/assist/assist.dart'; | |
9 import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dar t'; | |
10 | |
11 /** | |
12 * A partial implementation of an [AssistContributor] that provides a utility | |
13 * method to make it easier to add assists. | |
14 * | |
15 * Clients may not extend or implement this class, but are allowed to use it as | |
16 * a mix-in when creating a subclass of [AssistContributor]. | |
17 */ | |
18 abstract class AssistContributorMixin implements AssistContributor { | |
19 /** | |
20 * The collector to which assists should be added. | |
21 */ | |
22 AssistCollector get collector; | |
23 | |
24 /** | |
25 * Add an assist. Use the [kind] of the assist to get the message and priority , | |
26 * and use the change [builder] to get the edits that comprise the assist. If | |
27 * the message has parameters, then use the list of [args] to populate the | |
28 * message. | |
29 */ | |
30 void addAssistFromBuilder(ChangeBuilder builder, AssistKind kind, | |
31 {List args: null}) { | |
scheglov
2017/06/28 18:36:33
`null` is the default default value.
Brian Wilkerson
2017/06/28 18:43:49
Removed
| |
32 SourceChange change = builder.sourceChange; | |
33 if (change.edits.isEmpty) { | |
34 return; | |
35 } | |
36 change.message = formatList(kind.message, args); | |
37 collector.addAssist( | |
38 new PrioritizedSourceChange(kind.priority, builder.sourceChange)); | |
39 } | |
40 } | |
OLD | NEW |