mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Merge #702
702: Go to Implementation r=matklad a=kjeremy First half of #620 Co-authored-by: Jeremy Kolb <kjeremy@gmail.com> Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
commit
b704ce803b
14 changed files with 277 additions and 17 deletions
|
@ -2,7 +2,7 @@ use lsp_types::{
|
|||
CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions,
|
||||
ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability,
|
||||
ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind,
|
||||
TextDocumentSyncOptions,
|
||||
TextDocumentSyncOptions, ImplementationProviderCapability,
|
||||
};
|
||||
|
||||
pub fn server_capabilities() -> ServerCapabilities {
|
||||
|
@ -26,7 +26,7 @@ pub fn server_capabilities() -> ServerCapabilities {
|
|||
}),
|
||||
definition_provider: Some(true),
|
||||
type_definition_provider: None,
|
||||
implementation_provider: None,
|
||||
implementation_provider: Some(ImplementationProviderCapability::Simple(true)),
|
||||
references_provider: Some(true),
|
||||
document_highlight_provider: Some(true),
|
||||
document_symbol_provider: Some(true),
|
||||
|
|
|
@ -305,6 +305,7 @@ fn on_request(
|
|||
.on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)?
|
||||
.on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)?
|
||||
.on::<req::GotoDefinition>(handlers::handle_goto_definition)?
|
||||
.on::<req::GotoImplementation>(handlers::handle_goto_implementation)?
|
||||
.on::<req::ParentModule>(handlers::handle_parent_module)?
|
||||
.on::<req::Runnables>(handlers::handle_runnables)?
|
||||
.on::<req::DecorationsRequest>(handlers::handle_decorations)?
|
||||
|
|
|
@ -229,6 +229,26 @@ pub fn handle_goto_definition(
|
|||
Ok(Some(req::GotoDefinitionResponse::Link(res)))
|
||||
}
|
||||
|
||||
pub fn handle_goto_implementation(
|
||||
world: ServerWorld,
|
||||
params: req::TextDocumentPositionParams,
|
||||
) -> Result<Option<req::GotoImplementationResponse>> {
|
||||
let position = params.try_conv_with(&world)?;
|
||||
let line_index = world.analysis().file_line_index(position.file_id);
|
||||
let nav_info = match world.analysis().goto_implementation(position)? {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
};
|
||||
let nav_range = nav_info.range;
|
||||
let res = nav_info
|
||||
.info
|
||||
.into_iter()
|
||||
.map(|nav| RangeInfo::new(nav_range, nav))
|
||||
.map(|nav| to_location_link(&nav, &world, &line_index))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
Ok(Some(req::GotoDefinitionResponse::Link(res)))
|
||||
}
|
||||
|
||||
pub fn handle_parent_module(
|
||||
world: ServerWorld,
|
||||
params: req::TextDocumentPositionParams,
|
||||
|
|
|
@ -8,7 +8,7 @@ pub use lsp_types::{
|
|||
CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams,
|
||||
DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult,
|
||||
PublishDiagnosticsParams, ReferenceParams, SignatureHelp, TextDocumentEdit,
|
||||
TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams,
|
||||
TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams
|
||||
};
|
||||
|
||||
pub enum AnalyzerStatus {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue