Skip to content

Commit 412155a

Browse files
ENT-14274: Insert missing semicolon when missing and not tagged as syntax-error
Ticket: ENT-14274 Changelog: None Signed-off-by: Simon Halvorsen <simon.halvorsen@northern.tech>
1 parent 53770c0 commit 412155a

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/cfengine_cli/format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def format_json_file(filename: str, check: bool) -> FormatResult:
9898

9999
def text(node: Node) -> str:
100100
"""Extract the UTF-8 text content of a tree-sitter node."""
101+
if node and node.is_missing and not node.is_named:
102+
return node.type
101103
if not node.text:
102104
return ""
103105
return node.text.decode("utf-8")

tests/unit/test_format.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def __init__(
4242
self.next_named_sibling = next_named_sibling
4343
self.prev_named_sibling = prev_named_sibling
4444
self.parent = parent
45+
self.is_missing = False
46+
self.is_named = True
4547

4648

4749
def _leaf(node_type, node_text=None):

0 commit comments

Comments
 (0)