[svn] r7228: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n Nemerle.Compi...

VladD2 svnadmin at nemerle.org
Mon Jan 8 07:37:28 CET 2007


Log:
1. Move Location related methods to Location struct.
2. Add synchronization AstToolWindow with code.

Author: VladD2
Date: Mon Jan  8 07:37:24 2007
New Revision: 7228

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.resx
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Checker.n	Mon Jan  8 07:37:24 2007
@@ -161,7 +161,7 @@
           mutable ploc = walker.GetLocation(c.patterns.Head);
 
           foreach (p in c.patterns.Tail)
-            ploc = Utils.Combine(ploc, walker.GetLocation(p));
+            ploc = ploc.Combine(walker.GetLocation(p));
 
           (ploc, walker.GetLocation(c.body))
         });
@@ -263,7 +263,7 @@
 
             funs.Iter(f =>
             {
-              mutable loc = Utils.Combine(f.header.Location, f.body.Location).TrimStart(f.header.Location, false);
+              mutable loc = f.header.Location.Combine(f.body.Location).TrimStart(f.header.Location, false);
 
               when (IsNext(loc.Line, loc.Column, ' ') && IsNext(loc.Line, loc.Column + 1, ')'))
                 loc = Location(loc.FileIndex, loc.Line, loc.Column + 1, loc.EndLine, loc.EndColumn);
@@ -431,7 +431,7 @@
           {
           | Some(loc) => 
 
-            usingLoc = if (usingLoc.IsEmpty()) loc else Utils.Combine(usingLoc, us.Location);
+            usingLoc = if (usingLoc.IsEmpty()) loc else usingLoc.Combine(us.Location);
 
           | None      => ()
           }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ExprWalker.n	Mon Jan  8 07:37:24 2007
@@ -468,7 +468,7 @@
       Walk(expression, info =>
       {
         when (info.Node is Located)
-          loc = Utils.Combine(loc, (info.Node :> Located).Location);
+          loc = loc.Combine((info.Node :> Located).Location);
       });
 
       loc
@@ -481,7 +481,7 @@
       Walk(member, info =>
       {
         when (info.Node is Located)
-          loc = Utils.Combine(loc, (info.Node :> Located).Location);
+          loc = loc.Combine((info.Node :> Located).Location);
       });
 
       loc

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n	Mon Jan  8 07:37:24 2007
@@ -43,7 +43,7 @@
           if (result == null)
           {
             Trace.WriteLine("### RunCompletionEngine() return null!");
-            array(0);
+            _topKeywords
           }
           else
           {
@@ -107,7 +107,7 @@
           FindCorrespondMethod(isAccessor);
 
         | method is MethodBuilder => scanMethod(method)
-        | null => array(0)
+        | null => _topKeywords
         | field is FieldBuilder =>
           if (field.InitializerLocation.Contains(fileIndex, line, col))
             scanMethod(field.LookupInitializerMethod());

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Using.n	Mon Jan  8 07:37:24 2007
@@ -30,7 +30,7 @@
       if (us.Name is []) // using directive with empty namspace name
       { 
         if (loc.Line == line && col <= loc.Column + UsingLen)
-          array(0) // completion on the end of "using" keyword
+          _topKeywords // completion on the end of "using" keyword
         else
           GetCompletionElems(us.BeforeEnv.CurrentNamespace, null, false);
       }
@@ -60,7 +60,7 @@
           def ns = OpenNs(name, us.BeforeEnv.NameTree.NamespaceTree, completeLastName);
           // Convert namsespace content to CompletionElems (with filtering)
           if (ns.Children == null)
-            array(0)
+            _topKeywords
           else
             GetCompletionElems(ns, if (completeLastName) name.Last else null, 
               !string.IsNullOrEmpty(us.Alias));

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	Mon Jan  8 07:37:24 2007
@@ -47,7 +47,7 @@
         | Using as us     => CompleteInUsing    (us, fileIndex, line, col, source);
         | Namespace as ns => CompleteInNamespace(ns, fileIndex, line, col, source);
         | Type as ty      => CompleteInType     (ty, fileIndex, line, col, source);
-        | None            => throw System.Exception(); //array(0)
+        | None            => throw System.Exception();
       }
     }
     
@@ -69,7 +69,8 @@
     static this()
     {
       _topKeywords = StrsToCompletionElems(
-        ["using", "class", "struct", "variant", "namespace", "enum"],
+        ["using", "class", "struct", "variant", "namespace", "enum", "public", "protected",
+         "internal", "private", "abstract", "sealed"],
         GlyphType.Snippet :> int,
         "snippet or top level keyword");
     }

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Utils.n	Mon Jan  8 07:37:24 2007
@@ -18,45 +18,6 @@
   {
     InvariantCultureCompareInfo : CompareInfo = CultureInfo.InvariantCulture.CompareInfo;
 
-    public Append[T](mutable this source : array[T], value : T) : array[T]
-    {
-      def oldLen = source.Length;
-      Array.Resize(ref source, oldLen + 1);
-      source[oldLen] = value;
-      source
-    }
-
-    // Returns whether the first location is strictly inside the second
-    public StrictlyContains(this firstLocation : Location, secondLocation : Location) : bool
-    {
-      firstLocation.Contains(secondLocation) && firstLocation != secondLocation
-    }
-
-    // Returns whether the first location is (not strictly) inside the second
-    public Contains(this firstLocation : Location, secondLocation : Location) : bool
-    {
-      if (firstLocation.FileIndex == secondLocation.FileIndex)
-        firstLocation.Contains(secondLocation.Line, secondLocation.Column) &&
-          firstLocation.Contains(secondLocation.EndLine, secondLocation.EndColumn)
-      else
-        false
-    }
-
-    // Returns whether the first location is (not strictly) before the second (the left of first is to the left of second)
-    public StartsBefore(this firstLocation : Location, secondLocation: Location) : bool
-    {
-      if (firstLocation.Line < secondLocation.Line)
-        true
-      else if (firstLocation.Line > secondLocation.Line)
-        false
-      else if (firstLocation.Column < secondLocation.Column)
-        true
-      else if (firstLocation.Column > secondLocation.Column)
-        false
-      else
-        true
-    }
-
     // For debug purposes, brief output
     public Brief(this output : string, maximalLength : int = 100) : string
     {
@@ -355,36 +316,6 @@
       loop(members);
     }
 
-    public Contains(this location : Location, testFileIndex : int, 
-      testLine : int, testCol : int) : bool
-    {
-      if (location.FileIndex == testFileIndex)
-        location.Contains(testLine, testCol)
-      else
-        false
-    }
-
-    /// The 'lst' must be ordered. This function test only first and last elements.
-    public OrderedContains[T](this lst : list[T], testLine : int, testCol : int) : bool
-      where T : Located
-    {
-      Debug.Assert(lst.IsOrdered((x, y) => x.Location.CompareTo(y.Location) > 0));
-
-      if (lst.IsEmpty)
-        false
-      else
-        (lst.Head.Location + lst.Last.Location).Contains(testLine, testCol)
-    }
-
-    /// The 'lst' must be ordered. This function test only first and last elements.
-    public EnclosingLocation(this lst : list[Location]) : Location
-    {
-      Debug.Assert(lst.IsOrdered((x, y) => x.CompareTo(y) > 0));
-      Debug.Assert(!lst.IsEmpty);
-      
-      lst.Head + lst.Last
-    }
-
     /// It's poor performance and very pared-down implementation of 
     /// qualified identifier fersing.
     public ParseQualIdent(text : string) : list[string]
@@ -427,121 +358,6 @@
       parse(text.Explode(), []).Rev()
     }
 
-    public TrimStart(this l1 : Location, l2 : Location) : Location
-    {
-      TrimStart(l1, l2, true)
-    }
-
-    public TrimStart(this l1 : Location, l2 : Location, adjustBegin : bool) : Location
-    {
-      mutable lbeg;
-      mutable cbeg;
-
-      def adj = if (adjustBegin) 1 else 0;
-
-      if      (l1.Line < l2.EndLine) { lbeg = l2.EndLine; cbeg = l2.EndColumn + adj; }
-      else if (l1.Line > l2.EndLine) { lbeg = l1.Line;    cbeg = l1.Column; }
-      else
-      {
-        lbeg = l1.Line;
-        cbeg = if (l1.Column < l2.EndColumn) l2.EndColumn + adj else l1.Column;
-      }
-
-      Location(l1.FileIndex, lbeg, cbeg, l1.EndLine, l1.EndColumn)
-    }
-
-    public TrimEnd(this l1 : Location, l2 : Location) : Location
-    {
-      mutable lend;
-      mutable cend;
-
-      if      (l1.EndLine > l2.Line) { lend = l2.Line;    cend = l2.Column - 1; }
-      else if (l1.EndLine < l2.Line) { lend = l1.EndLine; cend = l2.EndColumn; }
-      else
-      {
-        lend = l1.EndLine;
-        cend = if (l1.EndColumn > l2.Column) l2.Column else l1.EndColumn;
-      }
-
-      Location(l1.FileIndex, l1.Line, l1.Column, lend, cend)
-    }
-
-    public Trim(this l1 : Location, l2 : Location, line : int, col : int) : Location
-    {
-      if (line < l2.Line || line == l2.Line && col < l2.Column)
-        l1.TrimEnd(l2)
-      else if (line > l2.EndLine || line == l2.EndLine && col > l2.EndColumn)
-        l1.TrimStart(l2, true)
-      else
-        l1
-    }
-
-    public Combine(l1 : Location, l2 : Location) : Location
-    {
-      mutable lbeg;
-      mutable cbeg;
-
-      if      (l1.Line < l2.Line) { lbeg = l1.Line; cbeg = l1.Column; }
-      else if (l1.Line > l2.Line) { lbeg = l2.Line; cbeg = l2.Column; }
-      else
-      {
-        lbeg = l1.Line;
-        cbeg = if (l1.Column < l2.Column) l1.Column else l2.Column;
-      }
-
-      mutable lend;
-      mutable cend;
-
-      if      (l1.EndLine > l2.EndLine) { lend = l1.EndLine; cend = l1.EndColumn; }
-      else if (l1.EndLine < l2.EndLine) { lend = l2.EndLine; cend = l2.EndColumn; }
-      else
-      {
-        lend = l1.EndLine;
-        cend = if (l1.EndColumn > l2.EndColumn) l1.EndColumn else l2.EndColumn;
-      }
-
-      Location(l1.FileIndex, lbeg, cbeg, lend, cend)
-    }
-
-    public Intersect(this l1 : Location, l2 : Location) : Location
-      requires l1.FileIndex == l2.FileIndex || l1.FileIndex == 0 || l2.FileIndex == 0
-    {
-      mutable lbeg;
-      mutable cbeg;
-
-      if      (l1.Line < l2.Line) { lbeg = l2.Line; cbeg = l2.Column; }
-      else if (l1.Line > l2.Line) { lbeg = l1.Line; cbeg = l1.Column; }
-      else
-      {
-        lbeg = l1.Line;
-        cbeg = if (l1.Column < l2.Column) l2.Column else l1.Column;
-      }
-
-      mutable lend;
-      mutable cend;
-
-      if      (l1.EndLine > l2.EndLine) { lend = l2.EndLine; cend = l2.EndColumn; }
-      else if (l1.EndLine < l2.EndLine) { lend = l1.EndLine; cend = l1.EndColumn; }
-      else
-      {
-        lend = l1.EndLine;
-        cend = if (l1.EndColumn > l2.EndColumn) l2.EndColumn else l1.EndColumn;
-      }
-
-      Location(l1.FileIndex, lbeg, cbeg, lend, cend)
-    }
-
-    public IsEqualExcludingFile(this l1 : Location, l2 : Location) : bool
-    {
-      l1.Line   == l2.Line   && l1.EndLine   == l2.EndLine &&
-      l1.Column == l2.Column && l1.EndColumn == l2.EndColumn
-    }
-
-    public IsEmpty(this loc : Location) : bool
-    {
-      loc.EndLine == 0 || loc.EndLine < loc.Line || (loc.EndLine == loc.Line && loc.EndColumn <= loc.Column)
-    }
-
     public GetLocalPath(this asm : Assembly) : string
     {
        Uri(asm.CodeBase).LocalPath;
@@ -583,5 +399,16 @@
       loop(l, pred, 0)
     }
 
+    /// The 'lst' must be ordered. This function test only first and last elements.
+    public static OrderedContains[T](this lst : list[T], testLine : int, testCol : int) : bool
+      where T : Located
+    {
+      Debug.Assert(lst.IsOrdered((x, y) => x.Location.CompareTo(y.Location) > 0));
+
+      if (lst.IsEmpty)
+        false
+      else
+        (lst.Head.Location + lst.Last.Location).Contains(testLine, testCol)
+    }
   } // End of Utils module
 } // End of namespace
