diff options
author | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2015-02-08 09:27:26 +0300 |
---|---|---|
committer | Michael Hutchinson <m.j.hutchinson@gmail.com> | 2015-02-08 09:27:26 +0300 |
commit | 0207771005e73f4f585783e0b6ae368daf25d490 (patch) | |
tree | e24834261b3d33a6946837406ee9f524b24d74f4 /main/src | |
parent | 9f29560a79ea9bff73ed7f4af0b8c176ce2327fc (diff) |
[Refactoring] Fix FindDerivedClasses command handler
Diffstat (limited to 'main/src')
3 files changed, 25 insertions, 31 deletions
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml index d20c6f8c42..aa4e755af5 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml @@ -90,7 +90,7 @@ _label = "_Find References of All Overloads" /> <Command id = "MonoDevelop.Refactoring.RefactoryCommands.FindDerivedClasses" defaultHandler = "MonoDevelop.Refactoring.FindDerivedClassesHandler" - _label = "Find _Derived Classes" /> + _label = "Find _Derived Symbols" /> </Category> <Category _name = "Refactoring" id = "Refactoring"> diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs index d1d99c2b41..2c599e0dd8 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/FindDerivedClassesHandler.cs @@ -28,7 +28,6 @@ using System; using MonoDevelop.Core; using MonoDevelop.Ide.Gui; using MonoDevelop.Components.Commands; -using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Refactoring; using MonoDevelop.Ide; using ICSharpCode.NRefactory.TypeSystem; @@ -37,9 +36,6 @@ using System.Collections.Generic; using System.Threading; using MonoDevelop.Projects; using MonoDevelop.Ide.FindInFiles; -using ICSharpCode.NRefactory.CSharp.Resolver; -using ICSharpCode.NRefactory.TypeSystem.Implementation; -using System.Linq; using Mono.TextEditor; using ICSharpCode.NRefactory.Semantics; using System.Threading.Tasks; @@ -122,30 +118,25 @@ namespace MonoDevelop.Refactoring protected override void Run (object data) { -// var doc = IdeApp.Workbench.ActiveDocument; -// if (doc == null || doc.FileName == FilePath.Null) -// return; -// ResolveResult resolveResult; -// var item = CurrentRefactoryOperationsHandler.GetItem (doc, out resolveResult); -// -// IMember eitem = resolveResult != null ? (resolveResult.CallingMember ?? resolveResult.CallingType) : null; -// string itemName = null; -// if (item is IMember) -// itemName = ((IMember)item).FullName; -// if (item != null && eitem != null && (eitem.Equals (item) || (eitem.FullName == itemName && !(eitem is IProperty) && !(eitem is IMethod)))) { -// item = eitem; -// eitem = null; -// } -// ITypeDefinition eclass = null; -// if (item is ITypeDefinition) { -// if (((ITypeDefinition)item).Kind == TypeKind.Interface) -// eclass = CurrentRefactoryOperationsHandler.FindEnclosingClass (ctx, editor.Name, line, column); else -// eclass = (IType)item; -// if (eitem is IMethod && ((IMethod)eitem).IsConstructor && eitem.DeclaringType.Equals (item)) { -// item = eitem; -// eitem = null; -// } -// } + var doc = IdeApp.Workbench.ActiveDocument; + if (doc == null || doc.FileName == FilePath.Null) + return; + + ResolveResult resolveResult; + var item = CurrentRefactoryOperationsHandler.GetItem (doc, out resolveResult); + + var typeDef = item as ITypeDefinition; + if (typeDef != null && ((typeDef.Kind == TypeKind.Class && !typeDef.IsSealed) || typeDef.Kind == TypeKind.Interface)) { + FindDerivedClasses (typeDef); + return; + } + + var member = item as IMember; + if (member != null && (member.IsVirtual || member.IsAbstract || member.DeclaringType.Kind == TypeKind.Interface)) { + var handler = new FindDerivedSymbolsHandler (doc, member); + handler.Run (); + return; + } } } } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs index 375ea3edf1..a02fe48305 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs @@ -353,7 +353,8 @@ namespace MonoDevelop.Refactoring if (member.IsVirtual || member.IsAbstract || member.DeclaringType.Kind == TypeKind.Interface) { var handler = new FindDerivedSymbolsHandler (doc, member); if (handler.IsValid) { - ainfo.Add (GettextCatalog.GetString ("Find Derived Symbols"), new System.Action (handler.Run)); + var a = ainfo.Add (GettextCatalog.GetString ("Find Derived Symbols"), new Action (handler.Run)); + a.AccelKey = IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindDerivedClasses).AccelKey; added = true; } } @@ -378,7 +379,9 @@ namespace MonoDevelop.Refactoring } } if ((cls.Kind == TypeKind.Class && !cls.IsSealed) || cls.Kind == TypeKind.Interface) { - ainfo.Add (cls.Kind != TypeKind.Interface ? GettextCatalog.GetString ("Find _derived classes") : GettextCatalog.GetString ("Find _implementor classes"), new System.Action (new FindDerivedClasses (cls).Run)); + var label = cls.Kind != TypeKind.Interface ? GettextCatalog.GetString ("Find _derived classes") : GettextCatalog.GetString ("Find _implementor classes"); + var a = ainfo.Add (label, new System.Action (new FindDerivedClasses (cls).Run)); + a.AccelKey = IdeApp.CommandService.GetCommandInfo (RefactoryCommands.FindDerivedClasses).AccelKey; } ainfo.Add (GettextCatalog.GetString ("Find Extension Methods"), new System.Action (new FindExtensionMethodHandler (doc, cls).Run)); added = true; |