예제 #1
0
        private InvokedMethod TraverseInvokedMethod(CallStatementSyntax css)
        {
            InvokedMethod invokedMethod = new InvokedMethod();

            InvocationExpressionSyntax invokeInfo = css.Invocation as InvocationExpressionSyntax;
            if (invokeInfo.ArgumentList != null)
            {
                foreach (ArgumentSyntax argSyn in invokeInfo.ArgumentList.Arguments)
                {
                    Variables parameter = new Variables();
                    parameter.Name = argSyn.ToString();
                    invokedMethod.Parameters.Add(parameter);
                }
            }
            ExpressionSyntax es = invokeInfo.Expression;
            if (es is IdentifierNameSyntax)
            {
                invokedMethod.Name = (es as IdentifierNameSyntax).Identifier.ValueText;
            }
            else if(es is MemberAccessExpressionSyntax)
            {
                MemberAccessExpressionSyntax maes = es as MemberAccessExpressionSyntax;
                invokedMethod.Name = (maes.Name as SimpleNameSyntax).Identifier.ValueText;
                //TODO: What about the expression? Is it a variable? I think so!?
            }

            return invokedMethod;
        }
예제 #2
0
        private Method TraverseInvocationExpression(InvocationExpressionSyntax ies)
        {
            //TODO
            //get method name and accessed variables
            //and attributes and qualifiers
            Method retIm = new Method();

            if (ies.HasLeadingTrivia)
            {
                SetOuterComments(retIm, ies.GetLeadingTrivia().ToFullString());
            }

            if (ies.HasTrailingTrivia)
            {
                SetInnerComments(retIm, ies.GetTrailingTrivia().ToFullString());
            }
            //havent tested this with extra stuff like setting the variable equal to the method call
            //or with variables in the method call
            var methods = from aMethod in ies.ChildNodes().OfType<IdentifierNameSyntax>() select aMethod;
            foreach (IdentifierNameSyntax ins in methods)
            {
                InvokedMethod tempMethod = new InvokedMethod();
                tempMethod.Name = ins.Identifier.ValueText;
                retIm.InvokedMethods.Add(tempMethod);
            }
            //var args = from aArg in ies.ArgumentList.Arguments.OfType<ArgumentSyntax>() select aArg;
            //foreach (ArgumentSyntax asyn in args)
            //{
            //    Variables tempVar = new Variables();

            //}
            var args = from aArg in ies.Expression.ChildNodes().OfType<IdentifierNameSyntax>() select aArg;
            foreach (IdentifierNameSyntax ins in args)
            {
                Variables tempVar = new Variables();
                tempVar.Name = ins.Identifier.ValueText;
                retIm.AccessedVariables.Add(tempVar);
            }
            retIm.Name = ies.Expression.ToString();
            return retIm;
        }