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

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

Issue 3008443002: Enhance NavigationMixin to handle notifications (Closed)
Patch Set: Added a test Created 3 years, 4 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 | « no previous file | pkg/analyzer_plugin/test/plugin/mocks.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9a2d3b41016c44eabb0092e3e37fc10e258b7893..f8cb90a86815426e68f96b0b1d909bcf08bfa5de 100644
--- a/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/navigation_mixin.dart
@@ -29,8 +29,14 @@ abstract class DartNavigationMixin implements NavigationMixin {
AnalysisGetNavigationParams parameters) async {
String path = parameters.file;
ResolveResult result = await getResolveResult(path);
+ int offset = parameters.offset;
+ int length = parameters.length;
+ if (offset < 0 && length < 0) {
+ offset = 0;
+ length = result.content.length;
+ }
return new DartNavigationRequestImpl(
- resourceProvider, parameters.offset, parameters.length, result);
+ resourceProvider, offset, length, result);
}
}
@@ -69,4 +75,23 @@ abstract class NavigationMixin implements ServerPlugin {
result.sendNotifications(channel);
return result.result;
}
+
+ /**
+ * Send a navigation notification for the file with the given [path] to the
+ * server.
+ */
+ @override
+ Future<Null> sendNavigationNotification(String path) async {
+ try {
+ NavigationRequest request = await getNavigationRequest(
+ new AnalysisGetNavigationParams(path, -1, -1));
+ NavigationGenerator generator =
+ new NavigationGenerator(getNavigationContributors(path));
+ GeneratorResult generatorResult =
+ await generator.generateNavigationNotification(request);
+ generatorResult.sendNotifications(channel);
+ } on RequestFailure {
+ // If we couldn't analyze the file, then don't send a notification.
+ }
+ }
}
« no previous file with comments | « no previous file | pkg/analyzer_plugin/test/plugin/mocks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698