[svn] r7155: vs-plugin/trunk: Nemerle.Compiler.Utils/Utils.n Nemerle.VsIntegration/GUI/AstToolControl.Desi...

VladD2 svnadmin at nemerle.org
Wed Dec 27 05:23:31 CET 2006


Log:
Work on AstToolWindow.

Author: VladD2
Date: Wed Dec 27 05:23:25 2006
New Revision: 7155

Added:
   vs-plugin/trunk/Nemerle.VsIntegration/Resources/Images_24bit.bmp   (contents, props changed)
Modified:
   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/GUI/AstToolWindow.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj
   vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Resources.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Resources.resx

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	Wed Dec 27 05:23:25 2006
@@ -18,6 +18,19 @@
   {
     InvariantCultureCompareInfo : CompareInfo = CultureInfo.InvariantCulture.CompareInfo;
 
+    public FillList(rootNamespase : Decl.Namespace, items : SCG.List[object]) : void
+    {
+      def cnt = items.Count;
+      items.Clear();
+
+      if (cnt == 4)
+        items.AddRange(array["aaaaaaa" : object, "bbb", "cccccccccccccccc", "dd", "eee"]);
+      else
+        items.AddRange(array["aaaaaaa" : object, "bbb", "cccccccccccccccc", "dd"]);
+
+      _ = rootNamespase;
+    }
+
     // Returns whether the first location is strictly inside the second
     public StrictlyContains(this firstLocation : Location, secondLocation : Location) : bool
     {

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	Wed Dec 27 05:23:25 2006
@@ -28,47 +28,75 @@
 		/// </summary>
 		private void InitializeComponent()
 		{
+			this.components = new System.ComponentModel.Container();
 			this.panel1 = new System.Windows.Forms.Panel();
-			this.dataGridView1 = new System.Windows.Forms.DataGridView();
+			this._col = new System.Windows.Forms.Label();
+			this._line = new System.Windows.Forms.Label();
 			this._autoUpdateCheckBox = new System.Windows.Forms.CheckBox();
+			this._grid = new System.Windows.Forms.DataGridView();
 			this._astColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+			this._toolTip = new System.Windows.Forms.ToolTip(this.components);
 			this.panel1.SuspendLayout();
-			((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+			((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit();
 			this.SuspendLayout();
 			// 
 			// panel1
 			// 
+			this.panel1.Controls.Add(this._col);
+			this.panel1.Controls.Add(this._line);
 			this.panel1.Controls.Add(this._autoUpdateCheckBox);
 			this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
 			this.panel1.Location = new System.Drawing.Point(0, 0);
 			this.panel1.Name = "panel1";
-			this.panel1.Size = new System.Drawing.Size(245, 28);
+			this.panel1.Size = new System.Drawing.Size(245, 23);
 			this.panel1.TabIndex = 0;
 			// 
-			// dataGridView1
+			// _col
 			// 
-			this.dataGridView1.AllowUserToAddRows = false;
-			this.dataGridView1.AllowUserToDeleteRows = false;
-			this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-			this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
-            this._astColumn});
-			this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
-			this.dataGridView1.Location = new System.Drawing.Point(0, 28);
-			this.dataGridView1.Name = "dataGridView1";
-			this.dataGridView1.ReadOnly = true;
-			this.dataGridView1.Size = new System.Drawing.Size(245, 287);
-			this.dataGridView1.TabIndex = 1;
+			this._col.AutoSize = true;
+			this._col.Location = new System.Drawing.Point(148, 4);
+			this._col.Name = "_col";
+			this._col.Size = new System.Drawing.Size(13, 13);
+			this._col.TabIndex = 1;
+			this._col.Text = "0";
+			this._toolTip.SetToolTip(this._col, "Current char offset");
+			// 
+			// _line
+			// 
+			this._line.AutoSize = true;
+			this._line.Location = new System.Drawing.Point(93, 4);
+			this._line.Name = "_line";
+			this._line.Size = new System.Drawing.Size(13, 13);
+			this._line.TabIndex = 1;
+			this._line.Text = "0";
+			this._toolTip.SetToolTip(this._line, "Current Line");
 			// 
 			// _autoUpdateCheckBox
 			// 
 			this._autoUpdateCheckBox.AutoSize = true;
-			this._autoUpdateCheckBox.Location = new System.Drawing.Point(16, 9);
+			this._autoUpdateCheckBox.Location = new System.Drawing.Point(3, 3);
 			this._autoUpdateCheckBox.Name = "_autoUpdateCheckBox";
 			this._autoUpdateCheckBox.Size = new System.Drawing.Size(84, 17);
 			this._autoUpdateCheckBox.TabIndex = 0;
 			this._autoUpdateCheckBox.Text = "Auto update";
 			this._autoUpdateCheckBox.UseVisualStyleBackColor = true;
 			// 
+			// _grid
+			// 
+			this._grid.AllowUserToAddRows = false;
+			this._grid.AllowUserToDeleteRows = false;
+			this._grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+			this._grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this._astColumn});
+			this._grid.Dock = System.Windows.Forms.DockStyle.Fill;
+			this._grid.Location = new System.Drawing.Point(0, 23);
+			this._grid.Name = "_grid";
+			this._grid.ReadOnly = true;
+			this._grid.Size = new System.Drawing.Size(245, 292);
+			this._grid.TabIndex = 1;
+			this._grid.VirtualMode = true;
+			this._grid.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this._grid_CellValueNeeded);
+			// 
 			// _astColumn
 			// 
 			this._astColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
@@ -81,13 +109,13 @@
 			// 
 			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-			this.Controls.Add(this.dataGridView1);
+			this.Controls.Add(this._grid);
 			this.Controls.Add(this.panel1);
 			this.Name = "AstToolControl";
 			this.Size = new System.Drawing.Size(245, 315);
 			this.panel1.ResumeLayout(false);
 			this.panel1.PerformLayout();
-			((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+			((System.ComponentModel.ISupportInitialize)(this._grid)).EndInit();
 			this.ResumeLayout(false);
 
 		}
@@ -95,8 +123,11 @@
 		#endregion
 
 		private System.Windows.Forms.Panel panel1;
-		private System.Windows.Forms.DataGridView dataGridView1;
+		private System.Windows.Forms.DataGridView _grid;
 		private System.Windows.Forms.CheckBox _autoUpdateCheckBox;
 		private System.Windows.Forms.DataGridViewTextBoxColumn _astColumn;
+		private System.Windows.Forms.Label _col;
+		private System.Windows.Forms.Label _line;
+		private System.Windows.Forms.ToolTip _toolTip;
 	}
 }

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	Wed Dec 27 05:23:25 2006
@@ -5,6 +5,8 @@
 using System.Data;
 using System.Text;
 using System.Windows.Forms;
+using Nemerle.Completion2;
+using CompUtils = Nemerle.Compiler.Utils.Utils;
 
 namespace Nemerle.VisualStudio.GUI
 {
@@ -14,5 +16,36 @@
 		{
 			InitializeComponent();
 		}
+
+		List<object> _items = new List<object>(10000);
+
+		Decl.Namespace _rootNamespase;
+
+		public Decl.Namespace RootNamespase
+		{
+			get { return _rootNamespase; }
+			set
+			{
+				_rootNamespase = value;
+				CompUtils.FillList(_rootNamespase, _items);
+				_grid.RowCount = _items.Count;
+			}
+		}
+
+		public bool IsAutoUpdate
+		{
+			get { return _autoUpdateCheckBox.Checked; }
+		}
+
+		public void Activate(int line, int col)
+		{
+			_line.Text = line.ToString();
+			_col.Text  = col.ToString();
+		}
+
+		private void _grid_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
+		{
+			e.Value = _items[e.RowIndex];
+		}
 	}
 }

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	Wed Dec 27 05:23:25 2006
@@ -117,6 +117,9 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="_toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
   <metadata name="_astColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>

