[MonoDevelop] [PATCH] Fix improper member node command handling

Balaji Rao balajirrao at gmail.com
Thu Jun 28 10:03:13 EDT 2007


On Thu, Jun 28, 2007 at 12:29:29AM +0200, Lluis Sanchez wrote:
> Hi!
> 
> I think that MemberNodeCommandHandler should use
> IdeApp.ProjectOperations.JumpToDeclaration () to open the file. I don't
> know if JumpToDeclaration() will work for the case that your patch fixes
> though. You can try it, and if it doesn't maybe you can apply the patch
> there.
> 
Fixed it. Is it ok now ?
> Lluis.
Regards,
Balaji Rao
> 
> El dt 26 de 06 del 2007 a les 16:07 +0530, en/na Balaji Rao va
> escriure: 
> > Hello guys, 
> > 
> > This patch fixes improper node command handling incase of partial
> > classes.
> > _______________________________________________
> > Monodevelop-list mailing list
> > Monodevelop-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/monodevelop-list
> 
-------------- next part --------------
Index: Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/MemberNodeCommandHandler.cs
===================================================================
--- Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/MemberNodeCommandHandler.cs	(revision 80888)
+++ Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/MemberNodeCommandHandler.cs	(working copy)
@@ -38,22 +38,9 @@
 	public class MemberNodeCommandHandler: NodeCommandHandler
 	{
 		public override void ActivateItem ()
-		{
-			string file = GetFileName ();
-			IMember member = CurrentNode.DataItem as IMember;
-			int line = member.Region.BeginLine;
-			IdeApp.Workbench.OpenDocument (file, Math.Max (1, line), 1, true);
+		{			
+			ILanguageItem member = CurrentNode.DataItem as ILanguageItem;
+			IdeApp.ProjectOperations.JumpToDeclaration(member);
 		}
-		
-		string GetFileName ()
-		{
-			IMember member = (IMember) CurrentNode.GetParentDataItem (typeof(IMember), true);
-			if (member != null && member.Region.FileName != null) return member.Region.FileName;
-			
-			ClassData cls = (ClassData) CurrentNode.GetParentDataItem (typeof(ClassData), true);
-			if (cls != null && cls.Class.Region.FileName != null) return cls.Class.Region.FileName;
-			
-			return null;
-		}
 	}
 }
Index: Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs
===================================================================
--- Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs	(revision 80888)
+++ Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProjectOperations.cs	(working copy)
@@ -215,8 +215,17 @@
 					return;
 				else if (mem.Region.FileName != null)
 					file = mem.Region.FileName;
-				else if (mem.DeclaringType != null)
-					file = GetClassFileName (mem.DeclaringType);
+				else if (mem.DeclaringType != null) {
+					foreach (IClass c in mem.DeclaringType.Parts) {
+						if ((typeof(IField).IsInstanceOfType(mem) && c.Fields.Contains((IField)mem)) ||
+						    (typeof(IEvent).IsInstanceOfType(mem) && c.Events.Contains((IEvent)mem)) || 
+						    (typeof(IProperty).IsInstanceOfType(mem) && c.Properties.Contains((IProperty)mem)) ||
+						    (typeof(IMethod).IsInstanceOfType(mem) && c.Methods.Contains((IMethod)mem))) {
+							file= c.Region.FileName;
+							break;
+						}                                   
+					}					
+				}
 				if (file != null)
 					IdeApp.Workbench.OpenDocument (file, mem.Region.BeginLine, mem.Region.BeginColumn, true);
 			} else if (item is IClass) {


More information about the Monodevelop-list mailing list