private static LocalFunctionStatementSyntax GetNewNode( LocalFunctionStatementSyntax localFunctionStatement, TypeParameterConstraintSyntax constraint, SemanticModel semanticModel, CancellationToken cancellationToken) { string name = GetMethodTypeParameterName(semanticModel, localFunctionStatement.BodyOrExpressionBody().SpanStart, cancellationToken); LocalFunctionStatementSyntax newNode = localFunctionStatement.AddTypeParameterListParameters(TypeParameter(Identifier(name).WithRenameAnnotation())); if (constraint != null) { newNode = newNode.AddConstraintClauses(TypeParameterConstraintClause(name, constraint)); } return(newNode); }
private LocalFunctionStatementSyntax CreateFunctionStatement(FunctionDeclaration node) { LocalFunctionStatementSyntax funStatement = SyntaxFactory.LocalFunctionStatement(node.Type.ToCsNode <TypeSyntax>(), node.Name.Text); funStatement = funStatement.AddModifiers(node.Modifiers.ToCsNodes <SyntaxToken>()); funStatement = funStatement.AddParameterListParameters(node.Parameters.ToCsNodes <ParameterSyntax>()); if (node.JsDoc.Count > 0) { funStatement = funStatement.WithLeadingTrivia(SyntaxFactory.Trivia(node.JsDoc[0].ToCsNode <DocumentationCommentTriviaSyntax>())); } if (node.TypeParameters.Count > 0) { funStatement = funStatement.AddTypeParameterListParameters(node.TypeParameters.ToCsNodes <TypeParameterSyntax>()); } return(funStatement.WithBody(node.Body.ToCsNode <BlockSyntax>())); }