mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
use navigation target in API
This commit is contained in:
parent
d25c89f760
commit
830abe0c1b
4 changed files with 44 additions and 26 deletions
|
@ -2,7 +2,7 @@ use languageserver_types::{
|
|||
self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier,
|
||||
TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, InsertTextFormat,
|
||||
};
|
||||
use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition,FileRange, CompletionItem, CompletionItemKind, InsertText};
|
||||
use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition,FileRange, CompletionItem, CompletionItemKind, InsertText, NavigationTarget};
|
||||
use ra_editor::{LineCol, LineIndex, translate_offset_with_edit};
|
||||
use ra_text_edit::{AtomTextEdit, TextEdit};
|
||||
use ra_syntax::{SyntaxKind, TextRange, TextUnit};
|
||||
|
@ -322,6 +322,15 @@ impl TryConvWith for FileSystemEdit {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryConvWith for &NavigationTarget {
|
||||
type Ctx = ServerWorld;
|
||||
type Output = Location;
|
||||
fn try_conv_with(self, world: &ServerWorld) -> Result<Location> {
|
||||
let line_index = world.analysis().file_line_index(self.file_id());
|
||||
to_location(self.file_id(), self.range(), &world, &line_index)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_location(
|
||||
file_id: FileId,
|
||||
range: TextRange,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue