From 4b2d4a664466e1e784e6c5be367966c426d14ef8 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 21 Sep 2011 18:28:20 +0200 Subject: [PATCH] Fix bug that caused methods to not be shown in the F6 dialog (find overrides). The bug occurred when looking for the overrides of A.M() in this code: class A { virtual void M(); } class B : A {} class C : B { override void M(); } C.M() was found, but not added to the tree because there isn't any intermediate node B.M(). --- .../ContextActions/ContextActionsHelper.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs index 1f2c6fb22b..ca6ae15d80 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs @@ -113,9 +113,21 @@ namespace ICSharpCode.SharpDevelop.Refactoring public ObservableCollection BuildTreeViewModel(IEnumerable> classTree) { - return new ObservableCollection( - classTree.Select( - node => MakeGoToMemberAction(node.Content, BuildTreeViewModel(node.Children))).Where(action => action != null)); + ObservableCollection c = new ObservableCollection(); + foreach (var node in classTree) { + var childNodes = BuildTreeViewModel(node.Children); + var action = MakeGoToMemberAction(node.Content, childNodes); + if (action != null) { + c.Add(action); + } else { + // If the member doesn't exist in the derived class, directly append the + // children of that derived class here. + c.AddRange(childNodes); + // This is necessary so that the method C.M() is shown in the case + // "class A { virtual void M(); } class B : A {} class C : B { override void M(); }" + } + } + return c; } } }