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