Modified: vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolWindow.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolWindow.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolWindow.cs	Wed Dec 27 05:23:25 2006
@@ -7,6 +7,8 @@
 using System.Runtime.InteropServices;
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.Shell;
+using Nemerle.Compiler;
+using Nemerle.Completion2;
 
 namespace Nemerle.VisualStudio.GUI
 {
@@ -22,11 +24,17 @@
 	[Guid("721e9eb7-98fa-4efb-9e17-d60a6894ccd0")]
 	public class AstToolWindow : ToolWindowPane
 	{
+		static AstToolWindow _astToolWindow;
+		public static AstToolWindow AstTool
+		{
+			get { return _astToolWindow; }
+		}
+
 		// This is the user control hosted by the tool window; it is exposed to the base class 
 		// using the Window property. Note that, even if this class implements IDispose, we are
 		// not calling Dispose on this object. This is because ToolWindowPane calls Dispose on 
 		// the object returned by the Window property.
-		private AstToolControl control;
+		private AstToolControl _control;
 
 		/// <summary>
 		/// Standard constructor for the tool window.
@@ -35,6 +43,7 @@
 			:
 				base(null)
 		{
+			_astToolWindow = this;
 			// Set the window title reading it from the resources.
 			this.Caption = "AST";
 			// Set the image that will appear on the tab of the window frame
@@ -43,10 +52,32 @@
 			// while the Index is the offset in the bitmap strip. Each image in
 			// the strip being 16x16.
 			this.BitmapResourceID = 301;
-			this.BitmapIndex = 1;
+			this.BitmapIndex = 2;
+
+
+			_control = new AstToolControl();
+		}
+
+		protected override void OnClose()
+		{
+			_astToolWindow = null;
+			base.OnClose();
+		}
 
+		public bool IsAutoUpdate
+		{
+			get { return _control.IsAutoUpdate; }
+		}
 
-			control = new AstToolControl();
+		public Decl.Namespace RootNamespase
+		{
+			get { return _control.RootNamespase; }
+			set { _control.RootNamespase = value; }
+		}
+
+		public void Activate(int line, int col)
+		{
+			_control.Activate(line, col);
 		}
 
 		/// <summary>
@@ -55,11 +86,7 @@
 		/// </summary>
 		override public IWin32Window Window
 		{
-			get
-			{
-				return (IWin32Window)control;
+			get { return (IWin32Window)_control; }
 			}
 		}
-
-	}
 }

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	Wed Dec 27 05:23:25 2006
@@ -10,6 +10,7 @@
 using Nemerle.Completion2;
 using Nemerle.Compiler;
 using Nemerle.VisualStudio.Project;
