Skip to content

Commit

Permalink
Make the requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aradalvand committed Jun 21, 2024
1 parent 082be91 commit 90be032
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,4 @@ public static string StaticMethodString(IMethodSymbol method)
SyntaxFactory.TypeArgumentList(CommaSeparatedList(argSyntaxes));

private static ArgumentListSyntax ArgumentList(params ArgumentSyntax[] args) => SyntaxFactory.ArgumentList(CommaSeparatedList(args));

private static ArgumentListSyntax ArgumentList(IEnumerable<ArgumentSyntax> args) =>
SyntaxFactory.ArgumentList(CommaSeparatedList(args));
}
8 changes: 4 additions & 4 deletions src/Riok.Mapperly/Emit/Syntax/SyntaxFactoryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public static SeparatedSyntaxList<T> CommaSeparatedList<T>(params T[] nodes)
return SeparatedList<T>(joinedNodes);
}

public SeparatedSyntaxList<T> ConditionalCommaLineFeedSeparatedList<T>(IEnumerable<T> nodes)
private SeparatedSyntaxList<T> ConditionalCommaLineFeedSeparatedList<T>(IEnumerable<T> nodes)
where T : SyntaxNode
{
const int MultilineSeparatedListThreshold = 20;
var nodesList = nodes.ToList();
var sep = Token(SyntaxKind.CommaToken);
if (nodesList.Count > 1)
if (nodesList.Sum(x => x.FullSpan.Length) > MultilineSeparatedListThreshold)
{
sep = sep.AddTrailingLineFeed(Indentation + 1);
nodesList[0] = nodesList[0].AddLeadingLineFeed(Indentation + 1);
nodesList[^1] = nodesList[^1].AddTrailingLineFeed(Indentation);
}
var joinedNodes = Join(sep, false, nodesList);
var result = SeparatedList<T>(joinedNodes);
return result;
return SeparatedList<T>(joinedNodes);
}

private SeparatedSyntaxList<T> CommaLineFeedSeparatedList<T>(IEnumerable<T> nodes)
Expand Down

0 comments on commit 90be032

Please sign in to comment.