Author: lluis
Date: 2008-02-18 05:31:30 -0500 (Mon, 18 Feb 2008)
New Revision: 96039

Modified:
   trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog
   
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopTreeView.cs
Log:
* MonoDevelop.Ide.Gui/MonoDevelopTreeView.cs: If there are several
  valid node type builders for a type, make sure to pick the most
  specific one.

Modified: trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog   2008-02-18 
10:30:16 UTC (rev 96038)
+++ trunk/monodevelop/main/src/core/MonoDevelop.Ide/ChangeLog   2008-02-18 
10:31:30 UTC (rev 96039)
@@ -1,3 +1,8 @@
+2008-02-18  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.Ide.Gui/MonoDevelopTreeView.cs: If there are several valid
+         node type builders for a type, make sure to pick the most specific 
one.
+
 2008-02-18  Mike Krüger <[EMAIL PROTECTED]> 
 
        * MonoDevelop.Ide.Gui.Content/TextEditorProperties.cs: Fixed tabs2spaces

Modified: 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopTreeView.cs
===================================================================
--- 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopTreeView.cs
  2008-02-18 10:30:16 UTC (rev 96038)
+++ 
trunk/monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/MonoDevelopTreeView.cs
  2008-02-18 10:31:30 UTC (rev 96039)
@@ -833,10 +833,20 @@
                        if (chain == null)
                        {
                                ArrayList list = new ArrayList ();
+                               
+                               // Find the most specific node builder type.
+                               TypeNodeBuilder bestTypeNodeBuilder = null;
+                               Type bestNodeType = null;
+                               
                                foreach (NodeBuilder nb in builders) {
                                        if (nb is TypeNodeBuilder) {
-                                               if 
(((TypeNodeBuilder)nb).NodeDataType.IsAssignableFrom (type))
-                                                       list.Insert (0, nb);
+                                               TypeNodeBuilder tnb = 
(TypeNodeBuilder) nb;
+                                               if 
(tnb.NodeDataType.IsAssignableFrom (type)) {
+                                                       if (bestNodeType == 
null || bestNodeType.IsAssignableFrom (tnb.NodeDataType)) {
+                                                               bestNodeType = 
tnb.NodeDataType;
+                                                               
bestTypeNodeBuilder = tnb;
+                                                       }
+                                               }
                                        }
                                        else {
                                                try {
@@ -848,11 +858,12 @@
                                        }
                                }
                                
-                               chain = (NodeBuilder[]) list.ToArray 
(typeof(NodeBuilder));
+                               if (bestTypeNodeBuilder != null) {
+                                       list.Insert (0, bestTypeNodeBuilder);
+                                       chain = (NodeBuilder[]) list.ToArray 
(typeof(NodeBuilder));
+                               } else
+                                       chain = null;
                                
-                               if (chain.Length == 0 || !(chain[0] is 
TypeNodeBuilder))
-                                       chain = null;
-
                                builderChains [type] = chain;
                        }
                        return chain;

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to