private static SyntaxNode HandleEventDeclaration(EventDeclarationSyntax node)
        {
            SyntaxToken triviaToken = node.EventKeyword;

            if (triviaToken.IsMissing)
            {
                return(null);
            }

            SyntaxTokenList modifiers = AddModifier(node.Modifiers, ref triviaToken, SyntaxKind.PrivateKeyword);

            return(node
                   .WithEventKeyword(triviaToken)
                   .WithModifiers(modifiers)
                   .WithoutFormatting());
        }
Example #2
0
        public static EventDeclarationSyntax InsertModifier(EventDeclarationSyntax eventDeclaration, SyntaxToken modifier, IModifierComparer comparer)
        {
            if (eventDeclaration == null)
            {
                throw new ArgumentNullException(nameof(eventDeclaration));
            }

            SyntaxTokenList modifiers = eventDeclaration.Modifiers;

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

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

            return(eventDeclaration.WithModifiers(modifiers.InsertModifier(modifier, comparer)));
        }
        private static SyntaxNode HandleEventDeclaration(EventDeclarationSyntax node)
        {
            SyntaxToken triviaToken = node.EventKeyword;
            if (triviaToken.IsMissing)
            {
                return null;
            }

            SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref triviaToken, SyntaxKind.PrivateKeyword);
            return node
                .WithEventKeyword(triviaToken)
                .WithModifiers(modifiers)
                .WithoutFormatting();
        }