| Index: pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
|
| diff --git a/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart b/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
|
| index 4445fadb85ab1113eb288d2b7dd8b488d6a215e6..c766be09725afdb002f6c42f55d467e8fa57b390 100644
|
| --- a/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
|
| +++ b/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
|
| @@ -14,6 +14,27 @@ import 'package:analyzer_plugin/utilities/generator.dart';
|
| import 'package:analyzer_plugin/utilities/navigation/navigation.dart';
|
|
|
| /**
|
| + * A mixin that can be used when creating a subclass of [ServerPlugin] and
|
| + * mixing in [NavigationMixin]. This implements the creation of the navigation
|
| + * request based on the assumption that the driver being created is an
|
| + * [AnalysisDriver].
|
| + *
|
| + * Clients may not extend or implement this class, but are allowed to use it as
|
| + * a mix-in when creating a subclass of [ServerPlugin] that also uses
|
| + * [NavigationMixin] as a mix-in.
|
| + */
|
| +abstract class DartNavigationMixin implements NavigationMixin {
|
| + @override
|
| + Future<NavigationRequest> getNavigationRequest(
|
| + AnalysisGetNavigationParams parameters,
|
| + covariant AnalysisDriver driver) async {
|
| + ResolveResult result = await driver.getResult(parameters.file);
|
| + return new DartNavigationRequestImpl(
|
| + resourceProvider, parameters.offset, parameters.length, result);
|
| + }
|
| +}
|
| +
|
| +/**
|
| * A mixin that can be used when creating a subclass of [ServerPlugin] to
|
| * provide most of the implementation for handling navigation requests.
|
| *
|
| @@ -30,11 +51,12 @@ abstract class NavigationMixin implements ServerPlugin {
|
| covariant AnalysisDriverGeneric driver);
|
|
|
| /**
|
| - * Return the result of using the given analysis [driver] to produce a fully
|
| - * resolved AST for the file with the given [path].
|
| + * Return the navigation request that should be passes to the contributors
|
| + * returned from [getNavigationContributors].
|
| */
|
| - Future<ResolveResult> getResolveResultForNavigation(
|
| - covariant AnalysisDriverGeneric driver, String path);
|
| + Future<NavigationRequest> getNavigationRequest(
|
| + AnalysisGetNavigationParams parameters,
|
| + covariant AnalysisDriverGeneric driver);
|
|
|
| @override
|
| Future<AnalysisGetNavigationResult> handleAnalysisGetNavigation(
|
| @@ -47,10 +69,7 @@ abstract class NavigationMixin implements ServerPlugin {
|
| RequestErrorFactory.pluginError('Failed to analyze $path', null));
|
| }
|
| AnalysisDriverGeneric driver = driverMap[contextRoot];
|
| - ResolveResult analysisResult =
|
| - await getResolveResultForNavigation(driver, path);
|
| - NavigationRequestImpl request = new NavigationRequestImpl(
|
| - resourceProvider, parameters.offset, parameters.length, analysisResult);
|
| + NavigationRequest request = await getNavigationRequest(parameters, driver);
|
| NavigationGenerator generator =
|
| new NavigationGenerator(getNavigationContributors(driver));
|
| GeneratorResult result =
|
|
|