Skip to content

Commit d6de6e0

Browse files
committed
add standalone-expression handling for inline-lambda multiline formatting, #154
1 parent 79317ec commit d6de6e0

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

gdtoolkit/formatter/expression.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def _format_foldable_to_multiple_lines(
161161
"lambda_header": _format_lambda_header_to_multiple_lines,
162162
"inline_lambda_statements": _format_inline_lambda_statements_to_multiple_lines,
163163
"return_stmt": _format_return_stmt_to_multiple_lines,
164+
"expr_stmt": lambda e, ec, c: _format_standalone_expression(
165+
e.children[0].children[0], ec, c
166+
),
164167
} # type: Dict[str, Callable]
165168
return handlers[expression.data](expression, expression_context, context)
166169

tests/formatter/input-output-pairs/long-inline-lambdas.in.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
func xyz(x):
2+
pass
13
func foo():
24
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
35
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: pass
@@ -6,3 +8,4 @@ func foo():
68

79
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) -> int: pass;pass;return 123
810
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) -> int: pass;pass;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];pass
11+
var x7 = 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: pass;pass;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]);pass

tests/formatter/input-output-pairs/long-inline-lambdas.out.gd

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
func xyz(x):
2+
pass
3+
4+
15
func foo():
26
var x1 = func(
37
p1,
@@ -190,3 +194,70 @@ func foo():
190194
0,
191195
0
192196
] ; pass
197+
var x7 = func baz(
198+
p1,
199+
p2,
200+
p3,
201+
p4,
202+
p5,
203+
p6,
204+
p7,
205+
p8,
206+
p9,
207+
p10,
208+
p11,
209+
p12,
210+
p13,
211+
p14,
212+
p15,
213+
p16,
214+
p17,
215+
p18,
216+
p19,
217+
p20,
218+
p21,
219+
p22,
220+
p23
221+
) -> int: pass ; pass ; xyz(
222+
[
223+
0,
224+
0,
225+
0,
226+
0,
227+
0,
228+
0,
229+
0,
230+
0,
231+
0,
232+
0,
233+
0,
234+
0,
235+
0,
236+
0,
237+
0,
238+
0,
239+
0,
240+
0,
241+
0,
242+
0,
243+
0,
244+
0,
245+
0,
246+
0,
247+
0,
248+
0,
249+
0,
250+
0,
251+
0,
252+
0,
253+
0,
254+
0,
255+
0,
256+
0,
257+
0,
258+
0,
259+
0,
260+
0,
261+
0
262+
]
263+
) ; pass

0 commit comments

Comments
 (0)