Browse Source

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().
4.1
Daniel Grunwald 14 years ago
parent
commit
4b2d4a6644
  1. 18
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs

18
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs

@ -113,9 +113,21 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -113,9 +113,21 @@ namespace ICSharpCode.SharpDevelop.Refactoring
public ObservableCollection<ContextActionViewModel> BuildTreeViewModel(IEnumerable<ITreeNode<IClass>> classTree)
{
return new ObservableCollection<ContextActionViewModel>(
classTree.Select(
node => MakeGoToMemberAction(node.Content, BuildTreeViewModel(node.Children))).Where(action => action != null));
ObservableCollection<ContextActionViewModel> c = new ObservableCollection<ContextActionViewModel>();
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;
}
}
}

Loading…
Cancel
Save