add byte range to main loop and direct the request via callback and define the callback on client side
This commit is contained in:
parent
e909b4b282
commit
e68a654dca
2 changed files with 28 additions and 1 deletions
|
|
@ -591,6 +591,16 @@ impl ProcMacroExpander for Expander {
|
|||
|
||||
Ok(SubResponse::FilePathResult { name })
|
||||
}
|
||||
SubRequest::ByteRange { file_id, ast_id, start, end } => {
|
||||
let range = resolve_sub_span(
|
||||
db,
|
||||
file_id,
|
||||
ast_id,
|
||||
TextRange::new(TextSize::from(start), TextSize::from(end)),
|
||||
);
|
||||
|
||||
Ok(SubResponse::ByteRangeResult { range: range.range.into() })
|
||||
}
|
||||
};
|
||||
match self.0.expand(
|
||||
subtree.view(),
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use proc_macro_api::{
|
|||
transport::codec::{json::JsonProtocol, postcard::PostcardProtocol},
|
||||
version::CURRENT_API_VERSION,
|
||||
};
|
||||
use std::io::{self, BufRead, Write};
|
||||
use std::{io, ops::Range};
|
||||
|
||||
use legacy::Message;
|
||||
|
||||
|
|
@ -240,6 +240,23 @@ impl<C: Codec> proc_macro_srv::ProcMacroClientInterface for ProcMacroClientHandl
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn byte_range(
|
||||
&mut self,
|
||||
proc_macro_srv::span::Span { range, anchor, ctx: _ }: proc_macro_srv::span::Span,
|
||||
) -> Range<usize> {
|
||||
match self.roundtrip(bidirectional::SubRequest::ByteRange {
|
||||
file_id: anchor.file_id.as_u32(),
|
||||
ast_id: anchor.ast_id.into_raw(),
|
||||
start: range.start().into(),
|
||||
end: range.end().into(),
|
||||
}) {
|
||||
Some(bidirectional::BidirectionalMessage::SubResponse(
|
||||
bidirectional::SubResponse::ByteRangeResult { range },
|
||||
)) => range,
|
||||
_ => Range { start: range.start().into(), end: range.end().into() },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_expand_ra<C: Codec>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue