コード例 #1
0
 public static async Task <Document> RefactorAsync(
     Document document,
     ClassDeclarationSyntax classDeclaration,
     CancellationToken cancellationToken)
 {
     return(await InsertModifierRefactoring.RefactorAsync(document, classDeclaration, SyntaxKind.StaticKeyword, cancellationToken).ConfigureAwait(false));
 }
コード例 #2
0
 public static Task <Document> RefactorAsync(
     Document document,
     ClassDeclarationSyntax classDeclaration,
     CancellationToken cancellationToken)
 {
     return(InsertModifierRefactoring.RefactorAsync(document, classDeclaration, SyntaxKind.StaticKeyword, cancellationToken));
 }
        private static void ComputeRefactoring(RefactoringContext context, MemberDeclarationSyntax memberDeclaration, SyntaxTokenList modifiers)
        {
            if (modifiers.Contains(SyntaxKind.AbstractKeyword) &&
                !modifiers.Contains(SyntaxKind.StaticKeyword))
            {
                SyntaxNode parent = memberDeclaration.Parent;

                Debug.Assert(parent?.IsKind(SyntaxKind.ClassDeclaration, SyntaxKind.InterfaceDeclaration, SyntaxKind.StructDeclaration) == true, parent?.Kind().ToString());

                if (parent?.IsKind(SyntaxKind.ClassDeclaration) == true)
                {
                    var classDeclaration = (ClassDeclarationSyntax)parent;

                    if (CanBeMarkedAsAbstract(classDeclaration))
                    {
                        context.RegisterRefactoring(
                            "Mark containing class as abstract",
                            cancellationToken =>
                        {
                            return(InsertModifierRefactoring.RefactorAsync(
                                       context.Document,
                                       classDeclaration,
                                       SyntaxKind.AbstractKeyword,
                                       cancellationToken));
                        });
                    }
                }
            }
        }
コード例 #4
0
        public static Task <Document> RefactorAsync(
            Document document,
            MemberDeclarationSyntax memberDeclaration,
            CancellationToken cancellationToken)
        {
            var classDeclaration = (ClassDeclarationSyntax)memberDeclaration.Parent;

            return(InsertModifierRefactoring.RefactorAsync(
                       document,
                       classDeclaration,
                       SyntaxKind.AbstractKeyword,
                       cancellationToken));
        }