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

            return(enumDeclaration.WithModifiers(InsertModifier(enumDeclaration.Modifiers, modifierKind)));
        }
Example #2
0
 public override SyntaxNode VisitEnumDeclaration(EnumDeclarationSyntax node)
 {
     if (!ShouldPublicize(node.AttributeLists))
     {
         return(base.VisitEnumDeclaration(node));
     }
     logger("Publicize enum '{0}'", node.Identifier.Text);
     return(node
            .WithModifiers(MakePublic(node.Modifiers)));
 }
Example #3
0
        public static EnumDeclarationSyntax WithModifiers(this EnumDeclarationSyntax enumDeclarationSyntax, params SyntaxKind[] modifiers)
        {
            var tokenList = new SyntaxTokenList();

            foreach (var modifier in modifiers)
            {
                tokenList = tokenList.Add(SyntaxFactory.Token(modifier));
            }
            return(enumDeclarationSyntax.WithModifiers(tokenList));
        }
Example #4
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)));
        }
Example #5
0
 public override SyntaxNode VisitEnumDeclaration(EnumDeclarationSyntax node)
 {
     node = node.WithModifiers(RemoveDefaultAccessModifier2(node.Modifiers));
     return(base.VisitEnumDeclaration(node));
 }
Example #6
0
 public static EnumDeclarationSyntax WithModifiers(this EnumDeclarationSyntax enumSyntax, IEnumerable <SyntaxToken> tokens) => enumSyntax.WithModifiers(tokens.ToTokenList());