コード例 #1
0
        protected override void VisitCastSyntax(CastSyntax pNode)
        {
            base.VisitCastSyntax(pNode);

            //We only care about methods that aren't in the current module
            foreach (var mod in _unit.GetAllReferences())
            {
                //Find the method
                foreach (var m in mod.Module.Methods)
                {
                    if (m is CastDefinitionSyntax c && IsCalledCast(c, pNode))
                    {
                        var rn = new ReferencedNode(m, mod.Cache);
                        if (!MethodNodes.Contains(rn))
                        {
                            MethodNodes.Add(rn);

                            //Get any type/methods that this method references
                            var mrv = new ModuleReferenceVisitor(mod.Cache, _context, mod);
                            mrv.Visit(m);
                            MethodNodes.AddRange(mrv.MethodNodes);
                            TypeNodes.AddRange(mrv.TypeNodes);
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected override void VisitMethodCallSyntax(MethodCallSyntax pNode)
        {
            base.VisitMethodCallSyntax(pNode);

            //We only care about methods that aren't in the current module
            if (_module != null || Namespace != null)
            {
                System.Diagnostics.Debug.Assert(_module != null || _unit.HasReference(Namespace));

                //Get the referenced module
                var mod = Namespace == null ? _module : _unit.GetReference(Namespace);

                //Find the method
                foreach (var m in mod.Module.Methods)
                {
                    if (IsCalledMethod(m, pNode))
                    {
                        var rn = new ReferencedNode(m, mod.Cache);
                        if (!MethodNodes.Contains(rn))
                        {
                            MethodNodes.Add(rn);

                            //Get any type/methods that this method references
                            var mrv = new ModuleReferenceVisitor(mod.Cache, _context, mod);
                            mrv.MethodNodes.Add(rn);

                            mrv.Visit(m);
                            MethodNodes.AddRange(mrv.MethodNodes);
                            TypeNodes.AddRange(mrv.TypeNodes);
                        }
                    }
                }
            }
        }