Esempio n. 1
0
        public CSharpSyntaxNodeData(CSharpSyntaxNode node)
        {
            Kind = node.Kind();
            SyntaxTokenList modifiers = GetSyntaxPropertiesForNode(node);

            Modifiers = ModifiersHelper.GetNonAccessibilityModifiers(modifiers);
            Access    = ModifiersHelper.GetAccessibilityOrDefault(Kind, modifiers);
        }
Esempio n. 2
0
        private static SyntaxNode AddAccessModifierIfNotPresent(MemberDeclarationSyntax node)
        {
            SyntaxTokenList modifiers            = node.Modifiers;
            AccessModifier  currentAccessibility = ModifiersHelper.GetAccessibility(modifiers);

            if (currentAccessibility != AccessModifier.NotExplicit)
            {
                return(node);
            }

            AccessModifier   defaultAccessibility = ModifiersHelper.GetDefaultAccessibility(node.Kind());
            SyntaxTriviaList leadingTrivia        = node.GetLeadingTrivia();
            SyntaxTokenList  newModifiers         = FormatModifiers(modifiers, defaultAccessibility);

            return(node.WithoutLeadingTrivia().WithModifiers(newModifiers).WithLeadingTrivia(leadingTrivia));
        }
Esempio n. 3
0
        private static SyntaxTokenList FormatModifiers(SyntaxTokenList existingModifiers, AccessModifier access)
        {
            // Get First since all current default modifiers have only one modifier (public, internal or private)
            SyntaxToken newAccessibility           = ModifiersHelper.GetModifiers(access).First();
            ICollection <SyntaxToken> newModifiers = new List <SyntaxToken>()
            {
                newAccessibility.WithTrailingTrivia(SingleWhitespace)
            };

            foreach (SyntaxToken token in existingModifiers)
            {
                SyntaxToken newToken = token.WithoutTrivia().WithTrailingTrivia(SingleWhitespace);
                newModifiers.Add(newToken);
            }

            return(SyntaxFactory.TokenList(newModifiers));
        }