Skip to content

Commit

Permalink
Add 'simple_multistatement_lambdas' tests, align formatter, and fix l…
Browse files Browse the repository at this point in the history
…exer
  • Loading branch information
Scony committed Sep 12, 2024
1 parent 0373e49 commit e3c5a02
Show file tree
Hide file tree
Showing 6 changed files with 517 additions and 1 deletion.
1 change: 1 addition & 0 deletions gdtoolkit/formatter/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def _format_foldable_to_multiple_lines(
"c_dict_element": _format_kv_pair_to_multiple_lines,
"eq_dict_element": _format_kv_pair_to_multiple_lines,
"lambda": _format_lambda_to_multiple_lines,
"lambda_header": _format_lambda_header_to_multiple_lines,
# fake expressions:
"func_args": _format_args_to_multiple_lines,
"func_arg_regular": _format_func_arg_to_multiple_lines,
Expand Down
4 changes: 3 additions & 1 deletion gdtoolkit/parser/gdscript_indenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def handle_NL(self, token: Token) -> Iterator[Token]:
else:
while indent < self.indent_level[-1]:
self.indent_level.pop()
yield Token.new_borrow_pos(self.DEDENT_type, indent_str, token)
yield Token(
self.DEDENT_type, indent_str, None, token.line, None, token.line
)
# produce extra newline after dedent to simplify grammar:
yield token

Expand Down
15 changes: 15 additions & 0 deletions tests/formatter/input-output-pairs/long_unistatement_lambdas.in.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
func xyz(x):
pass
func foo():
var x1 = func(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): pass
var x2 = func(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23) -> int: return 1
var x3 = func bar(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): pass
var x4 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23) -> int: return 1

var x5 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): return [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var x6 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): xyz([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
var x8 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): var xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
var x9 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): var x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var x10 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): var xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:int
var x11 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): var x:Array=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
var x12 = func baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23): var x:=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Loading

0 comments on commit e3c5a02

Please sign in to comment.