private static Task <Document> RefactorAsync(
            Document document,
            SwitchSectionSyntax section,
            SyntaxListSelection <SwitchLabelSyntax> selectedLabels,
            CancellationToken cancellationToken)
        {
            SyntaxList <SwitchLabelSyntax> labels = section.Labels;

            int lastIndex = selectedLabels.LastIndex;

            if (selectedLabels.Last() == labels.Last())
            {
                lastIndex--;
            }

            var switchStatement = (SwitchStatementSyntax)section.Parent;

            SyntaxList <SwitchSectionSyntax> sections = switchStatement.Sections;

            int index = sections.IndexOf(section);

            SyntaxList <SwitchSectionSyntax> newSections = sections
                                                           .ReplaceAt(index, section.RemoveNodes(labels.Take(lastIndex + 1), SyntaxRemoveOptions.KeepNoTrivia))
                                                           .InsertRange(index, CreateSwitchSections(section, selectedLabels, lastIndex));

            SwitchStatementSyntax newSwitchStatement = switchStatement.WithSections(newSections);

            return(document.ReplaceNodeAsync(switchStatement, newSwitchStatement, cancellationToken));
        }