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

Unified Diff: pkg/analyzer_plugin/lib/plugin/completion_mixin.dart

Issue 2970203002: Remove references to AnalysisDriver from the plugin mixin classes (Closed)
Patch Set: Created 3 years, 5 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
Index: pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
diff --git a/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart b/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
index 813a6ace72aee546c7528b9b0a5525885ecffafc..a4008136658b4b22af8c706f439a2801739a61a9 100644
--- a/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
@@ -23,34 +23,24 @@ import 'package:analyzer_plugin/utilities/generator.dart';
abstract class CompletionMixin implements ServerPlugin {
/**
* Return a list containing the completion contributors that should be used to
- * create completion suggestions when used in the context of the given
- * analysis [driver].
+ * create completion suggestions for the file with the given [path].
*/
- List<CompletionContributor> getCompletionContributors(
- covariant AnalysisDriverGeneric driver);
+ List<CompletionContributor> getCompletionContributors(String path);
/**
* Return the completion request that should be passes to the contributors
* returned from [getCompletionContributors].
*/
Future<CompletionRequest> getCompletionRequest(
- CompletionGetSuggestionsParams parameters,
- covariant AnalysisDriverGeneric driver);
+ CompletionGetSuggestionsParams parameters);
@override
Future<CompletionGetSuggestionsResult> handleCompletionGetSuggestions(
CompletionGetSuggestionsParams parameters) async {
String path = parameters.file;
- ContextRoot contextRoot = contextRootContaining(path);
- if (contextRoot == null) {
- // Return an error from the request.
- throw new RequestFailure(
- RequestErrorFactory.pluginError('Failed to analyze $path', null));
- }
- AnalysisDriverGeneric driver = driverMap[contextRoot];
- CompletionRequest request = await getCompletionRequest(parameters, driver);
+ CompletionRequest request = await getCompletionRequest(parameters);
CompletionGenerator generator =
- new CompletionGenerator(getCompletionContributors(driver));
+ new CompletionGenerator(getCompletionContributors(path));
GeneratorResult result =
await generator.generateCompletionResponse(request);
result.sendNotifications(channel);
@@ -71,8 +61,14 @@ abstract class CompletionMixin implements ServerPlugin {
abstract class DartCompletionMixin implements CompletionMixin {
@override
Future<CompletionRequest> getCompletionRequest(
- CompletionGetSuggestionsParams parameters,
- covariant AnalysisDriver driver) async {
+ CompletionGetSuggestionsParams parameters) async {
+ String path = parameters.file;
+ AnalysisDriver driver = driverForPath(path);
+ if (driver == null) {
+ // Return an error from the request.
+ throw new RequestFailure(
+ RequestErrorFactory.pluginError('Failed to analyze $path', null));
+ }
ResolveResult result = await driver.getResult(parameters.file);
return new DartCompletionRequestImpl(
resourceProvider, parameters.offset, result);

Powered by Google App Engine
This is Rietveld 408576698