[svn] r6680: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n

VladD2 svnadmin at nemerle.org
Sat Sep 23 07:31:37 CEST 2006


Log:
Work on relocation.

Author: VladD2
Date: Sat Sep 23 07:31:33 2006
New Revision: 6680

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompiledUnitAstBrowser.n	Sat Sep 23 07:31:33 2006
@@ -12,6 +12,7 @@
     FillTree(root : Decl) : void
     {
       def fileIndex = root.Location.FileIndex;
+      mutable currNode = null;
 
       def addLocation(nodes, kind, name, location)
       {
@@ -20,6 +21,7 @@
           def x = location;
           def newNode = nodes.Add($"($(x.Line),$(x.Column); $(x.EndLine),$(x.EndColumn)) $kind: $name");
           newNode.Tag = location;
+          currNode = newNode;
         }
       }
 
@@ -66,9 +68,21 @@
       {
         addLocation(nodes, "Location", " ", builder.Location);
         addLacations(nodes, "PartsLocation", builder.PartsLocation);
-        foreach (member :> MemberBuilder in builder.GetDirectMembers())
-          when (member.BodyLocation.FileIndex == fileIndex)
-            addLocation(nodes, member.ToString(), " ", member.BodyLocation);
+        
+        def comparer(x, y)
+        {
+          def (x, y) = (x.BodyLocation, y.BodyLocation);
+          if (x.Line == y.Line) x.Column - y.Column else if (x.Line > y.Line) 1 else 0
+        }
+        // Filter member whith this fileIndex, convert list to list[MemberBuilder] and sort the result list.
+        def fileMembers = builder.GetDirectMembers().Map(m => m :> MemberBuilder).Filter(fun(m)
+          { m.BodyLocation.FileIndex == fileIndex }).Sort(comparer);
+
+        foreach (member in fileMembers)
+        {
+          addLocation(nodes, member.ToString(), " ", member.Location);
+          addLocation(currNode.Nodes, "BodyLocation", " ", member.BodyLocation);
+        }
       }
 
       def add(nodes, astNode)
@@ -145,10 +159,10 @@
       {
         Tree.BeginUpdate();
         def nodesInfo = getNodesInfo();
-        def count = Tree.GetNodeCount(true);
+        //def count = Tree.GetNodeCount(true);
         Tree.Nodes.Clear();
         add(Tree.Nodes, root);
-        when (count == Tree.GetNodeCount(true))
+        //when (count == Tree.GetNodeCount(true))
           setNodesInfo(nodesInfo);
       }
       finally



More information about the svn mailing list