Пример #1
0
        // We have a lambda; we want to find a syntax node or statement which can be bound such that
        // we can get the type of the lambda, if there is one. For example if given
        //
        // A().B(x=>M(x)).C();  then we want to find  A().B(x=>M())
        // object d = (D)(x=>M(x)); then we want to find (D)(x=>M(x))
        // D d = x=>M(x); then we want to find the whole thing.
        //
        protected virtual SyntaxNode GetBindableSyntaxNodeOfLambdaOrQuery(SyntaxNode node)
        {
            Debug.Assert(node != null);
            Debug.Assert(node != this.Root);
            Debug.Assert(node.IsAnonymousFunction() || node.IsQuery());

            SyntaxNode current = node.Parent;

            for (; current != this.Root; current = current.Parent)
            {
                Debug.Assert(current != null, "How did we get outside the root?");

                if (current is StatementSyntax)
                {
                    return(current);
                }

                if (current.Kind == SyntaxKind.ParenthesizedExpression)
                {
                    continue;
                }

                if (current is ExpressionSyntax)
                {
                    return(GetBindableSyntaxNode(current));
                }
            }

            // We made it up to the root without finding a viable expression or statement. Just bind
            // the lambda and hope for the best.
            return(node);
        }
Пример #2
0
        private static bool NodeIsExplicitType(SyntaxNode node, SyntaxNode lambda)
        {
            Debug.Assert(node != null);
            Debug.Assert(lambda != null);
            Debug.Assert(lambda.IsAnonymousFunction() || lambda.IsQuery());

            // UNDONE;
            return(false);
        }