Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/proc-macro-api/src/bidirectional_protocol/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ use crate::{
legacy_protocol::msg::{FlatTree, Message, PanicMessage, ServerConfig},
};

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum SubRequest {
FilePath { file_id: u32 },
SourceText { file_id: u32, ast_id: u32, start: u32, end: u32 },
LocalFilePath { file_id: u32 },
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum SubResponse {
FilePathResult { name: String },
SourceTextResult { text: Option<String> },
LocalFilePathResult { name: Option<String> },
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum BidirectionalMessage {
Request(Request),
Response(Response),
SubRequest(SubRequest),
SubResponse(SubResponse),
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Request {
ListMacros { dylib_path: Utf8PathBuf },
ExpandMacro(Box<ExpandMacro>),
ApiVersionCheck {},
SetConfig(ServerConfig),
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Response {
ListMacros(Result<Vec<(String, ProcMacroKind)>, String>),
ExpandMacro(Result<FlatTree, PanicMessage>),
Expand All @@ -47,7 +47,7 @@ pub enum Response {
ExpandMacroExtended(Result<ExpandMacroExtended, PanicMessage>),
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpandMacro {
pub lib: Utf8PathBuf,
pub env: Vec<(String, String)>,
Expand All @@ -56,13 +56,13 @@ pub struct ExpandMacro {
pub data: ExpandMacroData,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpandMacroExtended {
pub tree: FlatTree,
pub span_data_table: Vec<u32>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpandMacroData {
pub macro_body: FlatTree,
pub macro_name: String,
Expand All @@ -76,7 +76,7 @@ pub struct ExpandMacroData {
pub span_data_table: Vec<u32>,
}

#[derive(Clone, Copy, Default, Debug, Serialize, Deserialize)]
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpnGlobals {
#[serde(skip_serializing)]
#[serde(default)]
Expand Down
12 changes: 6 additions & 6 deletions crates/proc-macro-api/src/legacy_protocol/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ pub enum Response {
}

/// Configuration settings for the proc-macro-srv.
#[derive(Debug, Serialize, Deserialize, Default)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(default)]
pub struct ServerConfig {
/// Defines how span data should be handled.
pub span_mode: SpanMode,
}

/// Represents an extended macro expansion response, including span data mappings.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpandMacroExtended {
/// The expanded syntax tree.
pub tree: FlatTree,
Expand All @@ -89,11 +89,11 @@ pub struct ExpandMacroExtended {
}

/// Represents an error message when a macro expansion results in a panic.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PanicMessage(pub String);

/// Represents a macro expansion request sent from the client.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpandMacro {
/// The path to the dynamic library containing the macro.
pub lib: Utf8PathBuf,
Expand All @@ -107,7 +107,7 @@ pub struct ExpandMacro {
}

/// Represents the input data required for expanding a macro.
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpandMacroData {
/// Argument of macro call.
///
Expand All @@ -134,7 +134,7 @@ pub struct ExpandMacroData {
}

/// Represents global expansion settings, including span resolution.
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize)]
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpnGlobals {
/// Determines whether to serialize the expansion settings.
#[serde(skip_serializing)]
Expand Down
Loading
Loading