aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_api/src
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2021-03-24 07:01:37 +0000
committerEdwin Cheng <[email protected]>2021-03-24 07:01:37 +0000
commita2950fcb052b624c8971f668d61e70c176defe99 (patch)
treead357404a5110c75d413f4908255049aa4dcbfdf /crates/proc_macro_api/src
parentd702f10fb345637e82f3fb9606f5aba243df5365 (diff)
Trim down IPC json size
Diffstat (limited to 'crates/proc_macro_api/src')
-rw-r--r--crates/proc_macro_api/src/rpc.rs30
1 files changed, 26 insertions, 4 deletions
diff --git a/crates/proc_macro_api/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs
index 9a68e2cc5..8f7270afe 100644
--- a/crates/proc_macro_api/src/rpc.rs
+++ b/crates/proc_macro_api/src/rpc.rs
@@ -77,7 +77,11 @@ struct TokenIdDef(u32);
77#[derive(Serialize, Deserialize)] 77#[derive(Serialize, Deserialize)]
78#[serde(remote = "Delimiter")] 78#[serde(remote = "Delimiter")]
79struct DelimiterDef { 79struct DelimiterDef {
80 #[serde(with = "TokenIdDef")] 80 #[serde(
81 with = "TokenIdDef",
82 default = "tt::TokenId::unspecified",
83 skip_serializing_if = "token_id_def::skip_if"
84 )]
81 id: TokenId, 85 id: TokenId,
82 #[serde(with = "DelimiterKindDef")] 86 #[serde(with = "DelimiterKindDef")]
83 kind: DelimiterKind, 87 kind: DelimiterKind,
@@ -116,7 +120,11 @@ enum LeafDef {
116#[serde(remote = "Literal")] 120#[serde(remote = "Literal")]
117struct LiteralDef { 121struct LiteralDef {
118 text: SmolStr, 122 text: SmolStr,
119 #[serde(with = "TokenIdDef")] 123 #[serde(
124 with = "TokenIdDef",
125 default = "tt::TokenId::unspecified",
126 skip_serializing_if = "token_id_def::skip_if"
127 )]
120 id: TokenId, 128 id: TokenId,
121} 129}
122 130
@@ -126,7 +134,11 @@ struct PunctDef {
126 char: char, 134 char: char,
127 #[serde(with = "SpacingDef")] 135 #[serde(with = "SpacingDef")]
128 spacing: Spacing, 136 spacing: Spacing,
129 #[serde(with = "TokenIdDef")] 137 #[serde(
138 with = "TokenIdDef",
139 default = "tt::TokenId::unspecified",
140 skip_serializing_if = "token_id_def::skip_if"
141 )]
130 id: TokenId, 142 id: TokenId,
131} 143}
132 144
@@ -141,10 +153,20 @@ enum SpacingDef {
141#[serde(remote = "Ident")] 153#[serde(remote = "Ident")]
142struct IdentDef { 154struct IdentDef {
143 text: SmolStr, 155 text: SmolStr,
144 #[serde(with = "TokenIdDef")] 156 #[serde(
157 with = "TokenIdDef",
158 default = "tt::TokenId::unspecified",
159 skip_serializing_if = "token_id_def::skip_if"
160 )]
145 id: TokenId, 161 id: TokenId,
146} 162}
147 163
164mod token_id_def {
165 pub(super) fn skip_if(value: &tt::TokenId) -> bool {
166 *value == tt::TokenId::unspecified()
167 }
168}
169
148mod opt_delimiter_def { 170mod opt_delimiter_def {
149 use super::{Delimiter, DelimiterDef}; 171 use super::{Delimiter, DelimiterDef};
150 use serde::{Deserialize, Deserializer, Serialize, Serializer}; 172 use serde::{Deserialize, Deserializer, Serialize, Serializer};