public Func <SyntaxGenerator, ClassDeclarationSyntax, ClassDeclarationSyntax> GetAddParametersToMethodAction(string methodName, string types, string identifiers) { ClassDeclarationSyntax AddParametersToMethod(SyntaxGenerator syntaxGenerator, ClassDeclarationSyntax node) { // if we have more than one method with same name return without making changes var methodNode = GetMethodNode(node, methodName); if (methodNode != null) { MethodDeclarationActions methodActions = new MethodDeclarationActions(); var addParametersToMethodAction = methodActions.GetAddParametersToMethodAction(types, identifiers); var newMethodNode = addParametersToMethodAction(syntaxGenerator, methodNode); node = node.ReplaceNode(methodNode, newMethodNode); } return(node); } return(AddParametersToMethod); }
public Func <SyntaxGenerator, ClassDeclarationSyntax, ClassDeclarationSyntax> GetRemoveMethodParametersAction(string methodName) { ClassDeclarationSyntax RemoveMethodParameters(SyntaxGenerator syntaxGenerator, ClassDeclarationSyntax node) { // if we have more than one method with same name return without making changes var methodNode = GetMethodNode(node, methodName); if (methodNode != null) { MethodDeclarationActions methodActions = new MethodDeclarationActions(); var removeMethodParametersActionFunc = methodActions.GetRemoveMethodParametersAction(); var newMethodNode = removeMethodParametersActionFunc(syntaxGenerator, methodNode); node = node.ReplaceNode(methodNode, newMethodNode); } return(node); } return(RemoveMethodParameters); }
public Func <SyntaxGenerator, ClassDeclarationSyntax, ClassDeclarationSyntax> GetCommentMethodAction(string methodName, string comment = null, string dontUseCTAPrefix = null) { ClassDeclarationSyntax CommentMethod(SyntaxGenerator syntaxGenerator, ClassDeclarationSyntax node) { // if we have more than one method with same name return without making changes var methodNode = GetMethodNode(node, methodName); if (methodNode != null) { MethodDeclarationActions methodActions = new MethodDeclarationActions(); var commentMethodAction = methodActions.GetCommentMethodAction(comment, dontUseCTAPrefix); var newMethodNode = commentMethodAction(syntaxGenerator, methodNode); node = node.ReplaceNode(methodNode, newMethodNode); } return(node); } return(CommentMethod); }
public Func <SyntaxGenerator, ClassDeclarationSyntax, ClassDeclarationSyntax> GetChangeMethodToReturnTaskTypeAction(string methodName) { ClassDeclarationSyntax ChangeMethodToReturnTaskType(SyntaxGenerator syntaxGenerator, ClassDeclarationSyntax node) { // if we have more than one method with same name return without making changes var methodNode = GetMethodNode(node, methodName); if (methodNode != null) { MethodDeclarationActions methodActions = new MethodDeclarationActions(); var changeMethodToReturnTaskTypeActionFunc = methodActions.GetChangeMethodToReturnTaskTypeAction(methodName); var newMethodNode = changeMethodToReturnTaskTypeActionFunc(syntaxGenerator, methodNode); node = node.ReplaceNode(methodNode, newMethodNode); } return(node); } return(ChangeMethodToReturnTaskType); }
public Func <SyntaxGenerator, ClassDeclarationSyntax, ClassDeclarationSyntax> GetAddCommentsToMethodAction(string methodName, string comment, string dontUseCTAPrefix = null) { ClassDeclarationSyntax AddCommentsToMethod(SyntaxGenerator syntaxGenerator, ClassDeclarationSyntax node) { // if we have more than one method with same name return without making changes var methodNode = GetMethodNode(node, methodName); if (methodNode != null) { if (!string.IsNullOrWhiteSpace(comment)) { MethodDeclarationActions methodActions = new MethodDeclarationActions(); var addCommentActionFunc = methodActions.GetAddCommentAction(comment, dontUseCTAPrefix); var newMethodNode = addCommentActionFunc(syntaxGenerator, methodNode); node = node.ReplaceNode(methodNode, newMethodNode); } } return(node); } return(AddCommentsToMethod); }