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 Oct 31, 2024
1 parent 3cae080 commit d6497cf
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 28 deletions.
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 d6497cf

Please sign in to comment.