Skip to content

Commit

Permalink
Update Formatter.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Oct 23, 2023
1 parent a13b2e1 commit da66869
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/Draco.Compiler/Internal/Syntax/Formatting/Formatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit da66869

Please sign in to comment.