From da66869ef0bd85dd7922e8bfb2acb6af2b3fc442 Mon Sep 17 00:00:00 2001 From: LPeter1997 Date: Mon, 23 Oct 2023 19:15:11 +0200 Subject: [PATCH] Update Formatter.cs --- .../Internal/Syntax/Formatting/Formatter.cs | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs b/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs index 3916fe4fc..4bb7ff73c 100644 --- a/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs +++ b/src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs @@ -88,8 +88,51 @@ public override SyntaxNode VisitExpressionStatement(ExpressionStatementSyntax no node.Semicolon, Newline)); - public override SyntaxNode VisitGroupingExpression(GroupingExpressionSyntax node) => - node.Update(this.AppendSequence(node.OpenParen, node.Expression, node.CloseParen)); + public override SyntaxNode VisitIfExpression(IfExpressionSyntax node) => node.Update(this.AppendSequence( + node.IfKeyword, + Space, + node.OpenParen, + node.Condition, + node.CloseParen, + Space, + node.Then, + node.Else)); + + public override SyntaxNode VisitElseClause(ElseClauseSyntax node) => node.Update(this.AppendSequence( + Space, + node.ElseKeyword, + Space, + node.Expression)); + + public override SyntaxNode VisitWhileExpression(WhileExpressionSyntax node) => node.Update(this.AppendSequence( + node.WhileKeyword, + Space, + node.OpenParen, + node.Condition, + node.CloseParen, + Space, + node.Then)); + + public override SyntaxNode VisitBlockExpression(BlockExpressionSyntax node) => node.Update(this.AppendSequence( + node.OpenBrace, + Newline, + Indent, + node.Statements, + node.Value, + Unindent, + node.CloseBrace)); + + public override SyntaxNode VisitBinaryExpression(BinaryExpressionSyntax node) => node.Update(this.AppendSequence( + node.Left, + Space, + node.Operator, + Space, + node.Right)); + + public override SyntaxNode VisitGroupingExpression(GroupingExpressionSyntax node) => node.Update(this.AppendSequence( + node.OpenParen, + node.Expression, + node.CloseParen)); public override SyntaxNode VisitTypeSpecifier(TypeSpecifierSyntax node) => node.Update(this.AppendSequence( node.Colon,