private static SyntaxNode HandleEnumDeclaration(EnumDeclarationSyntax node)
        {
            SyntaxToken triviaToken = node.EnumKeyword;

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

            SyntaxKind      defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword;
            SyntaxTokenList modifiers         = AddModifier(node.Modifiers, ref triviaToken, defaultVisibility);

            return(node
                   .WithEnumKeyword(triviaToken)
                   .WithModifiers(modifiers)
                   .WithoutFormatting());
        }
Exemple #2
0
        public static EnumDeclarationSyntax InsertModifier(EnumDeclarationSyntax enumDeclaration, SyntaxToken modifier, IModifierComparer comparer)
        {
            if (enumDeclaration == null)
            {
                throw new ArgumentNullException(nameof(enumDeclaration));
            }

            SyntaxTokenList modifiers = enumDeclaration.Modifiers;

            if (!modifiers.Any())
            {
                SyntaxToken enumKeyword = enumDeclaration.EnumKeyword;

                return(enumDeclaration
                       .WithEnumKeyword(enumKeyword.WithoutLeadingTrivia())
                       .WithModifiers(TokenList(modifier.WithLeadingTrivia(enumKeyword.LeadingTrivia))));
            }

            return(enumDeclaration.WithModifiers(modifiers.InsertModifier(modifier, comparer)));
        }
        private static SyntaxNode HandleEnumDeclaration(EnumDeclarationSyntax node)
        {
            SyntaxToken triviaToken = node.EnumKeyword;
            if (triviaToken.IsMissing)
            {
                return null;
            }

            SyntaxKind defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword;
            SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref triviaToken, defaultVisibility);
            return node
                .WithEnumKeyword(triviaToken)
                .WithModifiers(modifiers)
                .WithoutFormatting();
        }