+using Nemerle.VisualStudio.GUI;
 
 namespace Nemerle.VisualStudio.LanguageService
 {
@@ -20,6 +21,24 @@
 		{
 		}
 
+		public override void OnChangeScrollInfo(IVsTextView view, int iBar, 
+			int iMinUnit, int iMaxUnits, int iVisibleUnits, int iFirstVisibleUnit)
+		{
+			base.OnChangeScrollInfo(view, iBar, iMinUnit, iMaxUnits, iVisibleUnits, iFirstVisibleUnit);
+			NemerleSource source = Source as NemerleSource;
+			if (source != null)
+			{
+				int line, col;
+				ErrorHandler.ThrowOnFailure(view.GetCaretPos(out line, out col));
+				//Debug.WriteLine(
+				//		string.Format("OnChangeScrollInfo line={0}, col={1}", line + 1, col + 1));
+				AstToolWindow tw = (AstToolWindow)source.ProjectInfo.ProjectNode.Package
+					.FindToolWindow(typeof(AstToolWindow), 0, true);
+
+				tw.Activate(line + 1, col + 1);
+			}
+		}
+
 		protected override int ExecCommand(ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
 		{
 			string txt = null;

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj	Wed Dec 27 05:23:25 2006
@@ -204,6 +204,7 @@
     <Content Include="CodeSnippets\Snippets\match.snippet">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
+    <None Include="Resources\Images_24bit.bmp" />
     <None Include="CtcComponents\Guids.h" />
     <None Include="CtcComponents\PkgCmdID.h" />
     <None Include="nemerle.snk" />

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs	Wed Dec 27 05:23:25 2006
@@ -18,6 +18,7 @@
 using MSBuild = Microsoft.Build.BuildEngine;
 using SourceMap = System.Collections.Generic.Dictionary<string, Nemerle.VisualStudio.LanguageService.NemerleSource>;
 using ProjectManager = Nemerle.VisualStudio.LanguageService.ProjectManager;
+using Nemerle.VisualStudio.GUI;
 
 namespace Nemerle.VisualStudio.Project
 {
@@ -321,17 +322,6 @@
 				//  return;
 				//}
 
-#if DebugLocations
-				// Just debug staff.
-				// Update file content, because it is changed, but engine still doesn't know it.
-				if (ProjectNode.Site != null)
-				{
-					NemerleSource source = GetSource(filePath);
-					if (source != null)
-						Engine.Sources.AddOrUpdate(filePath, source.GetText());
-				}
-
-#endif
 				// Reset link to the project. It leads next request to Project property
 				// will create new project, and accordingly will create new types tree.
 				ResetTypeTree();
@@ -343,6 +333,15 @@
 				Engine.Project.UpdateDebugTree(fileIndex);
 #endif
 			}
+
+			AstToolWindow tool = AstToolWindow.AstTool;
+			if (tool != null && tool.IsAutoUpdate)
+			{
+				int fileIndex = Location.GetFileIndex(filePath);
+				//FixMy: get_Item is accessor! It must be accessed directly! Fix ncc.
+				Decl.Namespace ns = Engine.Project.CompileUnits.get_Item(fileIndex);
+				tool.RootNamespase = ns;
+			}
 		}
 
 		public Nemerle.Completion2.Project Project

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Resources.Designer.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Resources.Designer.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Resources.Designer.cs	Wed Dec 27 05:23:25 2006
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.42
+//     Runtime Version:2.0.50727.308
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -94,6 +94,13 @@
             }
         }
         
+        internal static System.Drawing.Bitmap _301 {
+            get {
+                object obj = ResourceManager.GetObject("301", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Application.
         /// </summary>

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Resources.resx
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Resources.resx	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Resources.resx	Wed Dec 27 05:23:25 2006
@@ -230,4 +230,7 @@
   <data name="300" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>Resources\Nemerle.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="301" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>Resources\Images_24bit.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/Resources/Images_24bit.bmp
==============================================================================
Binary file. No diff available.



More information about the svn mailing list