Esempio n. 1
0
 public virtual void VisitParameterDeclarationSyntax(ParameterDeclarationSyntax syntax)
 {
     this.Visit(syntax.Keyword);
     this.Visit(syntax.Name);
     this.Visit(syntax.Type);
     this.Visit(syntax.Modifier);
 }
Esempio n. 2
0
        public static SyntaxBase?TryGetDefaultValue(ParameterDeclarationSyntax parameterDeclarationSyntax)
        {
            if (parameterDeclarationSyntax.Modifier is ParameterDefaultValueSyntax defaultValueSyntax)
            {
                return(defaultValueSyntax.DefaultValue);
            }

            return(null);
        }
Esempio n. 3
0
        public static SyntaxBase?TryGetDefaultValue(ParameterDeclarationSyntax parameterDeclarationSyntax)
        {
            if (parameterDeclarationSyntax.Modifier is ParameterDefaultValueSyntax defaultValueSyntax)
            {
                return(defaultValueSyntax.DefaultValue);
            }

            if (parameterDeclarationSyntax.Modifier is ObjectSyntax modifierObject)
            {
                return(TryGetObjectProperty(modifierObject, LanguageConstants.ParameterDefaultPropertyName));
            }

            return(null);
        }
Esempio n. 4
0
        public static IEnumerable <SyntaxBase>?TryGetAllowedItems(ParameterDeclarationSyntax parameterDeclarationSyntax)
        {
            if (!(parameterDeclarationSyntax.Modifier is ObjectSyntax modifierObject))
            {
                return(null);
            }

            var allowedValuesSyntax = TryGetObjectProperty(modifierObject, LanguageConstants.ParameterAllowedPropertyName);

            if (!(allowedValuesSyntax is ArraySyntax allowedArraySyntax))
            {
                return(null);
            }

            return(allowedArraySyntax.Items.Select(i => i.Value));
        }
Esempio n. 5
0
        protected virtual SyntaxBase ReplaceParameterDeclarationSyntax(ParameterDeclarationSyntax syntax)
        {
            var hasChanges = TryRewrite(syntax.LeadingNodes, out var leadingNodes);

            hasChanges |= TryRewriteStrict(syntax.Keyword, out var keyword);
            hasChanges |= TryRewriteStrict(syntax.Name, out var name);
            hasChanges |= TryRewrite(syntax.Type, out var type);
            hasChanges |= TryRewrite(syntax.Modifier, out var modifier);

            if (!hasChanges)
            {
                return(syntax);
            }

            return(new ParameterDeclarationSyntax(leadingNodes, keyword, name, type, modifier));
        }
Esempio n. 6
0
        public static ArraySyntax?TryGetAllowedSyntax(ParameterDeclarationSyntax parameterDeclarationSyntax)
        {
            if (!(parameterDeclarationSyntax.Modifier is ObjectSyntax modifierObject))
            {
                return(null);
            }

            var allowedValuesSyntax = TryGetObjectProperty(modifierObject, LanguageConstants.ParameterAllowedPropertyName);

            if (!(allowedValuesSyntax is ArraySyntax allowedArraySyntax))
            {
                return(null);
            }

            return(allowedArraySyntax);
        }
Esempio n. 7
0
        public static IEnumerable<SyntaxBase>? TryGetAllowedItems(ParameterDeclarationSyntax parameterDeclarationSyntax)
        {
            if (!(parameterDeclarationSyntax.Modifier is ObjectSyntax modifierObject))
            {
                return null;
            }

            var allowedProperty = modifierObject.Properties.SingleOrDefault(p => p.TryGetKeyText() == LanguageConstants.ParameterAllowedPropertyName);
            if (allowedProperty == null)
            {
                return null;
            }

            if (!(allowedProperty.Value is ArraySyntax allowedArraySyntax))
            {
                return null;
            }

            return allowedArraySyntax.Items.Select(i => i.Value);
        }
Esempio n. 8
0
 public static TypeSymbol?TryGetPrimitiveType(ParameterDeclarationSyntax parameterDeclarationSyntax)
 => LanguageConstants.TryGetDeclarationType(parameterDeclarationSyntax.ParameterType?.TypeName);
Esempio n. 9
0
 void ISyntaxVisitor.VisitParameterDeclarationSyntax(ParameterDeclarationSyntax syntax) => ReplaceCurrent(syntax, ReplaceParameterDeclarationSyntax);
Esempio n. 10
0
        protected virtual ParameterDeclarationSyntax ReplaceParameterDeclarationSyntax(ParameterDeclarationSyntax syntax)
        {
            var hasChanges = Rewrite(syntax.Keyword, out var keyword);

            hasChanges |= Rewrite(syntax.Name, out var name);
            hasChanges |= Rewrite(syntax.Type, out var type);
            hasChanges |= RewriteNullable(syntax.Modifier, out var modifier);

            if (!hasChanges)
            {
                return(syntax);
            }

            return(new ParameterDeclarationSyntax(keyword, name, type, modifier));
        }