Ejemplo n.º 1
0
            internal override bool CanMatch(AstNode node)
            {
                if (specialNodeType != null && node.GetType() == specialNodeType)
                {
                    return(true);
                }

                Expression expr = node as Expression;

                if (expr == null)
                {
                    return(node is MethodDeclaration);
                }

                InvocationExpression ie = node as InvocationExpression;

                if (ie != null)
                {
                    Expression target = ParenthesizedExpression.UnpackParenthesizedExpression(ie.Target);

                    IdentifierExpression ident = target as IdentifierExpression;
                    if (ident != null)
                    {
                        return(ident.Identifier == method.Name);
                    }

                    MemberReferenceExpression mre = target as MemberReferenceExpression;
                    if (mre != null)
                    {
                        return(mre.MemberName == method.Name);
                    }

                    PointerReferenceExpression pre = target as PointerReferenceExpression;
                    if (pre != null)
                    {
                        return(pre.MemberName == method.Name);
                    }
                }
                else if (expr.Role != InvocationExpression.Roles.TargetExpression)
                {
                    // MemberReferences & Identifiers that aren't used in an invocation can still match the method
                    // as delegate name.
                    if (expr.GetChildByRole(AstNode.Roles.Identifier).Name == method.Name)
                    {
                        potentialMethodGroupConversions.Add(expr);
                    }
                }
                return(node is MethodDeclaration);
            }
Ejemplo n.º 2
0
            public override bool DoMatch(INode other, Match match)
            {
                INode unpacked = ParenthesizedExpression.UnpackParenthesizedExpression(other as Expression);

                return(child.DoMatch(unpacked, match));
            }