IEnumerable <AnalyzerTreeNodeData> FindReferencesInType(TypeDef type)
        {
            AnalyzerTreeNodeData newNode = null;

            try {
                if (!TypesHierarchyHelpers.IsBaseType(analyzedMethod.DeclaringType, type, resolveTypeArguments: false))
                {
                    yield break;
                }

                foreach (MethodDef method in type.Methods)
                {
                    if (TypesHierarchyHelpers.IsBaseMethod(analyzedMethod, method))
                    {
                        bool hidesParent = !method.IsVirtual ^ method.IsNewSlot;
                        newNode = new MethodNode(method, hidesParent)
                        {
                            Context = Context
                        };
                    }
                }
            }
            catch (ResolveException) {
                // ignore this type definition. maybe add a notification about such cases.
            }

            if (newNode != null)
            {
                yield return(newNode);
            }
        }
Exemple #2
0
 internal static void DeleteNodes(ITreeNodeData[] nodes)
 {
     if (nodes != null)
     {
         foreach (var node in nodes)
         {
             AnalyzerTreeNodeData.CancelSelfAndChildren(node);
             node.TreeNode.Parent.Children.Remove(node.TreeNode);
         }
     }
 }
Exemple #3
0
        protected override IEnumerable <AnalyzerTreeNodeData> FetchChildren(CancellationToken ct)
        {
            //note: only goes up 1 level
            AnalyzerTreeNodeData newNode = null;

            try {
                //get base type (if any)
                if (analyzedMethod.DeclaringType.BaseType == null)
                {
                    yield break;
                }
                ITypeDefOrRef baseType = analyzedMethod.DeclaringType.BaseType;

                while (baseType != null)
                {
                    //only typedef has a Methods property
                    if (baseType is TypeDef)
                    {
                        TypeDef def = (TypeDef)baseType;
                        foreach (var method in def.Methods)
                        {
                            if (TypesHierarchyHelpers.IsBaseMethod(method, analyzedMethod))
                            {
                                newNode = new MethodNode(method)
                                {
                                    Context = Context
                                };
                                break;                                 //there can be only one
                            }
                        }
                        //escape from the while loop if we have a match (cannot yield return in try/catch)
                        if (newNode != null)
                        {
                            break;
                        }

                        baseType = def.BaseType;
                    }
                    else
                    {
                        //try to resolve the TypeRef
                        //will be null if resolving failed
                        baseType = baseType.Resolve();
                    }
                }
            }
            catch (ResolveException) {
                //ignored
            }
            if (newNode != null)
            {
                yield return(newNode);
            }
        }
Exemple #4
0
        public static void HandleModelUpdated(ITreeNode node, IDsDocument[] documents)
        {
            var children = node.DataChildren.ToArray();

            for (int i = children.Length - 1; i >= 0; i--)
            {
                var c = children[i];
                var n = c as AnalyzerTreeNodeData;
                if (n is null || !n.HandleModelUpdated(documents))
                {
                    AnalyzerTreeNodeData.CancelSelfAndChildren(c);
                    node.Children.RemoveAt(i);
                }
            }
        }
Exemple #5
0
        public static void HandleAssemblyListChanged(ITreeNode node, IDsDocument[] removedAssemblies, IDsDocument[] addedAssemblies)
        {
            var children = node.DataChildren.ToArray();

            for (int i = children.Length - 1; i >= 0; i--)
            {
                var c = children[i];
                var n = c as AnalyzerTreeNodeData;
                if (n is null || !n.HandleAssemblyListChanged(removedAssemblies, addedAssemblies))
                {
                    AnalyzerTreeNodeData.CancelSelfAndChildren(c);
                    node.Children.RemoveAt(i);
                }
            }
        }
Exemple #6
0
        public static void HandleModelUpdated(ITreeNode node, IDnSpyFile[] files)
        {
            var children = node.DataChildren.ToArray();

            for (int i = children.Length - 1; i >= 0; i--)
            {
                var c = children[i];
                var n = c as IAnalyzerTreeNodeData;
                if (n == null || !n.HandleModelUpdated(files))
                {
                    AnalyzerTreeNodeData.CancelSelfAndChildren(c);
                    node.Children.RemoveAt(i);
                }
            }
        }
Exemple #7
0
 void CancelAndClearChildren()
 {
     AnalyzerTreeNodeData.CancelSelfAndChildren(this);
     TreeNode.Children.Clear();
     TreeNode.LazyLoading = true;
 }
Exemple #8
0
		public void OnActivated(AnalyzerTreeNodeData node) {
			if (node == null)
				throw new ArgumentNullException(nameof(node));
			bool newTab = Keyboard.Modifiers == ModifierKeys.Control || Keyboard.Modifiers == ModifierKeys.Shift;
			FollowNode(node, newTab, null);
		}
Exemple #9
0
		public void Add(AnalyzerTreeNodeData node) {
			if (node is EntityNode) {
				var an = node as EntityNode;
				var found = TreeView.Root.DataChildren.OfType<EntityNode>().FirstOrDefault(n => n.Member == an.Member);
				if (found != null) {
					found.TreeNode.IsExpanded = true;
					TreeView.SelectItems(new TreeNodeData[] { found });
					TreeView.Focus();
					return;
				}
			}
			TreeView.Root.Children.Add(TreeView.Create(node));
			node.TreeNode.IsExpanded = true;
			TreeView.SelectItems(new TreeNodeData[] { node });
			TreeView.Focus();
		}