Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1211)

Unified Diff: pkg/analyzer_plugin/lib/utilities/assist/assist_contributor_mixin.dart

Issue 2956353002: Add a mixin for assists similar to that for fixes (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_plugin/lib/utilities/assist/assist.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_plugin/lib/utilities/assist/assist_contributor_mixin.dart
diff --git a/pkg/analyzer_plugin/lib/utilities/assist/assist_contributor_mixin.dart b/pkg/analyzer_plugin/lib/utilities/assist/assist_contributor_mixin.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c66c051d4fb666ecf556a1434ebc664d1e1c7ee9
--- /dev/null
+++ b/pkg/analyzer_plugin/lib/utilities/assist/assist_contributor_mixin.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/src/generated/java_core.dart';
+import 'package:analyzer_plugin/protocol/protocol_common.dart';
+import 'package:analyzer_plugin/protocol/protocol_generated.dart';
+import 'package:analyzer_plugin/utilities/assist/assist.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+
+/**
+ * A partial implementation of an [AssistContributor] that provides a utility
+ * method to make it easier to add assists.
+ *
+ * Clients may not extend or implement this class, but are allowed to use it as
+ * a mix-in when creating a subclass of [AssistContributor].
+ */
+abstract class AssistContributorMixin implements AssistContributor {
+ /**
+ * The collector to which assists should be added.
+ */
+ AssistCollector get collector;
+
+ /**
+ * Add an assist. Use the [kind] of the assist to get the message and priority,
+ * and use the change [builder] to get the edits that comprise the assist. If
+ * the message has parameters, then use the list of [args] to populate the
+ * message.
+ */
+ void addAssistFromBuilder(ChangeBuilder builder, AssistKind kind,
+ {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
+ SourceChange change = builder.sourceChange;
+ if (change.edits.isEmpty) {
+ return;
+ }
+ change.message = formatList(kind.message, args);
+ collector.addAssist(
+ new PrioritizedSourceChange(kind.priority, builder.sourceChange));
+ }
+}
« no previous file with comments | « pkg/analyzer_plugin/lib/utilities/assist/assist.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698