コード例 #1
0
        public void Resolve(VBAParser.VsAssignContext context)
        {
            // named parameter reference must be scoped to called procedure
            var callee = FindParentCall(context);

            ResolveInternal(context.implicitCallStmt_InStmt(), callee, ContextAccessorType.GetValueOrReference);
        }
コード例 #2
0
        public override void EnterVsAssign(VBAParser.VsAssignContext context)
        {
            /* named parameter syntax */

            // one of these is null...
            var callStatementA = context.Parent.Parent.Parent as VBAParser.ICS_S_ProcedureOrArrayCallContext;
            var callStatementB = context.Parent.Parent.Parent as VBAParser.ICS_S_VariableOrProcedureCallContext;
            var callStatementC = context.Parent.Parent.Parent as VBAParser.ICS_B_MemberProcedureCallContext;
            var callStatementD = context.Parent.Parent.Parent as VBAParser.ICS_B_ProcedureCallContext;

            var procedureName = string.Empty;
            ParserRuleContext identifierContext = null;

            if (callStatementA != null)
            {
                procedureName     = callStatementA.ambiguousIdentifier().GetText();
                identifierContext = callStatementA.ambiguousIdentifier();
            }
            else if (callStatementB != null)
            {
                procedureName     = callStatementB.ambiguousIdentifier().GetText();
                identifierContext = callStatementB.ambiguousIdentifier();
            }
            else if (callStatementC != null)
            {
                procedureName     = callStatementC.ambiguousIdentifier().GetText();
                identifierContext = callStatementC.ambiguousIdentifier();
            }
            else if (callStatementD != null)
            {
                procedureName     = callStatementD.certainIdentifier().GetText();
                identifierContext = callStatementD.certainIdentifier();
            }

            var procedure = FindProcedureDeclaration(procedureName, identifierContext);

            if (procedure == null)
            {
                return;
            }

            var call = context.implicitCallStmt_InStmt();
            var arg  = Resolve(call.iCS_S_VariableOrProcedureCall())
                       ?? Resolve(call.iCS_S_ProcedureOrArrayCall())
                       ?? Resolve(call.iCS_S_DictionaryCall())
                       ?? Resolve(call.iCS_S_MembersCall());

            if (arg != null)
            {
                var reference = new IdentifierReference(_qualifiedName, arg.IdentifierName, context.GetSelection(), context, arg);
                arg.AddReference(reference);
            }
        }