Skip to content

Commit

Permalink
Make sure indexer declarations print consistently with other paramete…
Browse files Browse the repository at this point in the history
…r lists (#1278)

closes #1255
  • Loading branch information
belav committed Jun 3, 2024
1 parent c6e39f6 commit 7653a6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
abstract class ClassName
{
abstract int this[int index] { get; set; }

public string this[
[SomeAttribute] int a________________________________,
[SomeAttribute] int b________________________________
] => someValue;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ internal static class BracketedParameterList
{
public static Doc Print(BracketedParameterListSyntax node, FormattingContext context)
{
return Doc.Concat(
Token.Print(node.OpenBracketToken, context),
SeparatedSyntaxList.Print(node.Parameters, Parameter.Print, " ", context),
Token.Print(node.CloseBracketToken, context)
);
return ParameterList.Print(node, node.OpenBracketToken, node.CloseBracketToken, context);
}
}
14 changes: 12 additions & 2 deletions Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters;
internal static class ParameterList
{
public static Doc Print(ParameterListSyntax node, FormattingContext context)
{
return Print(node, node.OpenParenToken, node.CloseParenToken, context);
}

public static Doc Print(
BaseParameterListSyntax node,
SyntaxToken openToken,
SyntaxToken closeToken,
FormattingContext context
)
{
return Doc.Group(
Token.Print(node.OpenParenToken, context),
Token.Print(openToken, context),
node.Parameters.Count > 0
? Doc.Concat(
Doc.Indent(
Expand All @@ -20,7 +30,7 @@ public static Doc Print(ParameterListSyntax node, FormattingContext context)
Doc.SoftLine
)
: Doc.Null,
Token.Print(node.CloseParenToken, context)
Token.Print(closeToken, context)
);
}
}

0 comments on commit 7653a6d

Please sign in to comment.