@@ -9,7 +9,7 @@ import type { AstPath, Doc, ParserOptions } from 'prettier';
99import type { AstNode } from '../slang-nodes' ;
1010import type { PrintFunction , SlangNode } from '../types' ;
1111
12- const { group, indent , line } = doc . builders ;
12+ const { group, indentIfBreak } = doc . builders ;
1313
1414export class TupleDeconstructionStatement implements SlangNode {
1515 readonly kind = NonterminalKind . TupleDeconstructionStatement ;
@@ -50,15 +50,16 @@ export class TupleDeconstructionStatement implements SlangNode {
5050 path : AstPath < TupleDeconstructionStatement > ,
5151 print : PrintFunction
5252 ) : Doc {
53+ const declarationDoc = group (
54+ [ this . varKeyword ? 'var (' : '(' , path . call ( print , 'elements' ) , ')' ] ,
55+ { id : Symbol ( 'Slang.VariableDeclarationStatement.variables' ) }
56+ ) ;
57+
5358 return [
54- this . varKeyword ? 'var ' : '' ,
55- '(' ,
56- path . call ( print , 'elements' ) ,
57- typeof this . expression . variant !== 'string' &&
58- this . expression . variant . kind === NonterminalKind . TupleExpression
59- ? [ ') = ' , path . call ( print , 'expression' ) ]
60- : group ( [ ') =' , indent ( [ line , path . call ( print , 'expression' ) ] ) ] ) ,
61- ';'
59+ declarationDoc ,
60+ indentIfBreak ( [ ' = ' , path . call ( print , 'expression' ) , ';' ] , {
61+ groupId : declarationDoc . id !
62+ } )
6263 ] ;
6364 }
6465}
0 commit comments