private static SyntaxNode HandleDelegateDeclaration(DelegateDeclarationSyntax node) { SyntaxToken triviaToken = node.DelegateKeyword; if (triviaToken.IsMissing) { return(null); } SyntaxKind defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword; SyntaxTokenList modifiers = AddModifier(node.Modifiers, ref triviaToken, defaultVisibility); return(node .WithDelegateKeyword(triviaToken) .WithModifiers(modifiers) .WithoutFormatting()); }
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))); }