[svn] r7202: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n Nemerle.VsIntegr...

VladD2 svnadmin at nemerle.org
Thu Jan 4 21:17:22 CET 2007


Log:
Work on AstToolWindow.

Author: VladD2
Date: Thu Jan  4 21:17:19 2007
New Revision: 7202

Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.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/NemerleLanguageService.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs
   vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n	Thu Jan  4 21:17:19 2007
@@ -14,6 +14,19 @@
 {
 	public module AstUtils
 	{
+    public FillList(lex : LexerBase, items : SCG.List[AstNodeInfo]) : void
+    {
+      def scan(toc : Token)
+      {
+        | EndOfFile => items.Add(AstNodeInfo("EOF", toc.Location));
+        | _ =>
+          items.Add(AstNodeInfo(toc.ToString(), toc.Location));
+          scan(lex.GetToken());
+      }
+
+      scan(lex.GetToken());
+    }
+
     public FillList(rootNamespase : Decl.Namespace, items : SCG.List[AstNodeInfo]) : void
     {
       items.Clear();

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	Thu Jan  4 21:17:19 2007
@@ -30,19 +30,21 @@
 		{
 			this.components = new System.ComponentModel.Container();
 			this.panel1 = new System.Windows.Forms.Panel();
+			this._checkCountLabel = new System.Windows.Forms.Label();
 			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._checkCountLabel = new System.Windows.Forms.Label();
+			this._displayType = new System.Windows.Forms.ComboBox();
 			this.panel1.SuspendLayout();
 			((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit();
 			this.SuspendLayout();
 			// 
 			// panel1
 			// 
+			this.panel1.Controls.Add(this._displayType);
 			this.panel1.Controls.Add(this._checkCountLabel);
 			this.panel1.Controls.Add(this._col);
 			this.panel1.Controls.Add(this._line);
@@ -50,9 +52,19 @@
 			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, 23);
+			this.panel1.Size = new System.Drawing.Size(245, 46);
 			this.panel1.TabIndex = 0;
 			// 
+			// _checkCountLabel
+			// 
+			this._checkCountLabel.AutoSize = true;
+			this._checkCountLabel.Location = new System.Drawing.Point(200, 4);
+			this._checkCountLabel.Name = "_checkCountLabel";
+			this._checkCountLabel.Size = new System.Drawing.Size(13, 13);
+			this._checkCountLabel.TabIndex = 1;
+			this._checkCountLabel.Text = "0";
+			this._toolTip.SetToolTip(this._checkCountLabel, "Check count");
+			// 
 			// _col
 			// 
 			this._col.AutoSize = true;
@@ -92,10 +104,10 @@
 			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.Location = new System.Drawing.Point(0, 46);
 			this._grid.Name = "_grid";
 			this._grid.ReadOnly = true;
-			this._grid.Size = new System.Drawing.Size(245, 292);
+			this._grid.Size = new System.Drawing.Size(245, 269);
 			this._grid.TabIndex = 1;
 			this._grid.VirtualMode = true;
 			this._grid.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this._grid_CellClick);
@@ -108,17 +120,18 @@
 			this._astColumn.HeaderText = "AST";
 			this._astColumn.Name = "_astColumn";
 			this._astColumn.ReadOnly = true;
-			this._astColumn.Width = 53;
 			// 
-			// _checkCountLabel
+			// _displayType
 			// 
-			this._checkCountLabel.AutoSize = true;
-			this._checkCountLabel.Location = new System.Drawing.Point(200, 4);
-			this._checkCountLabel.Name = "_checkCountLabel";
-			this._checkCountLabel.Size = new System.Drawing.Size(13, 13);
-			this._checkCountLabel.TabIndex = 1;
-			this._checkCountLabel.Text = "0";
-			this._toolTip.SetToolTip(this._checkCountLabel, "Check count");
+			this._displayType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+			this._displayType.Items.AddRange(new object[] {
+            "Tokens",
+            "AST"});
+			this._displayType.Location = new System.Drawing.Point(3, 20);
+			this._displayType.Margin = new System.Windows.Forms.Padding(2);
+			this._displayType.Name = "_displayType";
+			this._displayType.Size = new System.Drawing.Size(158, 21);
+			this._displayType.TabIndex = 2;
 			// 
 			// AstToolControl
 			// 
@@ -145,5 +158,6 @@
 		private System.Windows.Forms.Label _line;
 		private System.Windows.Forms.ToolTip _toolTip;
 		private System.Windows.Forms.Label _checkCountLabel;
+		private System.Windows.Forms.ComboBox _displayType;
 	}
 }

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	Thu Jan  4 21:17:19 2007
@@ -11,6 +11,8 @@
 using Nemerle.Builtins;
 using Nemerle.Compiler.Utils;
 using Nemerle.VisualStudio.Properties;
+using Nemerle.VisualStudio.Project;
+using Nemerle.VisualStudio.LanguageService;
 
 namespace Nemerle.VisualStudio.GUI
 {
@@ -20,28 +22,13 @@
 		{
 			InitializeComponent();
 			_autoUpdateCheckBox.Checked = Settings.Default.AutoShowAst;
+			_displayType.SelectedIndex = 1;
 		}
 
 		List<AstNodeInfo> _items = new List<AstNodeInfo>(10000);
 
-		Decl.Namespace _rootNamespase;
-
 		int _checkCount;
 
-		public Decl.Namespace RootNamespase
-		{
-			get { return _rootNamespase; }
-			set
-			{
-				_checkCountLabel.Text = (++_checkCount).ToString();
-				_rootNamespase = value;
-				AstUtils.FillList(_rootNamespase, _items);
-				_grid.RowCount = _items.Count;
-				_grid.Invalidate();
-				_grid.Update();
-			}
-		}
-
 		public bool IsAutoUpdate
 		{
 			get { return _autoUpdateCheckBox.Checked; }
@@ -87,5 +74,38 @@
 		{
 			Settings.Default.AutoShowAst = _autoUpdateCheckBox.Checked;
 		}
+
+		internal void ShowInfo(NemerleSource source)
+		{
+			_checkCountLabel.Text = (++_checkCount).ToString();
+			_items.Clear();
+			ProjectInfo projectInfo = source.ProjectInfo;
+
+			if (projectInfo == null)
+				return;
+
+			switch (_displayType.SelectedIndex)
+			{
+				case 0: // Tokens
+					string code = source.GetText();
+					
+					LexerBase lex = new LexerString(projectInfo.Engine, code,
+						new Location(source.FileIndex, 1, 1));
+					//lex.BeginParseFile();
+					lex.Keywords = lex.Manager.CoreEnv.Keywords;
+					AstUtils.FillList(lex, _items);
+					break;
+				case 1: // AST
+					Decl.Namespace ns = projectInfo.Engine.Project.CompileUnits[source.FileIndex];
+					AstUtils.FillList(ns, _items);
+					break;
+			}
+
+			_grid.RowCount = _items.Count;
+			_grid.Invalidate();
+			_grid.Update();
+		}
+
+
 	}
 }

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	Thu Jan  4 21:17:19 2007
@@ -123,4 +123,10 @@
   <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>
+  <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/GUI/AstToolWindow.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolWindow.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/AstToolWindow.cs	Thu Jan  4 21:17:19 2007
@@ -9,6 +9,7 @@
 using Microsoft.VisualStudio.Shell;
 using Nemerle.Compiler;
 using Nemerle.Completion2;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VisualStudio.GUI
 {
@@ -69,12 +70,6 @@
 			get { return _control.IsAutoUpdate; }
 		}
 
-		public Decl.Namespace RootNamespase
-		{
-			get { return _control.RootNamespase; }
-			set { _control.RootNamespase = value; }
-		}
-
 		public void Activate(int line, int col)
 		{
 			_control.Activate(line, col);
@@ -88,5 +83,10 @@
 		{
 			get { return (IWin32Window)_control; }
 		}
+
+		internal void ShowInfo(Nemerle.VisualStudio.LanguageService.NemerleSource source)
+		{
+			_control.ShowInfo(source);
+		}
 	}
 }

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs	Thu Jan  4 21:17:19 2007
@@ -160,10 +160,7 @@
 
 				AstToolWindow tool = AstToolWindow.AstTool;
 				if (tool != null && tool.IsAutoUpdate)
-				{
-					Decl.Namespace ns = projectInfo.Engine.Project.CompileUnits[source.FileIndex];
-					tool.RootNamespase = ns;
-				}
+					tool.ShowInfo(source);
 
 				return scope;
 			}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleTypeAndMemberDropdownBars .cs	Thu Jan  4 21:17:19 2007
