public CSharpSyntaxNode Convert(MethodDeclaration node)
        {
            List <Node> modifiers = node.Modifiers;

            if (this.Context.Config.PreferTypeScriptType && node.Name.Text == "toString" && !node.HasModify(NodeKind.OverrideKeyword))
            {
                modifiers = new List <Node>(modifiers);
                modifiers.Add(NodeHelper.CreateNode(NodeKind.OverrideKeyword));
            }

            MethodDeclarationSyntax csMethod = SyntaxFactory
                                               .MethodDeclaration(node.Type.ToCsNode <TypeSyntax>(), node.Name.Text)
                                               .AddModifiers(modifiers.ToCsNodes <SyntaxToken>())
                                               .AddParameterListParameters(node.Parameters.ToCsNodes <ParameterSyntax>());

            if (node.JsDoc.Count > 0)
            {
                csMethod = csMethod.WithLeadingTrivia(SyntaxFactory.Trivia(node.JsDoc[0].ToCsNode <DocumentationCommentTriviaSyntax>()));
            }
            if (node.TypeParameters.Count > 0)
            {
                csMethod = csMethod.AddTypeParameterListParameters(node.TypeParameters.ToCsNodes <TypeParameterSyntax>());
            }

            if (node.Body == null)
            {
                csMethod = csMethod.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken));
            }
            else
            {
                csMethod = csMethod.WithBody(node.Body.ToCsNode <BlockSyntax>());
            }

            return(csMethod);
        }
        private static MethodDeclarationSyntax GetNewNode(
            MethodDeclarationSyntax methodDeclaration,
            TypeParameterConstraintSyntax constraint,
            SemanticModel semanticModel,
            CancellationToken cancellationToken)
        {
            string name = GetMethodTypeParameterName(semanticModel, methodDeclaration.BodyOrExpressionBody().SpanStart, cancellationToken);

            MethodDeclarationSyntax newNode = methodDeclaration.AddTypeParameterListParameters(TypeParameter(Identifier(name).WithRenameAnnotation()));

            if (constraint != null)
            {
                newNode = newNode.AddConstraintClauses(TypeParameterConstraintClause(name, constraint));
            }

            return(newNode);
        }
        private MethodDeclarationSyntax CreateFunctionDeclaration(FunctionDeclaration node)
        {
            MethodDeclarationSyntax methodDeclaration = SyntaxFactory.MethodDeclaration(node.Type.ToCsNode <TypeSyntax>(), node.Name.Text);

            methodDeclaration = methodDeclaration.AddModifiers(node.Modifiers.ToCsNodes <SyntaxToken>());
            methodDeclaration = methodDeclaration.AddParameterListParameters(node.Parameters.ToCsNodes <ParameterSyntax>());

            if (node.JsDoc.Count > 0)
            {
                methodDeclaration = methodDeclaration.WithLeadingTrivia(SyntaxFactory.Trivia(node.JsDoc[0].ToCsNode <DocumentationCommentTriviaSyntax>()));
            }
            if (node.TypeParameters.Count > 0)
            {
                methodDeclaration = methodDeclaration.AddTypeParameterListParameters(node.TypeParameters.ToCsNodes <TypeParameterSyntax>());
            }

            return(methodDeclaration.WithBody(node.Body.ToCsNode <BlockSyntax>()));
        }
        public CSharpSyntaxNode Convert(MethodSignature node)
        {
            MethodDeclarationSyntax csMethod = SyntaxFactory
                                               .MethodDeclaration(node.Type.ToCsNode <TypeSyntax>(), node.Name.Text)
                                               .AddParameterListParameters(node.Parameters.ToCsNodes <ParameterSyntax>());

            if (node.JsDoc.Count > 0)
            {
                csMethod = csMethod.WithLeadingTrivia(SyntaxFactory.Trivia(node.JsDoc[0].ToCsNode <DocumentationCommentTriviaSyntax>()));
            }

            if (node.TypeParameters.Count > 0)
            {
                csMethod = csMethod.AddTypeParameterListParameters(node.TypeParameters.ToCsNodes <TypeParameterSyntax>());
            }

            return(csMethod.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)));
        }