Exemplo n.º 1
0
        public static EventFieldDeclarationSyntax InsertModifier(EventFieldDeclarationSyntax eventFieldDeclaration, SyntaxKind modifierKind)
        {
            if (eventFieldDeclaration == null)
            {
                throw new ArgumentNullException(nameof(eventFieldDeclaration));
            }

            return(eventFieldDeclaration.WithModifiers(InsertModifier(eventFieldDeclaration.Modifiers, modifierKind)));
        }
        public static EventFieldDeclarationSyntax AddStaticModifier(EventFieldDeclarationSyntax node)
        {
            if (!node.Modifiers.Contains(SyntaxKind.StaticKeyword))
            {
                return(node.WithModifiers(AddStaticModifier(node.Modifiers)));
            }

            return(node);
        }
        private static EventFieldDeclarationSyntax MakeAbstract(EventFieldDeclarationSyntax eventDeclaration)
        {
            if (eventDeclaration == null)
            {
                throw new ArgumentNullException(nameof(eventDeclaration));
            }

            SyntaxTokenList modifiers = eventDeclaration.Modifiers;

            if (!modifiers.Contains(SyntaxKind.AbstractKeyword))
            {
                modifiers = modifiers.Add(SyntaxFactory.Token(SyntaxKind.AbstractKeyword));
            }

            return(eventDeclaration
                   .WithModifiers(modifiers));
        }
Exemplo n.º 4
0
        public static EventFieldDeclarationSyntax InsertModifier(EventFieldDeclarationSyntax eventFieldDeclaration, SyntaxToken modifier, IModifierComparer comparer)
        {
            if (eventFieldDeclaration == null)
            {
                throw new ArgumentNullException(nameof(eventFieldDeclaration));
            }

            SyntaxTokenList modifiers = eventFieldDeclaration.Modifiers;

            if (!modifiers.Any())
            {
                SyntaxToken eventKeyword = eventFieldDeclaration.EventKeyword;

                return(eventFieldDeclaration
                       .WithEventKeyword(eventKeyword.WithoutLeadingTrivia())
                       .WithModifiers(TokenList(modifier.WithLeadingTrivia(eventKeyword.LeadingTrivia))));
            }

            return(eventFieldDeclaration.WithModifiers(modifiers.InsertModifier(modifier, comparer)));
        }
Exemplo n.º 5
0
 public override SyntaxNode VisitEventFieldDeclaration(EventFieldDeclarationSyntax node)
 {
     node = node.WithModifiers(RemoveDefaultAccessModifier2(node.Modifiers));
     return(base.VisitEventFieldDeclaration(node));
 }