internal override SemanticInfo GetSemanticInfoWorker(SyntaxNode node, SemanticInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            ValidateSemanticInfoOptions(options);

            SyntaxNode bindableNode = this.GetBindableSyntaxNode(node);
            SyntaxNode bindableParent = this.GetBindableParentNode(bindableNode);

            // Special handling for the Color Color case.
            //
            // Suppose we have:
            // public class Color {
            //   public void M(int x) {}
            //   public static void M(params int[] x) {}
            // }
            // public class C {
            //   public void Test() {
            //     Color Color = new Color();
            //     System.Action<int> d = Color.M;
            //   }
            // }
            //
            // We actually don't know how to interpret the "Color" in "Color.M" until we
            // perform overload resolution on the method group.  Now, if we were getting
            // the semantic info for the method group, then bindableParent would be the
            // variable declarator "d = Color.M" and so we would be able to pull the result
            // of overload resolution out of the bound (method group) conversion.  However,
            // if we are getting the semantic info for just the "Color" part, then
            // bindableParent will be the member access, which doesn't have enough information
            // to determine which "Color" to use (since no overload resolution has been
            // performed).  We resolve this problem by detecting the case where we're looking
            // up the LHS of a member access and calling GetBindableParentNode one more time.
            // This gets us up to the level where the method group conversion occurs.
            if (bindableParent != null && bindableParent.Kind == SyntaxKind.MemberAccessExpression && ((MemberAccessExpressionSyntax)bindableParent).Expression == bindableNode)
            {
                bindableParent = this.GetBindableParentNode(bindableParent);
            }

            BoundNode boundParent = null;
            BoundNode boundNode = null;
            BoundNode highestBoundNode = null;

            if (bindableParent != null)
            {
                boundParent = this.GetBoundNode(bindableParent);
            }

            boundNode = this.GetBoundNode(bindableNode);

            if (boundParent != null)
            {
                highestBoundNode = this.GetBoundChild(boundParent, node);
            }
            else
            {
                highestBoundNode = boundNode;
            }

            return base.GetSemanticInfoForNode(bindableNode, options, boundNode, highestBoundNode, boundParent);
        }
示例#2
0
        internal override SemanticInfo GetSemanticInfoWorker(SyntaxNode node, SemanticInfoOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            ValidateSemanticInfoOptions(options);

            SyntaxNode bindableNode   = this.GetBindableSyntaxNode(node);
            SyntaxNode bindableParent = this.GetBindableParentNode(bindableNode);

            // Special handling for the Color Color case.
            //
            // Suppose we have:
            // public class Color {
            //   public void M(int x) {}
            //   public static void M(params int[] x) {}
            // }
            // public class C {
            //   public void Test() {
            //     Color Color = new Color();
            //     System.Action<int> d = Color.M;
            //   }
            // }
            //
            // We actually don't know how to interpret the "Color" in "Color.M" until we
            // perform overload resolution on the method group.  Now, if we were getting
            // the semantic info for the method group, then bindableParent would be the
            // variable declarator "d = Color.M" and so we would be able to pull the result
            // of overload resolution out of the bound (method group) conversion.  However,
            // if we are getting the semantic info for just the "Color" part, then
            // bindableParent will be the member access, which doesn't have enough information
            // to determine which "Color" to use (since no overload resolution has been
            // performed).  We resolve this problem by detecting the case where we're looking
            // up the LHS of a member access and calling GetBindableParentNode one more time.
            // This gets us up to the level where the method group conversion occurs.
            if (bindableParent != null && bindableParent.Kind == SyntaxKind.MemberAccessExpression && ((MemberAccessExpressionSyntax)bindableParent).Expression == bindableNode)
            {
                bindableParent = this.GetBindableParentNode(bindableParent);
            }

            BoundNode boundParent      = null;
            BoundNode boundNode        = null;
            BoundNode highestBoundNode = null;

            if (bindableParent != null)
            {
                boundParent = this.GetBoundNode(bindableParent);
            }

            boundNode = this.GetBoundNode(bindableNode);

            if (boundParent != null)
            {
                highestBoundNode = this.GetBoundChild(boundParent, node);
            }
            else
            {
                highestBoundNode = boundNode;
            }

            return(base.GetSemanticInfoForNode(bindableNode, options, boundNode, highestBoundNode, boundParent));
        }