Merge #4593
4593: Document some rust-analyzer specific protocol extensions r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
@@ -38,13 +38,6 @@ pub struct SyntaxTreeParams {
|
||||
pub range: Option<Range>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExpandedMacro {
|
||||
pub name: String,
|
||||
pub expansion: String,
|
||||
}
|
||||
|
||||
pub enum ExpandMacro {}
|
||||
|
||||
impl Request for ExpandMacro {
|
||||
@@ -60,19 +53,26 @@ pub struct ExpandMacroParams {
|
||||
pub position: Option<Position>,
|
||||
}
|
||||
|
||||
pub enum FindMatchingBrace {}
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExpandedMacro {
|
||||
pub name: String,
|
||||
pub expansion: String,
|
||||
}
|
||||
|
||||
impl Request for FindMatchingBrace {
|
||||
type Params = FindMatchingBraceParams;
|
||||
pub enum MatchingBrace {}
|
||||
|
||||
impl Request for MatchingBrace {
|
||||
type Params = MatchingBraceParams;
|
||||
type Result = Vec<Position>;
|
||||
const METHOD: &'static str = "rust-analyzer/findMatchingBrace";
|
||||
const METHOD: &'static str = "experimental/matchingBrace";
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct FindMatchingBraceParams {
|
||||
pub struct MatchingBraceParams {
|
||||
pub text_document: TextDocumentIdentifier,
|
||||
pub offsets: Vec<Position>,
|
||||
pub positions: Vec<Position>,
|
||||
}
|
||||
|
||||
pub enum ParentModule {}
|
||||
|
||||
@@ -509,9 +509,7 @@ fn on_request(
|
||||
.on_sync::<lsp_types::request::SelectionRangeRequest>(|s, p| {
|
||||
handlers::handle_selection_range(s.snapshot(), p)
|
||||
})?
|
||||
.on_sync::<lsp_ext::FindMatchingBrace>(|s, p| {
|
||||
handlers::handle_find_matching_brace(s.snapshot(), p)
|
||||
})?
|
||||
.on_sync::<lsp_ext::MatchingBrace>(|s, p| handlers::handle_matching_brace(s.snapshot(), p))?
|
||||
.on::<lsp_ext::AnalyzerStatus>(handlers::handle_analyzer_status)?
|
||||
.on::<lsp_ext::SyntaxTree>(handlers::handle_syntax_tree)?
|
||||
.on::<lsp_ext::ExpandMacro>(handlers::handle_expand_macro)?
|
||||
|
||||
@@ -126,15 +126,15 @@ pub fn handle_selection_range(
|
||||
Ok(Some(res?))
|
||||
}
|
||||
|
||||
pub fn handle_find_matching_brace(
|
||||
pub fn handle_matching_brace(
|
||||
world: WorldSnapshot,
|
||||
params: lsp_ext::FindMatchingBraceParams,
|
||||
params: lsp_ext::MatchingBraceParams,
|
||||
) -> Result<Vec<Position>> {
|
||||
let _p = profile("handle_find_matching_brace");
|
||||
let _p = profile("handle_matching_brace");
|
||||
let file_id = from_proto::file_id(&world, ¶ms.text_document.uri)?;
|
||||
let line_index = world.analysis().file_line_index(file_id)?;
|
||||
let res = params
|
||||
.offsets
|
||||
.positions
|
||||
.into_iter()
|
||||
.map(|position| {
|
||||
let offset = from_proto::offset(&line_index, position);
|
||||
|
||||
Reference in New Issue
Block a user