-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit-id:8fdc1e29
- Loading branch information
Showing
8 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "scarb-proc-macro-server-types" | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
homepage.workspace = true | ||
license.workspace = true | ||
readme.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
cairo-lang-macro = { path = "../../plugins/cairo-lang-macro", features = ["serde"], version = "0.1.0"} | ||
serde.workspace = true | ||
serde_json.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub type RequestId = u64; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RpcResponse { | ||
pub id: RequestId, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub result: Option<serde_json::Value>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub error: Option<ResponseError>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct ResponseError { | ||
pub message: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct RpcRequest { | ||
pub id: RequestId, | ||
pub method: String, | ||
pub value: serde_json::Value, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod jsonrpc; | ||
pub mod methods; |
22 changes: 22 additions & 0 deletions
22
utils/scarb-proc-macro-server-types/src/methods/defined_macros.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use super::Method; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Default, Serialize, Deserialize)] | ||
pub struct DefinedMacrosResponse { | ||
pub attributes: Vec<String>, | ||
pub inline_macros: Vec<String>, | ||
pub derives: Vec<String>, | ||
pub executables: Vec<String>, | ||
} | ||
|
||
#[derive(Debug, Default, Serialize, Deserialize)] | ||
pub struct DefinedMacrosParams {} | ||
|
||
pub struct DefinedMacros; | ||
|
||
impl Method for DefinedMacros { | ||
const METHOD: &'static str = "definedMacros"; | ||
|
||
type Params = DefinedMacrosParams; | ||
type Response = DefinedMacrosResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use super::Method; | ||
use super::ProcMacroResult; | ||
use cairo_lang_macro::TokenStream; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] | ||
pub struct ExpandAttributeParams { | ||
pub attr: String, | ||
pub args: TokenStream, | ||
pub item: TokenStream, | ||
} | ||
|
||
pub struct ExpandAttribute; | ||
|
||
impl Method for ExpandAttribute { | ||
const METHOD: &'static str = "expandAttribute"; | ||
|
||
type Params = ExpandAttributeParams; | ||
type Response = ProcMacroResult; | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] | ||
pub struct ExpandDeriveParams { | ||
pub derives: Vec<String>, | ||
pub item: TokenStream, | ||
} | ||
|
||
pub struct ExpandDerive; | ||
|
||
impl Method for ExpandDerive { | ||
const METHOD: &'static str = "expandDerive"; | ||
|
||
type Params = ExpandDeriveParams; | ||
type Response = ProcMacroResult; | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] | ||
pub struct ExpandInlineMacroParams { | ||
pub name: String, | ||
pub item: TokenStream, | ||
} | ||
|
||
pub struct ExpandInline; | ||
|
||
impl Method for ExpandInline { | ||
const METHOD: &'static str = "expandInline"; | ||
|
||
type Params = ExpandInlineMacroParams; | ||
type Response = ProcMacroResult; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use cairo_lang_macro::TokenStream; | ||
use serde::{de::DeserializeOwned, Deserialize, Serialize}; | ||
|
||
pub mod defined_macros; | ||
pub mod expand; | ||
|
||
pub trait Method { | ||
const METHOD: &str; | ||
|
||
type Params: Serialize + DeserializeOwned; | ||
type Response: Serialize + DeserializeOwned; | ||
} | ||
|
||
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
pub struct ProcMacroResult { | ||
pub token_stream: TokenStream, | ||
pub diagnostics: Vec<cairo_lang_macro::Diagnostic>, | ||
} |