Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-api/src/msg.rs')
-rw-r--r--crates/proc-macro-api/src/msg.rs45
1 files changed, 42 insertions, 3 deletions
diff --git a/crates/proc-macro-api/src/msg.rs b/crates/proc-macro-api/src/msg.rs
index 18fd9ed728..557ddba5c7 100644
--- a/crates/proc-macro-api/src/msg.rs
+++ b/crates/proc-macro-api/src/msg.rs
@@ -10,28 +10,63 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
use crate::ProcMacroKind;
-pub use crate::msg::flat::{FlatTree, TokenId};
+pub use crate::msg::flat::{
+ deserialize_span_data_index_map, serialize_span_data_index_map, FlatTree, SpanDataIndexMap,
+ TokenId,
+};
// The versions of the server protocol
pub const NO_VERSION_CHECK_VERSION: u32 = 0;
pub const VERSION_CHECK_VERSION: u32 = 1;
pub const ENCODE_CLOSE_SPAN_VERSION: u32 = 2;
pub const HAS_GLOBAL_SPANS: u32 = 3;
+pub const RUST_ANALYZER_SPAN_SUPPORT: u32 = 4;
-pub const CURRENT_API_VERSION: u32 = HAS_GLOBAL_SPANS;
+pub const CURRENT_API_VERSION: u32 = RUST_ANALYZER_SPAN_SUPPORT;
#[derive(Debug, Serialize, Deserialize)]
pub enum Request {
+ /// Since [`NO_VERSION_CHECK_VERSION`]
ListMacros { dylib_path: PathBuf },
+ /// Since [`NO_VERSION_CHECK_VERSION`]
ExpandMacro(ExpandMacro),
+ /// Since [`VERSION_CHECK_VERSION`]
ApiVersionCheck {},
+ /// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
+ SetConfig(ServerConfig),
+}
+
+#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)]
+pub enum SpanMode {
+ #[default]
+ Id,
+ RustAnalyzer,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum Response {
+ /// Since [`NO_VERSION_CHECK_VERSION`]
ListMacros(Result<Vec<(String, ProcMacroKind)>, String>),
+ /// Since [`NO_VERSION_CHECK_VERSION`]
ExpandMacro(Result<FlatTree, PanicMessage>),
+ /// Since [`NO_VERSION_CHECK_VERSION`]
ApiVersionCheck(u32),
+ /// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
+ SetConfig(ServerConfig),
+ /// Since [`RUST_ANALYZER_SPAN_SUPPORT`]
+ ExpandMacroExtended(Result<ExpandMacroExtended, PanicMessage>),
+}
+
+#[derive(Debug, Serialize, Deserialize, Default)]
+#[serde(default)]
+pub struct ServerConfig {
+ pub span_mode: SpanMode,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct ExpandMacroExtended {
+ pub tree: FlatTree,
+ pub span_data_table: Vec<u32>,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -64,9 +99,12 @@ pub struct ExpandMacro {
#[serde(skip_serializing_if = "ExpnGlobals::skip_serializing_if")]
#[serde(default)]
pub has_global_spans: ExpnGlobals,
+ #[serde(skip_serializing_if = "Vec::is_empty")]
+ #[serde(default)]
+ pub span_data_table: Vec<u32>,
}
-#[derive(Default, Debug, Serialize, Deserialize)]
+#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)]
pub struct ExpnGlobals {
#[serde(skip_serializing)]
#[serde(default)]
@@ -241,6 +279,7 @@ mod tests {
call_site: 0,
mixed_site: 0,
},
+ span_data_table: Vec::new(),
};
let json = serde_json::to_string(&task).unwrap();