예제 #1
0
        public static async Task <Document> RefactorAsync(
            Document document,
            ConstructorDeclarationSyntax constructor,
            CancellationToken cancellationToken)
        {
            SyntaxTokenList modifiers = constructor.Modifiers;

            int index = modifiers.IndexOf(SyntaxKind.PublicKeyword);

            Debug.Assert(index != -1, modifiers.ToString());

            if (index != -1)
            {
                SyntaxToken modifier = modifiers[index];

                SyntaxToken newModifier = CSharpFactory.ProtectedKeyword().WithTriviaFrom(modifier);

                return(await document.ReplaceTokenAsync(modifier, newModifier, cancellationToken).ConfigureAwait(false));
            }

            return(document);
        }