Example #1
0
        public static DelegateDeclarationSyntax InsertModifier(DelegateDeclarationSyntax delegateDeclaration, SyntaxKind modifierKind)
        {
            if (delegateDeclaration == null)
            {
                throw new ArgumentNullException(nameof(delegateDeclaration));
            }

            return(delegateDeclaration.WithModifiers(InsertModifier(delegateDeclaration.Modifiers, modifierKind)));
        }
Example #2
0
 public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
 {
     if (!ShouldPublicize(node.AttributeLists))
     {
         return(base.VisitDelegateDeclaration(node));
     }
     logger("Publicize delegate '{0}'", node.Identifier.Text);
     return(node
            .WithModifiers(MakePublic(node.Modifiers)));
 }
Example #3
0
        public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
        {
            var shouldRemoveModifier = ShouldRemoveModifier(node);

            node = (DelegateDeclarationSyntax)base.VisitDelegateDeclaration(node);

            // If this is a top level type, remove the modifier keyword as it's not needed
            if (shouldRemoveModifier)
            {
                node = node.WithModifiers(SyntaxFactory.TokenList(node.Modifiers.Where(IsImportantTypeModifier)));
            }

            return(node);
        }
Example #4
0
        public static DelegateDeclarationSyntax InsertModifier(DelegateDeclarationSyntax delegateDeclaration, SyntaxToken modifier, IModifierComparer comparer)
        {
            if (delegateDeclaration == null)
            {
                throw new ArgumentNullException(nameof(delegateDeclaration));
            }

            SyntaxTokenList modifiers = delegateDeclaration.Modifiers;

            if (!modifiers.Any())
            {
                SyntaxToken delegateKeyword = delegateDeclaration.DelegateKeyword;

                return(delegateDeclaration
                       .WithDelegateKeyword(delegateKeyword.WithoutLeadingTrivia())
                       .WithModifiers(TokenList(modifier.WithLeadingTrivia(delegateKeyword.LeadingTrivia))));
            }

            return(delegateDeclaration.WithModifiers(modifiers.InsertModifier(modifier, comparer)));
        }
Example #5
0
 public override SyntaxNode VisitDelegateDeclaration(DelegateDeclarationSyntax node)
 {
     node = node.WithModifiers(RemoveDefaultAccessModifier2(node.Modifiers));
     return(base.VisitDelegateDeclaration(node));
 }