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

Unified Diff: pkg/analysis_server/lib/src/services/correction/assist.dart

Issue 1461343002: Make AssistContributor asynchronous. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
Index: pkg/analysis_server/lib/src/services/correction/assist.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/assist.dart b/pkg/analysis_server/lib/src/services/correction/assist.dart
index 29d27819f59a427ee60aeb21682f7dd9ddbed9df..0f11dec1013f8ef681214b33161568f45ae33014 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist.dart
@@ -9,21 +9,28 @@ import 'package:analysis_server/src/plugin/server_plugin.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'dart:async';
/**
* Compute and return the assists available at the given selection (described by
* the [offset] and [length]) in the given [source]. The source was analyzed in
- * the given [context]. The [plugin] is used to get the list of assist
+ * the given [analysisContext]. The [plugin] is used to get the list of assist
* contributors.
*/
-List<Assist> computeAssists(ServerPlugin plugin, AnalysisContext context,
- Source source, int offset, int length) {
+Future<List<Assist>> computeAssists(
+ ServerPlugin plugin,
+ AnalysisContext analysisContext,
+ Source source,
+ int offset,
+ int length) async {
List<Assist> assists = <Assist>[];
List<AssistContributor> contributors = plugin.assistContributors;
+ AssistContextImpl assistContext =
+ new AssistContextImpl(analysisContext, source, offset, length);
for (AssistContributor contributor in contributors) {
try {
List<Assist> contributedAssists =
- contributor.computeAssists(context, source, offset, length);
+ await contributor.computeAssists(assistContext);
if (contributedAssists != null) {
assists.addAll(contributedAssists);
}
@@ -38,6 +45,26 @@ List<Assist> computeAssists(ServerPlugin plugin, AnalysisContext context,
}
/**
+ * The implementation of [AssistContext].
+ */
+class AssistContextImpl implements AssistContext {
+ @override
+ final AnalysisContext analysisContext;
+
+ @override
+ final Source source;
+
+ @override
+ final int selectionOffset;
+
+ @override
+ final int selectionLength;
+
+ AssistContextImpl(this.analysisContext, this.source, this.selectionOffset,
+ this.selectionLength);
+}
+
+/**
* An enumeration of possible assist kinds.
*/
class DartAssistKind {

Powered by Google App Engine
This is Rietveld 408576698