private Document Delete(Document document, ParameterSyntax node)
        {
            var parameterList = node.FirstAncestorOrSelf<ParameterListSyntax>();
            var newParameterList = parameterList.RemoveNode(node, SyntaxRemoveOptions.KeepNoTrivia);

            return document.ReplaceNodeAsync(parameterList, newParameterList, CancellationToken.None)
                           .WaitAndGetResult_CodeModel(CancellationToken.None);
        }
        private Document Delete(Document document, AttributeArgumentSyntax node)
        {
            var argumentList = node.FirstAncestorOrSelf<AttributeArgumentListSyntax>();
            var newArgumentList = argumentList.RemoveNode(node, SyntaxRemoveOptions.KeepNoTrivia);

            return document.ReplaceNodeAsync(argumentList, newArgumentList, CancellationToken.None)
                           .WaitAndGetResult_CodeModel(CancellationToken.None);
        }
        private Document Delete(Document document, EnumMemberDeclarationSyntax node)
        {
            var enumDeclaration = (EnumDeclarationSyntax)node.Parent;
            var members = enumDeclaration.Members;
            var newMembers = members.Remove(node);
            var newEnumDeclaration = enumDeclaration.WithMembers(newMembers);

            // If we're removing the last enum member, we may need to move any trailing trivia
            // to the enum member that comes before it.
            var memberIndex = members.IndexOf(node);
            if (memberIndex == members.Count - 1 && newMembers.Count > 0)
            {
                var trailingTrivia = node.GetTrailingTrivia();
                var lastMember = newEnumDeclaration.Members.Last();
                newEnumDeclaration = newEnumDeclaration.ReplaceNode(lastMember, lastMember.WithTrailingTrivia(trailingTrivia));
            }

            return document.ReplaceNodeAsync(enumDeclaration, newEnumDeclaration, CancellationToken.None)
                           .WaitAndGetResult_CodeModel(CancellationToken.None);
        }
        private Document Delete(Document document, AttributeSyntax node)
        {
            var attributeList = node.FirstAncestorOrSelf<AttributeListSyntax>();

            // If we don't have anything left, then just delete the whole attribute list.
            if (attributeList.Attributes.Count == 1)
            {
                var text = document.GetTextAsync(CancellationToken.None)
                                   .WaitAndGetResult_CodeModel(CancellationToken.None);

                // Note that we want to keep all leading trivia and delete all trailing trivia.
                var deletionStart = attributeList.SpanStart;
                var deletionEnd = attributeList.FullSpan.End;

                text = text.Replace(TextSpan.FromBounds(deletionStart, deletionEnd), string.Empty);

                return document.WithText(text);
            }
            else
            {
                var newAttributeList = attributeList.RemoveNode(node, SyntaxRemoveOptions.KeepNoTrivia);

                return document.ReplaceNodeAsync(attributeList, newAttributeList, CancellationToken.None)
                               .WaitAndGetResult_CodeModel(CancellationToken.None);
            }
        }
        private Document Delete(Document document, VariableDeclaratorSyntax node)
        {
            var fieldDeclaration = node.FirstAncestorOrSelf<BaseFieldDeclarationSyntax>();

            // If we won't have anything left, then just delete the whole declaration
            if (fieldDeclaration.Declaration.Variables.Count == 1)
            {
                return Delete(document, fieldDeclaration);
            }
            else
            {
                var newFieldDeclaration = fieldDeclaration.RemoveNode(node, SyntaxRemoveOptions.KeepNoTrivia);

                return document.ReplaceNodeAsync(fieldDeclaration, newFieldDeclaration, CancellationToken.None)
                               .WaitAndGetResult_CodeModel(CancellationToken.None);
            }
        }