Chromium Code Reviews| 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..c2d1ed10c8c6a35ba66b4f6a0db10977ba45dca7 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 { |
|
mfairhurst
2017/06/22 23:47:31
Should it extend NavigationMixin so many people ca
Brian Wilkerson
2017/06/23 15:02:17
Sigh. I already tried that, but it can't. A class
|
| + @override |
| + Future<NavigationRequest> getNavigationRequest( |
| + AnalysisGetNavigationParams parameters, |
| + covariant AnalysisDriver driver) async { |
| + ResolveResult analysisResult = await driver.getResult(parameters.file); |
| + return new NavigationRequestImpl( |
| + resourceProvider, parameters.offset, parameters.length, analysisResult); |
| + } |
| +} |
| + |
| +/** |
| * 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 = |