internal: Remove redundant offset data in annotations

This commit is contained in:
Lukas Wirth
2022-05-12 12:55:25 +02:00
parent d121307977
commit ca46c68b04
3 changed files with 84 additions and 152 deletions

View File

@@ -1103,19 +1103,17 @@ pub(crate) fn code_lens(
})
}
}
AnnotationKind::HasImpls { position: file_position, data } => {
AnnotationKind::HasImpls { file_id, data } => {
if !client_commands_config.show_reference {
return Ok(());
}
let line_index = snap.file_line_index(file_position.file_id)?;
let line_index = snap.file_line_index(file_id)?;
let annotation_range = range(&line_index, annotation.range);
let url = url(snap, file_position.file_id);
let position = position(&line_index, file_position.offset);
let url = url(snap, file_id);
let id = lsp_types::TextDocumentIdentifier { uri: url.clone() };
let doc_pos = lsp_types::TextDocumentPositionParams::new(id, position);
let doc_pos = lsp_types::TextDocumentPositionParams::new(id, annotation_range.start);
let goto_params = lsp_types::request::GotoImplementationParams {
text_document_position_params: doc_pos,
@@ -1138,7 +1136,7 @@ pub(crate) fn code_lens(
command::show_references(
implementation_title(locations.len()),
&url,
position,
annotation_range.start,
locations,
)
});
@@ -1149,19 +1147,17 @@ pub(crate) fn code_lens(
data: Some(to_value(lsp_ext::CodeLensResolveData::Impls(goto_params)).unwrap()),
})
}
AnnotationKind::HasReferences { position: file_position, data } => {
AnnotationKind::HasReferences { file_id, data } => {
if !client_commands_config.show_reference {
return Ok(());
}
let line_index = snap.file_line_index(file_position.file_id)?;
let line_index = snap.file_line_index(file_id)?;
let annotation_range = range(&line_index, annotation.range);
let url = url(snap, file_position.file_id);
let position = position(&line_index, file_position.offset);
let url = url(snap, file_id);
let id = lsp_types::TextDocumentIdentifier { uri: url.clone() };
let doc_pos = lsp_types::TextDocumentPositionParams::new(id, position);
let doc_pos = lsp_types::TextDocumentPositionParams::new(id, annotation_range.start);
let command = data.map(|ranges| {
let locations: Vec<lsp_types::Location> =
@@ -1170,7 +1166,7 @@ pub(crate) fn code_lens(
command::show_references(
reference_title(locations.len()),
&url,
position,
annotation_range.start,
locations,
)
});