Skip to content

Commit

Permalink
autosync: fix StreamOperation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed Jul 23, 2024
1 parent f7d7127 commit 51c90d6
Showing 1 changed file with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,19 @@ def get_patch(self, captures: [(Node, str)], src: bytes, **kwargs) -> bytes:
"""
query = kwargs["ts_cpp_lang"].query(queue_str)
root_node = kwargs["tree"].root_node
cap = list(
filter(
lambda x: "typ" in x[1],
query.matches(root_node, end_byte=last_op.start_byte),
)
)[-1]
typ = get_text_from_node(src, cap[1]["typ"])
match typ:
case b"int":
res += b"printInt32(" + s_name + b", " + last_op_text + b");"
case b"int64_t":
res += b"printInt64(" + s_name + b", " + last_op_text + b");"
case _:
res += b"SStream_concat0(" + s_name + b", " + last_op_text + b");"
query_result = list(filter(lambda x: "typ" in x[1], query.matches(root_node, end_byte=last_op.start_byte)))
if len(query_result) == 0:
res += b"SStream_concat0(" + s_name + b", " + last_op_text + b");"
else:
cap = query_result[-1]
typ = get_text_from_node(src, cap[1]["typ"])
match typ:
case b"int":
res += b"printInt32(" + s_name + b", " + last_op_text + b");"
case b"int64_t":
res += b"printInt64(" + s_name + b", " + last_op_text + b");"
case _:
res += b"SStream_concat0(" + s_name + b", " + last_op_text + b");"
else:
res += b"SStream_concat0(" + s_name + b", " + last_op_text + b");"
stream = captures[0][0]
Expand Down

0 comments on commit 51c90d6

Please sign in to comment.