Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/analysis/results.dart'; | 7 import 'package:analyzer/dart/analysis/results.dart'; |
| 8 import 'package:analyzer/src/dart/analysis/driver.dart'; | 8 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 9 import 'package:analyzer_plugin/plugin/plugin.dart'; | 9 import 'package:analyzer_plugin/plugin/plugin.dart'; |
| 10 import 'package:analyzer_plugin/protocol/protocol.dart'; | 10 import 'package:analyzer_plugin/protocol/protocol.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 * Clients may not extend or implement this class, but are allowed to use it as | 22 * Clients may not extend or implement this class, but are allowed to use it as |
| 23 * a mix-in when creating a subclass of [ServerPlugin] that also uses | 23 * a mix-in when creating a subclass of [ServerPlugin] that also uses |
| 24 * [NavigationMixin] as a mix-in. | 24 * [NavigationMixin] as a mix-in. |
| 25 */ | 25 */ |
| 26 abstract class DartNavigationMixin implements NavigationMixin { | 26 abstract class DartNavigationMixin implements NavigationMixin { |
| 27 @override | 27 @override |
| 28 Future<NavigationRequest> getNavigationRequest( | 28 Future<NavigationRequest> getNavigationRequest( |
| 29 AnalysisGetNavigationParams parameters) async { | 29 AnalysisGetNavigationParams parameters) async { |
| 30 String path = parameters.file; | 30 String path = parameters.file; |
| 31 ResolveResult result = await getResolveResult(path); | 31 ResolveResult result = await getResolveResult(path); |
| 32 int offset = parameters.offset; | |
| 33 int length = parameters.length; | |
| 34 if (offset < 0 && length < 0) { | |
| 35 offset = 0; | |
| 36 length = result.content.length; | |
| 37 } | |
| 32 return new DartNavigationRequestImpl( | 38 return new DartNavigationRequestImpl( |
| 33 resourceProvider, parameters.offset, parameters.length, result); | 39 resourceProvider, offset, length, result); |
| 34 } | 40 } |
| 35 } | 41 } |
| 36 | 42 |
| 37 /** | 43 /** |
| 38 * A mixin that can be used when creating a subclass of [ServerPlugin] to | 44 * A mixin that can be used when creating a subclass of [ServerPlugin] to |
| 39 * provide most of the implementation for handling navigation requests. | 45 * provide most of the implementation for handling navigation requests. |
| 40 * | 46 * |
| 41 * Clients may not extend or implement this class, but are allowed to use it as | 47 * Clients may not extend or implement this class, but are allowed to use it as |
| 42 * a mix-in when creating a subclass of [ServerPlugin]. | 48 * a mix-in when creating a subclass of [ServerPlugin]. |
| 43 */ | 49 */ |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 62 AnalysisGetNavigationParams parameters) async { | 68 AnalysisGetNavigationParams parameters) async { |
| 63 String path = parameters.file; | 69 String path = parameters.file; |
| 64 NavigationRequest request = await getNavigationRequest(parameters); | 70 NavigationRequest request = await getNavigationRequest(parameters); |
| 65 NavigationGenerator generator = | 71 NavigationGenerator generator = |
| 66 new NavigationGenerator(getNavigationContributors(path)); | 72 new NavigationGenerator(getNavigationContributors(path)); |
| 67 GeneratorResult result = | 73 GeneratorResult result = |
| 68 await generator.generateNavigationResponse(request); | 74 await generator.generateNavigationResponse(request); |
| 69 result.sendNotifications(channel); | 75 result.sendNotifications(channel); |
| 70 return result.result; | 76 return result.result; |
| 71 } | 77 } |
| 78 | |
| 79 /** | |
| 80 * Send a navigation notification for the file with the given [path] to the | |
| 81 * server. If a [result] is provided then it is expected to be the result of | |
|
scheglov
2017/08/23 21:36:21
What [result]?
Brian Wilkerson
2017/08/24 14:27:58
Removed.
| |
| 82 * analyzing the file at the given [path] and will be used to build the | |
| 83 * [NavigationRequest] that is passed to the navigation contributors. | |
| 84 */ | |
| 85 @override | |
| 86 Future<Null> sendNavigationNotification(String path) async { | |
| 87 try { | |
| 88 NavigationRequest request = await getNavigationRequest( | |
| 89 new AnalysisGetNavigationParams(path, -1, -1)); | |
| 90 NavigationGenerator generator = | |
| 91 new NavigationGenerator(getNavigationContributors(request.path)); | |
| 92 GeneratorResult generatorResult = | |
| 93 await generator.generateNavigationNotification(request); | |
| 94 generatorResult.sendNotifications(channel); | |
| 95 } on RequestFailure { | |
| 96 // If we couldn't analyze the file, then don't send a notification. | |
| 97 } | |
| 98 } | |
| 72 } | 99 } |
| OLD | NEW |