private static async Task <Document> RewriteArgumentList( Document document, ArgumentListSyntax argumentList, SyntaxTrivia openParenTrivia, SyntaxTrivia commaTrivia, SyntaxTrivia parameterTypeTrivia, CancellationToken cancellationToken) { var updatedArguments = argumentList.Arguments.Select( p => p.WithLeadingTrivia(parameterTypeTrivia)); var separators = Enumerable.Repeat( SF.Token(SyntaxKind.CommaToken).WithTrailingTrivia(commaTrivia), argumentList.Arguments.Count() - 1); var updatedParameterList = SF.ArgumentList( SF.Token(SyntaxKind.OpenParenToken).WithTrailingTrivia(openParenTrivia), SF.SeparatedList(updatedArguments, separators), argumentList.CloseParenToken); var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false); var newRoot = root.ReplaceNode(argumentList, updatedParameterList); var newDocument = document.WithSyntaxRoot(newRoot); return(newDocument); }
public IEnumerable <StatementSyntax> GetInitialization() { yield return(SH.LocalDeclaration(SF.IdentifierName("var"), output, SF.ObjectCreationExpression(_stringBuilder.CreateSyntax()) .WithArgumentList(SF.ArgumentList(SF.SeparatedList <ArgumentSyntax>())))); var bufferType = SF.ArrayType(SH.PredefinedType(SyntaxKind.CharKeyword), SF.SingletonList(SF.ArrayRankSpecifier(SF.SingletonSeparatedList((ExpressionSyntax)SH.Literal(BufferSize))))); yield return(SH.LocalDeclaration(SF.IdentifierName("var"), outputBuffer, SF.ArrayCreationExpression(bufferType))); yield return(SH.LocalDeclaration(SH.PredefinedType(SyntaxKind.IntKeyword), outputIndex, SH.Literal(0))); }
private static ArgumentListSyntax ToArgList(params ArgumentSyntax[] arguments) => SF.ArgumentList(SF.SeparatedList(arguments));
public static ExpressionSyntax Call(this ExpressionSyntax expression, string instruction, IEnumerable <ExpressionSyntax> arguments) { return(SF.InvocationExpression(expression.Dot(instruction), SF.ArgumentList(SF.SeparatedList( arguments.Select(x => SF.Argument(x)))))); }
public static ExpressionSyntax Call(this ExpressionSyntax expression, SimpleNameSyntax instruction, params ExpressionSyntax[] arguments) { return(SF.InvocationExpression(expression.Dot(instruction), SF.ArgumentList(SF.SeparatedList( arguments.Select(x => SF.Argument(x)))))); }
public static ExpressionSyntax Invoke(this ExpressionSyntax expression, params ExpressionSyntax[] arguments) { return(SF.InvocationExpression(expression, SF.ArgumentList(SF.SeparatedList( arguments.Select(x => SF.Argument(x)))))); }