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

Balaji Rao balajirrao at gmail.com
Tue Jun 26 06:37:18 EDT 2007


Hello guys, 

This patch fixes improper node command handling incase of partial
classes.
-------------- 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 80726)
+++ Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/MemberNodeCommandHandler.cs	(working copy)
@@ -47,13 +47,16 @@
 		
 		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;
-			
+			IMember member = CurrentNode.DataItem as IMember;
+			foreach (IClass c in member.DeclaringType.Parts) {
+				if ((typeof(IField).IsInstanceOfType(member) && c.Fields.Contains((IField)member)) ||
+				    (typeof(IEvent).IsInstanceOfType(member) && c.Events.Contains((IEvent)member)) || 
+				    (typeof(IProperty).IsInstanceOfType(member) && c.Properties.Contains((IProperty)member)) ||
+				    (typeof(IMethod).IsInstanceOfType(member) && c.Methods.Contains((IMethod)member))) {
+					return c.Region.FileName;
+				}				    
+			}
 			return null;
-		}
+		}		
 	}
 }


More information about the Monodevelop-list mailing list