Add rust-analyzer-span server feature equivalent to the ID server

This commit is contained in:
Lukas Wirth 2023-12-11 12:16:12 +01:00
parent 3ce35931db
commit a892237ed4
17 changed files with 1159 additions and 558 deletions

View file

@ -20,7 +20,10 @@ use triomphe::Arc;
use serde::{Deserialize, Serialize};
use crate::{
msg::{ExpandMacro, ExpnGlobals, FlatTree, PanicMessage, HAS_GLOBAL_SPANS},
msg::{
flat::serialize_span_data_index_map, ExpandMacro, ExpnGlobals, FlatTree, PanicMessage,
HAS_GLOBAL_SPANS, RUST_ANALYZER_SPAN_SUPPORT,
},
process::ProcMacroProcessSrv,
};
@ -166,6 +169,11 @@ impl ProcMacro {
call_site,
mixed_site,
},
span_data_table: if version >= RUST_ANALYZER_SPAN_SUPPORT {
serialize_span_data_index_map(&span_data_table)
} else {
Vec::new()
},
};
let response = self
@ -178,9 +186,7 @@ impl ProcMacro {
msg::Response::ExpandMacro(it) => {
Ok(it.map(|tree| FlatTree::to_subtree_resolved(tree, version, &span_data_table)))
}
msg::Response::ListMacros(..) | msg::Response::ApiVersionCheck(..) => {
Err(ServerError { message: "unexpected response".to_string(), io: None })
}
_ => Err(ServerError { message: "unexpected response".to_string(), io: None }),
}
}
}