\ No newline at end of file

Modified: vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.Designer.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.Designer.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.Designer.cs	Mon Jan  8 07:37:24 2007
@@ -30,6 +30,7 @@
 		{
 			this.components = new System.ComponentModel.Container();
 			this.panel1 = new System.Windows.Forms.Panel();
+			this._buildTypedtreeCountLabel = new System.Windows.Forms.Label();
 			this._displayType = new System.Windows.Forms.ComboBox();
 			this._checkCountLabel = new System.Windows.Forms.Label();
 			this._col = new System.Windows.Forms.Label();
@@ -38,7 +39,6 @@
 			this._grid = new System.Windows.Forms.DataGridView();
 			this._astColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
 			this._toolTip = new System.Windows.Forms.ToolTip(this.components);
-			this._buildTypedtreeCountLabel = new System.Windows.Forms.Label();
 			this.panel1.SuspendLayout();
 			((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit();
 			this.SuspendLayout();
@@ -57,6 +57,16 @@
 			this.panel1.Size = new System.Drawing.Size(245, 46);
 			this.panel1.TabIndex = 0;
 			// 
+			// _buildTypedtreeCountLabel
+			// 
+			this._buildTypedtreeCountLabel.AutoSize = true;
+			this._buildTypedtreeCountLabel.Location = new System.Drawing.Point(212, 4);
+			this._buildTypedtreeCountLabel.Name = "_buildTypedtreeCountLabel";
+			this._buildTypedtreeCountLabel.Size = new System.Drawing.Size(13, 13);
+			this._buildTypedtreeCountLabel.TabIndex = 3;
+			this._buildTypedtreeCountLabel.Text = "0";
+			this._toolTip.SetToolTip(this._buildTypedtreeCountLabel, "Build typed tree count");
+			// 
 			// _displayType
 			// 
 			this._displayType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@@ -119,6 +129,7 @@
             this._astColumn});
 			this._grid.Dock = System.Windows.Forms.DockStyle.Fill;
 			this._grid.Location = new System.Drawing.Point(0, 46);
+			this._grid.MultiSelect = false;
 			this._grid.Name = "_grid";
 			this._grid.ReadOnly = true;
 			this._grid.Size = new System.Drawing.Size(245, 269);
@@ -135,16 +146,6 @@
 			this._astColumn.Name = "_astColumn";
 			this._astColumn.ReadOnly = true;
 			// 
-			// _buildTypedtreeCountLabel
-			// 
-			this._buildTypedtreeCountLabel.AutoSize = true;
-			this._buildTypedtreeCountLabel.Location = new System.Drawing.Point(212, 4);
-			this._buildTypedtreeCountLabel.Name = "_buildTypedtreeCountLabel";
-			this._buildTypedtreeCountLabel.Size = new System.Drawing.Size(13, 13);
-			this._buildTypedtreeCountLabel.TabIndex = 3;
-			this._buildTypedtreeCountLabel.Text = "0";
-			this._toolTip.SetToolTip(this._buildTypedtreeCountLabel, "Build typed tree count");
-			// 
 			// AstToolControl
 			// 
 			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

Modified: vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.cs	Mon Jan  8 07:37:24 2007
@@ -38,6 +38,11 @@
 		{
 			_line.Text = line.ToString();
 			_col.Text  = col.ToString();
+			int index = _items.FindLastIndex(
+				delegate(AstNodeInfo n) { return n.Location.Contains(line, col); });
+
+			if (index >= 0)
+				_grid.CurrentCell = _grid.Rows[index].Cells[0];
 		}
 
 		private void _grid_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)

Modified: vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.resx
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.resx	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolControl.resx	Mon Jan  8 07:37:24 2007
@@ -123,7 +123,7 @@
   <metadata name="_astColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="_astColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
+  <metadata name="_toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
   </metadata>
 </root>
\ No newline at end of file

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs	Mon Jan  8 07:37:24 2007
@@ -153,7 +153,7 @@
 			{
 				Location last = selectionsStack[selectionsStack.Count - 1];
 				Location word = Utils.LocationFromSpan(last.FileIndex, wordSpan);
-				if (Nemerle.Compiler.Utils.Utils.StrictlyContains(last, word) && last != word)
+				if (last.StrictlyContains(word) && last != word)
 					selectionsStack.Add(word);
 			}
 			else



More information about the svn mailing list