Skip to content

Commit

Permalink
Don't serialize "startNodes" if it's empty
Browse files Browse the repository at this point in the history
This makes our snapshots and JSON less verbose.
  • Loading branch information
adamchalmers committed Nov 5, 2024
1 parent d2ec1e5 commit 24faa9f
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 48 deletions.
30 changes: 10 additions & 20 deletions docs/kcl/std.json
Original file line number Diff line number Diff line change
Expand Up @@ -93200,8 +93200,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -96944,8 +96943,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -100692,8 +100690,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -130888,8 +130885,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -135023,8 +135019,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -138765,8 +138760,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -142918,8 +142912,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -147053,8 +147046,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -150797,8 +150789,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down Expand Up @@ -154539,8 +154530,7 @@
"NonCodeMeta": {
"type": "object",
"required": [
"nonCodeNodes",
"startNodes"
"nonCodeNodes"
],
"properties": {
"nonCodeNodes": {
Expand Down
2 changes: 2 additions & 0 deletions src/wasm-lib/kcl/src/ast/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ pub enum NonCodeValue {
#[serde(rename_all = "camelCase")]
pub struct NonCodeMeta {
pub non_code_nodes: HashMap<usize, NodeList<NonCodeNode>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub start_nodes: NodeList<NonCodeNode>,

#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -1059,6 +1060,7 @@ impl<'de> Deserialize<'de> for NonCodeMeta {
#[serde(rename_all = "camelCase")]
struct NonCodeMetaHelper {
non_code_nodes: HashMap<String, NodeList<NonCodeNode>>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
start_nodes: NodeList<NonCodeNode>,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand Down Expand Up @@ -60,8 +61,7 @@ expression: actual
}
}
]
},
"startNodes": []
}
},
"start": 14,
"type": "ArrayExpression",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand Down Expand Up @@ -60,8 +61,7 @@ expression: actual
}
}
]
},
"startNodes": []
}
},
"start": 14,
"type": "ArrayExpression",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand Down Expand Up @@ -30,8 +31,7 @@ expression: actual
}
}
]
},
"startNodes": []
}
},
"properties": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand Down Expand Up @@ -30,8 +31,7 @@ expression: actual
}
}
]
},
"startNodes": []
}
},
"properties": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand Down Expand Up @@ -106,8 +107,7 @@ expression: actual
}
}
]
},
"startNodes": []
}
},
"start": 19,
"type": "PipeExpression",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: kcl/src/parser/parser_impl.rs
expression: actual
snapshot_kind: text
---
{
"body": [
Expand Down Expand Up @@ -48,8 +49,7 @@ expression: actual
}
}
]
},
"startNodes": []
}
},
"start": 0
}
3 changes: 1 addition & 2 deletions src/wasm-lib/kcl/tests/add_lots/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3197,8 +3197,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 0
}
Expand Down
3 changes: 1 addition & 2 deletions src/wasm-lib/kcl/tests/array_range_expr/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 0
}
Expand Down
3 changes: 1 addition & 2 deletions src/wasm-lib/kcl/tests/comparisons/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 0
}
Expand Down
6 changes: 2 additions & 4 deletions src/wasm-lib/kcl/tests/cube/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 30
},
Expand Down Expand Up @@ -787,8 +786,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 0
}
Expand Down
3 changes: 1 addition & 2 deletions src/wasm-lib/kcl/tests/cube/program_memory.snap
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 30
},
Expand Down
3 changes: 1 addition & 2 deletions src/wasm-lib/kcl/tests/double_map_fn/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 0
}
Expand Down
3 changes: 1 addition & 2 deletions src/wasm-lib/kcl/tests/sketch_in_object/ast.snap
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,7 @@ snapshot_kind: text
}
}
]
},
"startNodes": []
}
},
"start": 0
}
Expand Down

0 comments on commit 24faa9f

Please sign in to comment.