Exemple #1
0
        public static Dictionary <string, List <string> > calculateMappingsFor_MethodsCalled(this O2MappedAstData astData)
        {
            "stating: calculateMappingsFor_MethodsCalled".info();
            var mappings = new Dictionary <string, List <string> >();

            foreach (var iMethod in astData.iMethods())
            {
                if (iMethod != null && iMethod.DotNetName.valid())
                {
                    var calledMethodsList = mappings.add_Key(iMethod.fullName());
                    try
                    {
                        foreach (var iMethodCalled in astData.calledIMethods(iMethod))
                        {
                            if (iMethodCalled != null)
                            {
                                var methodCalledName = iMethodCalled.fullName();
                                if (calledMethodsList.Contains(methodCalledName).isFalse())
                                {
                                    calledMethodsList.add(methodCalledName);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.log("iMethodsThatCallThisIMethod");
                    }
                    //if (mappings.Keys.size() == 25)
                    //	return mappings;
                }
            }
            "completed: calculateMappingsFor_MethodsCalled".info();
            return(mappings);
        }
Exemple #2
0
        public static List <IMethod> iMethodsThatCallThisIMethod(this O2MappedAstData astData, IMethod targetIMethod)
        {
            var results = new List <IMethod>();

            if (astData != null && targetIMethod != null)
            {
                var targetIMethodName = targetIMethod.fullName();
                foreach (var iMethod in astData.iMethods())
                {
                    if (iMethod != null && iMethod.DotNetName.valid())
                    {
                        try
                        {
                            foreach (var iMethodCalled in astData.calledIMethods(iMethod))
                            {
                                if (iMethodCalled != null && iMethodCalled.fullName() == targetIMethodName)
                                {
                                    if (results.Contains(iMethod).isFalse())
                                    {
                                        results.add(iMethod);
                                    }
                                }
                                //"{0} -> {1}".debug(iMethod.DotNetName,  iMethodCalled.DotNetName);
                                //results.add(iMethod);
                            }
                        }
                        catch (Exception ex)
                        {
                            ex.log("iMethodsThatCallThisIMethod");
                        }
                    }
                }
            }
            return(results);
        }