@@ -44,6 +44,8 @@
 			{
 				ret = true;
 
+				//VladD2:  Ýòà ñòðîêà ïðèâîäèò ê ïåðåïàðñèâàíèþ âñåãî ÀÑÒ. Ìîæåò çäåñü ëó÷øå 
+				// èñïîüçîâàòü RawProject?
 				List<TypeBuilder> builders = _source.ProjectInfo.Project.GetTypes(_source.FileIndex);
 
 				List<NemerleDropDownMember> list = new List<NemerleDropDownMember>();
@@ -63,6 +65,8 @@
 							span.iEndLine    = loc.EndLine - 1;
 							span.iEndIndex   = loc.EndColumn - 1;
 
+							//VladD2: Ìíå êàæåòñÿ ÷òî NemerleDropDownMember ñîâåðøåííî íåíóæåí.
+							// âìåñòî íåãî õîðîøî áû ïðîñòî êëàñòü ýëåìåíò AST. Ýòî ñýêîíîìèëî áû âðåìÿ.
 							list.Add(new NemerleDropDownMember(
 								tb,
 								_source.FileIndex,

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	Thu Jan  4 21:17:19 2007
@@ -265,6 +265,12 @@
     <ZipProject Include="Templates\Projects\WindowsApplication\Program.n" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="..\..\..\..\VS\VSSDK\2006.12\VisualStudioIntegration\Common\Source\CSharp\Project\Microsoft.VisualStudio.Package.Project.Designer.cs">
+      <Link>Microsoft.VisualStudio.Package.Project.Designer.cs</Link>
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Microsoft.VisualStudio.Package.Project.resx</DependentUpon>
+    </Compile>
     <Compile Include="Project\RDTFileTextMerger.cs" />
     <Compile Include="GUI\AstToolControl.cs">
       <SubType>UserControl</SubType>



More information about the svn mailing list