1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

feat(core/tools): support @overloads in generated mocks

[no changelog]
This commit is contained in:
matejcik 2022-04-13 10:34:35 +02:00 committed by matejcik
parent 5c493f05ef
commit 0c1eb0c30d

View File

@ -17,6 +17,7 @@ current_indent = 0
current_class = None
current_method = None
current_package = None
current_method_is_overload = False
def split_to_parts(line, mod_desc=None):
@ -24,6 +25,7 @@ def split_to_parts(line, mod_desc=None):
global current_class
global current_method
global current_package
global current_method_is_overload
if line.startswith("package: "):
current_package = line[9:].strip()
@ -34,6 +36,10 @@ def split_to_parts(line, mod_desc=None):
current_class = None
return
if line == "@overload\n":
current_method_is_overload = True
return
if line.startswith("class "):
current_class = line[6:].split("(")[0].strip(":")
current_indent = 0
@ -51,6 +57,10 @@ def split_to_parts(line, mod_desc=None):
yield (current_package, "\n")
current_indent = 4
if current_method_is_overload:
yield (current_package, current_indent * " " + "@overload\n")
current_method_is_overload = False
line = current_indent * " " + line
yield (current_package, line)