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