mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Auto merge of #12224 - Veykril:anno-redundant, r=Veykril
internal: Remove redundant offset data in annotations cc https://github.com/rust-lang/rust-analyzer/issues/12221
This commit is contained in:
commit
5901dfdf1b
3 changed files with 84 additions and 152 deletions
|
@ -101,10 +101,7 @@ pub(crate) fn annotation(
|
|||
|
||||
Ok(Annotation {
|
||||
range: text_range(&line_index, code_lens.range)?,
|
||||
kind: AnnotationKind::HasImpls {
|
||||
position: file_position(snap, params.text_document_position_params)?,
|
||||
data: None,
|
||||
},
|
||||
kind: AnnotationKind::HasImpls { file_id, data: None },
|
||||
})
|
||||
}
|
||||
lsp_ext::CodeLensResolveData::References(params) => {
|
||||
|
@ -113,10 +110,7 @@ pub(crate) fn annotation(
|
|||
|
||||
Ok(Annotation {
|
||||
range: text_range(&line_index, code_lens.range)?,
|
||||
kind: AnnotationKind::HasReferences {
|
||||
position: file_position(snap, params)?,
|
||||
data: None,
|
||||
},
|
||||
kind: AnnotationKind::HasReferences { file_id, data: None },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue