Ejemplo n.º 1
0
        private static bool CanReuseParameter(CSharp.Syntax.ParameterSyntax parameter)
        {
            // cannot reuse a node that possibly ends in an expression
            if (parameter.Default != null)
            {
                return(false);
            }

            // cannot reuse lambda parameters as normal parameters (parsed with
            // different rules)
            CSharp.CSharpSyntaxNode parent = parameter.Parent;
            if (parent != null)
            {
                if (parent.Kind == SyntaxKind.SimpleLambdaExpression)
                {
                    return(false);
                }

                CSharp.CSharpSyntaxNode grandparent = parent.Parent;
                if (grandparent != null && grandparent.Kind == SyntaxKind.ParenthesizedLambdaExpression)
                {
                    Debug.Assert(parent.Kind == SyntaxKind.ParameterList);
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private static bool CanReuseParameter(CSharp.Syntax.ParameterSyntax parameter, SyntaxListBuilder <AnnotationSyntax> attributes, SyntaxListBuilder modifiers)
        {
            if (parameter == null)
            {
                return(false);
            }

            // cannot reuse parameter if it had attributes.
            //
            // TODO(cyrusn): Why?  We can reuse other constructs if they have attributes.
            if (attributes.Count != 0 || parameter.AttributeLists.Count != 0)
            {
                return(false);
            }

            // cannot reuse parameter if it had modifiers.
            if ((modifiers != null && modifiers.Count != 0) || parameter.Modifiers.Count != 0)
            {
                return(false);
            }

            return(CanReuseParameter(parameter));
        }