Remove source_range from definition

We don't use it now, and plan on dealing with it in a dedicated way when we need mouse hover interactions.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo 2022-01-21 07:31:02 -07:00
parent 4698d57ddd
commit 1d72e8face

View file

@ -94,7 +94,6 @@ pub struct DiagnosticSummary {
#[derive(Debug)]
pub struct Definition {
pub source_range: Option<Range<language::Anchor>>,
pub target_buffer: ModelHandle<Buffer>,
pub target_range: Range<language::Anchor>,
}
@ -756,24 +755,21 @@ impl Project {
let mut unresolved_locations = Vec::new();
match response {
lsp::GotoDefinitionResponse::Scalar(loc) => {
unresolved_locations.push((None, loc.uri, loc.range));
unresolved_locations.push((loc.uri, loc.range));
}
lsp::GotoDefinitionResponse::Array(locs) => {
unresolved_locations
.extend(locs.into_iter().map(|l| (None, l.uri, l.range)));
unresolved_locations.extend(locs.into_iter().map(|l| (l.uri, l.range)));
}
lsp::GotoDefinitionResponse::Link(links) => {
unresolved_locations.extend(links.into_iter().map(|l| {
(
l.origin_selection_range,
l.target_uri,
l.target_selection_range,
)
}));
unresolved_locations.extend(
links
.into_iter()
.map(|l| (l.target_uri, l.target_selection_range)),
);
}
}
for (source_range, target_uri, target_range) in unresolved_locations {
for (target_uri, target_range) in unresolved_locations {
let abs_path = target_uri
.to_file_path()
.map_err(|_| anyhow!("invalid target path"))?;
@ -806,21 +802,12 @@ impl Project {
.update(&mut cx, |this, cx| this.open_buffer(project_path, cx))
.await?;
cx.read(|cx| {
let source_buffer = source_buffer_handle.read(cx);
let target_buffer = target_buffer_handle.read(cx);
let source_range = source_range.map(|range| {
let start = source_buffer
.clip_point_utf16(range.start.to_point_utf16(), Bias::Left);
let end = source_buffer
.clip_point_utf16(range.end.to_point_utf16(), Bias::Left);
source_buffer.anchor_after(start)..source_buffer.anchor_before(end)
});
let target_start = target_buffer
.clip_point_utf16(target_range.start.to_point_utf16(), Bias::Left);
let target_end = target_buffer
.clip_point_utf16(target_range.end.to_point_utf16(), Bias::Left);
definitions.push(Definition {
source_range,
target_buffer: target_buffer_handle,
target_range: target_buffer.anchor_after(target_start)
..target_buffer.anchor_before(target_end),