mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
switch to FileRange
This commit is contained in:
parent
02924174bb
commit
fd33c89207
4 changed files with 37 additions and 15 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, CompletionItem, CompletionItemKind, InsertText};
|
||||
use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition,FileRange, CompletionItem, CompletionItemKind, InsertText};
|
||||
use ra_editor::{LineCol, LineIndex, translate_offset_with_edit};
|
||||
use ra_text_edit::{AtomTextEdit, TextEdit};
|
||||
use ra_syntax::{SyntaxKind, TextRange, TextUnit};
|
||||
|
@ -218,6 +218,17 @@ impl<'a> TryConvWith for &'a TextDocumentPositionParams {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) {
|
||||
type Ctx = ServerWorld;
|
||||
type Output = FileRange;
|
||||
fn try_conv_with(self, world: &ServerWorld) -> Result<FileRange> {
|
||||
let file_id = self.0.try_conv_with(world)?;
|
||||
let line_index = world.analysis().file_line_index(file_id);
|
||||
let range = self.1.conv_with(&line_index);
|
||||
Ok(FileRange { file_id, range })
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: TryConvWith> TryConvWith for Vec<T> {
|
||||
type Ctx = <T as TryConvWith>::Ctx;
|
||||
type Output = Vec<<T as TryConvWith>::Output>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue