From 24faa9fb8c271dfe4978d6b77d6a2a428287749c Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Thu, 31 Oct 2024 13:19:28 -0500 Subject: [PATCH] Don't serialize "startNodes" if it's empty This makes our snapshots and JSON less verbose. --- docs/kcl/std.json | 30 +++++++------------ src/wasm-lib/kcl/src/ast/types.rs | 2 ++ ...rser__parser_impl__snapshot_tests__aw.snap | 4 +-- ...rser__parser_impl__snapshot_tests__ax.snap | 4 +-- ...rser__parser_impl__snapshot_tests__ay.snap | 4 +-- ...rser__parser_impl__snapshot_tests__az.snap | 4 +-- ...rser__parser_impl__snapshot_tests__ba.snap | 4 +-- ...arser__parser_impl__snapshot_tests__f.snap | 4 +-- src/wasm-lib/kcl/tests/add_lots/ast.snap | 3 +- .../kcl/tests/array_range_expr/ast.snap | 3 +- src/wasm-lib/kcl/tests/comparisons/ast.snap | 3 +- src/wasm-lib/kcl/tests/cube/ast.snap | 6 ++-- .../kcl/tests/cube/program_memory.snap | 3 +- src/wasm-lib/kcl/tests/double_map_fn/ast.snap | 3 +- .../kcl/tests/sketch_in_object/ast.snap | 3 +- 15 files changed, 32 insertions(+), 48 deletions(-) diff --git a/docs/kcl/std.json b/docs/kcl/std.json index 2a49b6a5fc..2f7b82a7d8 100644 --- a/docs/kcl/std.json +++ b/docs/kcl/std.json @@ -93200,8 +93200,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -96944,8 +96943,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -100692,8 +100690,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -130888,8 +130885,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -135023,8 +135019,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -138765,8 +138760,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -142918,8 +142912,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -147053,8 +147046,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -150797,8 +150789,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { @@ -154539,8 +154530,7 @@ "NonCodeMeta": { "type": "object", "required": [ - "nonCodeNodes", - "startNodes" + "nonCodeNodes" ], "properties": { "nonCodeNodes": { diff --git a/src/wasm-lib/kcl/src/ast/types.rs b/src/wasm-lib/kcl/src/ast/types.rs index e197f149d6..4310eff863 100644 --- a/src/wasm-lib/kcl/src/ast/types.rs +++ b/src/wasm-lib/kcl/src/ast/types.rs @@ -1029,6 +1029,7 @@ pub enum NonCodeValue { #[serde(rename_all = "camelCase")] pub struct NonCodeMeta { pub non_code_nodes: HashMap>, + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub start_nodes: NodeList, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1059,6 +1060,7 @@ impl<'de> Deserialize<'de> for NonCodeMeta { #[serde(rename_all = "camelCase")] struct NonCodeMetaHelper { non_code_nodes: HashMap>, + #[serde(default, skip_serializing_if = "Vec::is_empty")] start_nodes: NodeList, } diff --git a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__aw.snap b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__aw.snap index db78d6395a..7b8f80bd14 100644 --- a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__aw.snap +++ b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__aw.snap @@ -1,6 +1,7 @@ --- source: kcl/src/parser/parser_impl.rs expression: actual +snapshot_kind: text --- { "body": [ @@ -60,8 +61,7 @@ expression: actual } } ] - }, - "startNodes": [] + } }, "start": 14, "type": "ArrayExpression", diff --git a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ax.snap b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ax.snap index 5598578f6e..9325e983bd 100644 --- a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ax.snap +++ b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ax.snap @@ -1,6 +1,7 @@ --- source: kcl/src/parser/parser_impl.rs expression: actual +snapshot_kind: text --- { "body": [ @@ -60,8 +61,7 @@ expression: actual } } ] - }, - "startNodes": [] + } }, "start": 14, "type": "ArrayExpression", diff --git a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ay.snap b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ay.snap index 4599b186de..60af233e36 100644 --- a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ay.snap +++ b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ay.snap @@ -1,6 +1,7 @@ --- source: kcl/src/parser/parser_impl.rs expression: actual +snapshot_kind: text --- { "body": [ @@ -30,8 +31,7 @@ expression: actual } } ] - }, - "startNodes": [] + } }, "properties": [ { diff --git a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__az.snap b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__az.snap index fc06a858dd..ad416a37ae 100644 --- a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__az.snap +++ b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__az.snap @@ -1,6 +1,7 @@ --- source: kcl/src/parser/parser_impl.rs expression: actual +snapshot_kind: text --- { "body": [ @@ -30,8 +31,7 @@ expression: actual } } ] - }, - "startNodes": [] + } }, "properties": [ { diff --git a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ba.snap b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ba.snap index 0a9ac7936f..1cfc7fa501 100644 --- a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ba.snap +++ b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__ba.snap @@ -1,6 +1,7 @@ --- source: kcl/src/parser/parser_impl.rs expression: actual +snapshot_kind: text --- { "body": [ @@ -106,8 +107,7 @@ expression: actual } } ] - }, - "startNodes": [] + } }, "start": 19, "type": "PipeExpression", diff --git a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__f.snap b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__f.snap index e9608c3f78..5eadacf87a 100644 --- a/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__f.snap +++ b/src/wasm-lib/kcl/src/parser/snapshots/kcl_lib__parser__parser_impl__snapshot_tests__f.snap @@ -1,6 +1,7 @@ --- source: kcl/src/parser/parser_impl.rs expression: actual +snapshot_kind: text --- { "body": [ @@ -48,8 +49,7 @@ expression: actual } } ] - }, - "startNodes": [] + } }, "start": 0 } diff --git a/src/wasm-lib/kcl/tests/add_lots/ast.snap b/src/wasm-lib/kcl/tests/add_lots/ast.snap index 0d100ee384..bbb2c39c85 100644 --- a/src/wasm-lib/kcl/tests/add_lots/ast.snap +++ b/src/wasm-lib/kcl/tests/add_lots/ast.snap @@ -3197,8 +3197,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 0 } diff --git a/src/wasm-lib/kcl/tests/array_range_expr/ast.snap b/src/wasm-lib/kcl/tests/array_range_expr/ast.snap index 8cf38bce14..168bc05a3a 100644 --- a/src/wasm-lib/kcl/tests/array_range_expr/ast.snap +++ b/src/wasm-lib/kcl/tests/array_range_expr/ast.snap @@ -848,8 +848,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 0 } diff --git a/src/wasm-lib/kcl/tests/comparisons/ast.snap b/src/wasm-lib/kcl/tests/comparisons/ast.snap index 6d89ed5633..6de399b7a9 100644 --- a/src/wasm-lib/kcl/tests/comparisons/ast.snap +++ b/src/wasm-lib/kcl/tests/comparisons/ast.snap @@ -651,8 +651,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 0 } diff --git a/src/wasm-lib/kcl/tests/cube/ast.snap b/src/wasm-lib/kcl/tests/cube/ast.snap index 88234fe25f..3366d2b011 100644 --- a/src/wasm-lib/kcl/tests/cube/ast.snap +++ b/src/wasm-lib/kcl/tests/cube/ast.snap @@ -664,8 +664,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 30 }, @@ -787,8 +786,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 0 } diff --git a/src/wasm-lib/kcl/tests/cube/program_memory.snap b/src/wasm-lib/kcl/tests/cube/program_memory.snap index 6e8b18ae96..ba5ed26e6f 100644 --- a/src/wasm-lib/kcl/tests/cube/program_memory.snap +++ b/src/wasm-lib/kcl/tests/cube/program_memory.snap @@ -681,8 +681,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 30 }, diff --git a/src/wasm-lib/kcl/tests/double_map_fn/ast.snap b/src/wasm-lib/kcl/tests/double_map_fn/ast.snap index b628c84919..32176a961a 100644 --- a/src/wasm-lib/kcl/tests/double_map_fn/ast.snap +++ b/src/wasm-lib/kcl/tests/double_map_fn/ast.snap @@ -226,8 +226,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 0 } diff --git a/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap b/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap index 09faa9846b..716c3407e3 100644 --- a/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap +++ b/src/wasm-lib/kcl/tests/sketch_in_object/ast.snap @@ -837,8 +837,7 @@ snapshot_kind: text } } ] - }, - "startNodes": [] + } }, "start": 0 }