mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
use location link in goto def
This commit is contained in:
parent
3aaf20bd6e
commit
8a5f74a24f
2 changed files with 25 additions and 12 deletions
|
@ -9,7 +9,7 @@ use languageserver_types::{
|
|||
SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit,
|
||||
};
|
||||
use ra_ide_api::{
|
||||
FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, SourceChange, RangeInfo,
|
||||
FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity, RangeInfo,
|
||||
};
|
||||
use ra_syntax::{TextUnit, AstNode};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
@ -17,7 +17,7 @@ use serde_json::to_value;
|
|||
use std::io::Write;
|
||||
|
||||
use crate::{
|
||||
conv::{to_location, Conv, ConvWith, MapConvWith, TryConvWith},
|
||||
conv::{to_location, to_location_link, Conv, ConvWith, MapConvWith, TryConvWith},
|
||||
project_model::TargetKind,
|
||||
req::{self, Decoration},
|
||||
server_world::ServerWorld,
|
||||
|
@ -208,6 +208,7 @@ pub fn handle_goto_definition(
|
|||
params: req::TextDocumentPositionParams,
|
||||
) -> Result<Option<req::GotoDefinitionResponse>> {
|
||||
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_definition(position)? {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
|
@ -217,9 +218,9 @@ pub fn handle_goto_definition(
|
|||
.info
|
||||
.into_iter()
|
||||
.map(|nav| RangeInfo::new(nav_range, nav))
|
||||
.map(|nav| nav.try_conv_with(&world))
|
||||
.map(|nav| to_location_link(&nav, &world, &line_index))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
Ok(Some(req::GotoDefinitionResponse::Array(res)))
|
||||
Ok(Some(req::GotoDefinitionResponse::Link(res)))
|
||||
}
|
||||
|
||||
pub fn handle_parent_module(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue