[svn] r7551: vs-plugin/trunk: Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n N...

phantom svnadmin at nemerle.org
Tue Mar 27 15:37:21 CEST 2007


Log:
Highlight usages optionized.

Author: phantom
Date: Tue Mar 27 15:37:15 2007
New Revision: 7551

Added:
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.resx
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.resx
Removed:
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.cs
   vs-plugin/trunk/Nemerle.VsIntegration/GUI/GoToTypeForm.resx
Modified:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Type.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.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/Properties/Settings.Designer.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.settings
   vs-plugin/trunk/Nemerle.VsIntegration/app.config

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n	Tue Mar 27 15:37:15 2007
@@ -45,7 +45,7 @@
       }
     }
 
-    public HandleIdleTime([NotNull] lexer : ScanLexer, [NotNull] filePath : string, line : int, col : int) : void
+    public HighlightUsages([NotNull] lexer : ScanLexer, [NotNull] filePath : string, line : int, col : int) : void
     {
       def fileIndex = _compileUnits.GetFileIndex(filePath);
       def decl      = GetActiveDecl(fileIndex, line, col);

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	Tue Mar 27 15:37:15 2007
@@ -138,7 +138,7 @@
         {
           def found = ExprFinder().Find(method.BodyParsed, method.BodyTyped, line, col);
           def (_, _, typedObject) = found;
-
+/*
           def getParameter(name, parsedParameters, typedParameters)
           {
             match (parsedParameters)
@@ -157,6 +157,32 @@
             | reference is LocalValue when (reference.ValKind is LocalValue.Kind.FunParm) =>
               getParameter(reference.Name, ast.header.parms, method.Header.parms);
             | _ => found
+*/
+
+          def getParameterNumber(name, parameters, i = 0)
+          {
+            | (_, parameter :: tail, _) =>
+              if (parameter.Name == name)
+                i
+              else
+                getParameterNumber(name, tail, i + 1)
+            | (_, [], _) => -1
+          }
+
+          match (typedObject)
+          {
+            | reference is LocalValue when (reference.ValKind is LocalValue.Kind.FunParm) =>
+              def function = reference.DefinedIn;
+              def number = getParameterNumber(reference.Name, function.ParametersDeclarations);
+              if (number < 0)
+                found
+              else
+              {
+                def parsedParameter = function.ParametersDeclarations.Nth(number);
+                def typedParameter = function.parms.Nth(number);
+                (parsedParameter.name.Location, parsedParameter.name, typedParameter)
+              }
+            | _ => found
           }
         }
         else if (ast.header.Location.Contains(line, col))

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n	Tue Mar 27 15:37:15 2007
@@ -29,10 +29,10 @@
     
     public static RunTheTest() : void
     {
-      //def suite = FindDefinitionTestProjectTwo();
-      def suite = FindUsagesTestProjectTwo();
+      def suite = FindDefinitionTestProjectTwo();
+      //def suite = FindUsagesTestProjectTwo();
       suite.SetUp();
-      suite.Test043();
+      suite.Test047();
     }
 
     public static Explode(this s : string, delimiter : string) : list[string]

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Refactoring/TestProjectTwo/SmallTestsOne.n	Tue Mar 27 15:37:15 2007
@@ -67,6 +67,16 @@
     {
       WriteLine(foo); // usage {43}
     }
+    
+    public LocalFunction(foo6667 : int): void // definition {46} foo
+    {
+      def localFunction(foo6668 : int) // definition {47} foo
+      {
+        WriteLine(foo6668) // usage {47}
+      }
+      
+      localFunction(foo6667); // usage {46}
+    }
   }
   
   module SmallModule

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.Designer.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.Designer.cs	Tue Mar 27 15:37:15 2007
@@ -0,0 +1,100 @@
+namespace Nemerle.VisualStudio.GUI
+{
+  partial class GotoUsageForm
+  {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing)
+    {
+      if (disposing && (components != null))
+      {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent()
+    {
+		this._listView = new Nemerle.VisualStudio.GUI.AutoSizeListView();
+		this.FileName = new System.Windows.Forms.ColumnHeader();
+		this.LineNumber = new System.Windows.Forms.ColumnHeader();
+		this.TypeOfUsage = new System.Windows.Forms.ColumnHeader();
+		this.LineOfCode = new System.Windows.Forms.ColumnHeader();
+		this.SuspendLayout();
+		// 
+		// _listView
+		// 
+		this._listView.BorderStyle = System.Windows.Forms.BorderStyle.None;
+		this._listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.FileName,
+            this.LineNumber,
+            this.TypeOfUsage,
+            this.LineOfCode});
+		this._listView.Dock = System.Windows.Forms.DockStyle.Fill;
+		this._listView.FullRowSelect = true;
+		this._listView.Location = new System.Drawing.Point(0, 0);
+		this._listView.Name = "_listView";
+		this._listView.ShowItemToolTips = true;
+		this._listView.Size = new System.Drawing.Size(670, 274);
+		this._listView.TabIndex = 0;
+		this._listView.UseCompatibleStateImageBehavior = false;
+		this._listView.View = System.Windows.Forms.View.Details;
+		this._listView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.HandleListViewMouseDoubleClick);
+		// 
+		// FileName
+		// 
+		this.FileName.Text = "File";
+		this.FileName.Width = 100;
+		// 
+		// LineNumber
+		// 
+		this.LineNumber.Text = "Line";
+		this.LineNumber.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+		this.LineNumber.Width = 96;
+		// 
+		// TypeOfUsage
+		// 
+		this.TypeOfUsage.Text = "Type";
+		// 
+		// LineOfCode
+		// 
+		this.LineOfCode.Text = "Code";
+		this.LineOfCode.Width = 237;
+		// 
+		// GotoUsageForm
+		// 
+		this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+		this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+		this.ClientSize = new System.Drawing.Size(670, 274);
+		this.Controls.Add(this._listView);
+		this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
+		this.KeyPreview = true;
+		this.Name = "GotoUsageForm";
+		this.ShowInTaskbar = false;
+		this.Text = "Found Usages:";
+		this.ResumeLayout(false);
+
+    }
+
+    #endregion
+
+    private AutoSizeListView _listView;
+    private System.Windows.Forms.ColumnHeader FileName;
+    private System.Windows.Forms.ColumnHeader LineNumber;
+    private System.Windows.Forms.ColumnHeader LineOfCode;
+	  private System.Windows.Forms.ColumnHeader TypeOfUsage;
+  }
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.cs	Tue Mar 27 15:37:15 2007
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+using Nemerle.Completion2;
+using System.IO;
+
+using Nemerle.VisualStudio.Project;
+using Nemerle.VisualStudio.LanguageService;
+
+namespace Nemerle.VisualStudio.GUI
+{
+	public partial class GotoUsageForm : Form
+	{
+		public GotoInfo Result;
+
+		public GotoUsageForm(IList<GotoInfo> gotoInfos)
+		{
+			InitializeComponent();
+
+			foreach (GotoInfo gotoInfo in gotoInfos)
+			{
+				ProjectInfo project = ProjectInfo.FindProject(gotoInfo.FilePath);
+				string loc = "";
+				if (project != null)
+				{
+					NemerleSource source = project.GetSource(gotoInfo.FilePath);
+					if (source != null)
+						loc = source.GetLine(gotoInfo.Line - 1);
+				}
+				ListViewItem lvi = new ListViewItem(new string[]
+				{
+					Path.GetFileName(gotoInfo.FilePath),
+					gotoInfo.Line.ToString(),
+					gotoInfo.UsageTypeToString(),
+					loc.Replace("\t", "    ")
+				});
+				lvi.ToolTipText = gotoInfo.FilePath;
+				lvi.Tag = gotoInfo;
+				_listView.Items.Add(lvi);
+			}
+		}
+
+		protected override void OnLoad(EventArgs e)
+		{
+			base.OnLoad(e);
+
+			Rectangle parentRect = Screen.FromControl(this).WorkingArea;
+
+			// Adjust size
+			//
+			_listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
+
+			ClientSize = _listView.PreferredSize;
+
+			if (Width < 800)
+				Width = 800;
+			if (Height < 300)
+				Height = 300;
+			if (Width > parentRect.Width * 4/5)
+				Width  = parentRect.Width * 4/5;
+			if (Height > parentRect.Height*2/3)
+				Height = parentRect.Height*2/3;
+
+			// Adjust position
+			//
+			Left = parentRect.Left + (parentRect.Width  - Width)  / 2;
+			Top  = parentRect.Top  + (parentRect.Height - Height) / 2;
+
+			// Select first item by default
+			//
+			if (_listView.Items.Count > 0)
+				_listView.SelectedIndices.Add(0);
+		}
+
+		protected override void OnKeyPress(KeyPressEventArgs e)
+		{
+			base.OnKeyPress(e);
+
+			if (e.KeyChar == (char)Keys.Escape)
+				Close(DialogResult.Cancel);
+			else if (e.KeyChar == '\r' || e.KeyChar == ' ')
+				Close(DialogResult.OK);
+		}
+
+		protected override void OnFormClosing(FormClosingEventArgs e)
+		{
+			base.OnClosing(e);
+
+			if (DialogResult == DialogResult.OK)
+				if (_listView.FocusedItem.Tag == null)
+				{
+					e.Cancel = true;
+					MessageBox.Show(this, "You must select an item.", "Goto",
+						MessageBoxButtons.OK, MessageBoxIcon.Error);
+				}
+				else
+					Result = (GotoInfo)_listView.FocusedItem.Tag;
+		}
+
+		private void HandleListViewMouseDoubleClick(object sender, MouseEventArgs e)
+		{
+			Close(DialogResult.OK);
+		}
+
+		private void Close(DialogResult result)
+		{
+			DialogResult = result;
+			Close();
+		}
+	}
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.resx
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/GotoUsageForm.resx	Tue Mar 27 15:37:15 2007
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.Designer.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.Designer.cs	Tue Mar 27 15:37:15 2007
@@ -0,0 +1,104 @@
+namespace Nemerle.VisualStudio.GUI
+{
+	partial class Options
+	{
+		/// <summary>
+		/// Required designer variable.
+		/// </summary>
+		private System.ComponentModel.IContainer components = null;
+
+		/// <summary>
+		/// Clean up any resources being used.
+		/// </summary>
+		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+		protected override void Dispose(bool disposing)
+		{
+			if (disposing && (components != null))
+			{
+				components.Dispose();
+			}
+			base.Dispose(disposing);
+		}
+
+		#region Windows Form Designer generated code
+
+		/// <summary>
+		/// Required method for Designer support - do not modify
+		/// the contents of this method with the code editor.
+		/// </summary>
+		private void InitializeComponent()
+		{
+			this.okButton = new System.Windows.Forms.Button();
+			this.cancelButton = new System.Windows.Forms.Button();
+			this.highlightUsagesCheckBox = new System.Windows.Forms.CheckBox();
+			this.highlightUsagesUnlessTerminalSessionCheckBox = new System.Windows.Forms.CheckBox();
+			this.SuspendLayout();
+			// 
+			// okButton
+			// 
+			this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
+			this.okButton.Location = new System.Drawing.Point(355, 208);
+			this.okButton.Name = "okButton";
+			this.okButton.Size = new System.Drawing.Size(75, 23);
+			this.okButton.TabIndex = 0;
+			this.okButton.Text = "OK";
+			this.okButton.UseVisualStyleBackColor = true;
+			// 
+			// cancelButton
+			// 
+			this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+			this.cancelButton.Location = new System.Drawing.Point(436, 208);
+			this.cancelButton.Name = "cancelButton";
+			this.cancelButton.Size = new System.Drawing.Size(75, 23);
+			this.cancelButton.TabIndex = 1;
+			this.cancelButton.Text = "Cancel";
+			this.cancelButton.UseVisualStyleBackColor = true;
+			// 
+			// highlightUsagesCheckBox
+			// 
+			this.highlightUsagesCheckBox.AutoSize = true;
+			this.highlightUsagesCheckBox.Location = new System.Drawing.Point(12, 12);
+			this.highlightUsagesCheckBox.Name = "highlightUsagesCheckBox";
+			this.highlightUsagesCheckBox.Size = new System.Drawing.Size(104, 17);
+			this.highlightUsagesCheckBox.TabIndex = 2;
+			this.highlightUsagesCheckBox.Text = "Highlight usages";
+			this.highlightUsagesCheckBox.UseVisualStyleBackColor = true;
+			this.highlightUsagesCheckBox.CheckedChanged += new System.EventHandler(this.highlightUsagesCheckBox_CheckedChanged);
+			// 
+			// highlightUsagesUnlessTerminalSessionCheckBox
+			// 
+			this.highlightUsagesUnlessTerminalSessionCheckBox.AutoSize = true;
+			this.highlightUsagesUnlessTerminalSessionCheckBox.Location = new System.Drawing.Point(26, 35);
+			this.highlightUsagesUnlessTerminalSessionCheckBox.Name = "highlightUsagesUnlessTerminalSessionCheckBox";
+			this.highlightUsagesUnlessTerminalSessionCheckBox.Size = new System.Drawing.Size(186, 17);
+			this.highlightUsagesUnlessTerminalSessionCheckBox.TabIndex = 3;
+			this.highlightUsagesUnlessTerminalSessionCheckBox.Text = "Unless terminal session is enabled";
+			this.highlightUsagesUnlessTerminalSessionCheckBox.UseVisualStyleBackColor = true;
+			// 
+			// Options
+			// 
+			this.AcceptButton = this.okButton;
+			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+			this.CancelButton = this.cancelButton;
+			this.ClientSize = new System.Drawing.Size(523, 243);
+			this.Controls.Add(this.highlightUsagesUnlessTerminalSessionCheckBox);
+			this.Controls.Add(this.highlightUsagesCheckBox);
+			this.Controls.Add(this.cancelButton);
+			this.Controls.Add(this.okButton);
+			this.Cursor = System.Windows.Forms.Cursors.Default;
+			this.Name = "Options";
+			this.Text = "Nemerle Options";
+			this.ResumeLayout(false);
+			this.PerformLayout();
+
+		}
+
+		#endregion
+
+		private System.Windows.Forms.Button okButton;
+		private System.Windows.Forms.Button cancelButton;
+		private System.Windows.Forms.CheckBox highlightUsagesCheckBox;
+		private System.Windows.Forms.CheckBox highlightUsagesUnlessTerminalSessionCheckBox;
+	}
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.cs	Tue Mar 27 15:37:15 2007
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using Nemerle.VisualStudio.Properties;
+
+namespace Nemerle.VisualStudio.GUI
+{
+	public partial class Options : Form
+	{
+		public Options()
+		{
+			InitializeComponent();
+			highlightUsagesCheckBox.Checked = Settings.Default.HighlightUsages;
+			highlightUsagesUnlessTerminalSessionCheckBox.Checked =
+				Settings.Default.HighlightUsagesUnlessTerminalSession;
+		}
+
+		private void highlightUsagesCheckBox_CheckedChanged(object sender, EventArgs e)
+		{
+			highlightUsagesUnlessTerminalSessionCheckBox.Enabled =
+				highlightUsagesCheckBox.Checked;
+		}
+
+		public void Save()
+		{
+			Settings.Default.HighlightUsages = highlightUsagesCheckBox.Checked;
+			Settings.Default.HighlightUsagesUnlessTerminalSession =
+				highlightUsagesUnlessTerminalSessionCheckBox.Checked;
+		}
+	}
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.resx
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/GUI/Options.resx	Tue Mar 27 15:37:15 2007
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
\ No newline at end of file

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	Tue Mar 27 15:37:15 2007
@@ -20,6 +20,8 @@
 using Nemerle.VisualStudio.GUI;
 using Nemerle.Utility;
 
+using Nemerle.VisualStudio.Properties;
+
 namespace Nemerle.VisualStudio.LanguageService
 {
 	[Guid(NemerleConstants.LanguageServiceGuidString)]
@@ -414,26 +416,29 @@
 			}
 		}
 
-		private void HandleIdleTime(ParseRequest request)
+		private bool NowIsTerminalSession()
+		{
+			return false;
+		}
+
+		// HiglightUsages finds usages of a token and highlights it.
+		// It needs a file index and a location of a cursor
+		private void HighlightUsages(ParseRequest request)
 		{
 			ProjectInfo projectInfo = GetProjectInfo(request);
 
 			if (projectInfo == null)
 				return;
 
-			projectInfo.HandleIdleTime(request.FileName, request.Line, request.Col,
+			if (Settings.Default.HighlightUsages)
+				if (!Settings.Default.HighlightUsagesUnlessTerminalSession || !NowIsTerminalSession())
+					projectInfo.HighlightUsages(request.FileName, request.Line, request.Col,
 				new SourceTextManager(projectInfo.GetSource(request.FileName)));
 		}
 
 		private AuthoringScope GetMethodScope(ParseRequest request)
 		{
-			// TODO: find the place of cursor or memorize where it was the last time
-			// TODO: move the HandleIdleTime invocation to the DoIdle handler or its connected sink
-			// HandleIdleTime finds usages of a token and highlights it
-			// it slows down showing a tip for a token
-			// actually, it needs a file index and a location of a cursor
-			// but it is a nice idea, to highlight usages in "get tip", should be an option
-			HandleIdleTime(request);
+			HighlightUsages(request);
 
 			string text;
 

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	Tue Mar 27 15:37:15 2007
@@ -71,7 +71,10 @@
 					break;
 				case 0x3103: txt = "cmdIdRename"; break;
 				case 0x3104: txt = "cmdIdInline"; break;
-				case 0x3105: txt = "cmdIdOptions"; break;
+				case 0x3105:
+					// cmdIdOptions
+					ShowOptions();
+					break;
 				case 0x3106: // AstToolWindow
 					//this.CodeWindowManager.LanguageService.
 					NemerleSource source = Source as NemerleSource;
@@ -147,6 +150,13 @@
 			return false;
 		}
 
+		private void ShowOptions()
+		{
+			using (Options options = new Options())
+				if (options.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+					options.Save();
+		}
+
 		private void AddWordSpan(TextSpan selection)
 		{
 			TextSpan[] spans = new TextSpan[1];

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	Tue Mar 27 15:37:15 2007
@@ -125,11 +125,11 @@
     <Compile Include="GUI\AutoSizeListView.cs">
       <SubType>Component</SubType>
     </Compile>
-    <Compile Include="GUI\GoToTypeForm.cs">
+    <Compile Include="GUI\GotoUsageForm.cs">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="GUI\GoToTypeForm.Designer.cs">
-      <DependentUpon>GoToTypeForm.cs</DependentUpon>
+    <Compile Include="GUI\GotoUsageForm.Designer.cs">
+      <DependentUpon>GotoUsageForm.cs</DependentUpon>
     </Compile>
     <Compile Include="GUI\NativeMethods.cs" />
     <Compile Include="LanguageService\NemerleAuthoringScope.cs" />
@@ -266,6 +266,12 @@
     <ZipProject Include="Templates\Projects\WindowsApplication\Program.n" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="GUI\Options.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="GUI\Options.Designer.cs">
+      <DependentUpon>Options.cs</DependentUpon>
+    </Compile>
     <Compile Include="Project\NemerleOAProject.cs" />
     <Compile Include="Project\NemerleOAProperties.cs" />
     <Compile Include="Project\RDTFileTextMerger.cs" />
@@ -293,9 +299,13 @@
       <SubType>Designer</SubType>
       <DependentUpon>AstToolControl.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="GUI\GoToTypeForm.resx">
+    <EmbeddedResource Include="GUI\GotoUsageForm.resx">
+      <SubType>Designer</SubType>
+      <DependentUpon>GotoUsageForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="GUI\Options.resx">
       <SubType>Designer</SubType>
-      <DependentUpon>GoToTypeForm.cs</DependentUpon>
+      <DependentUpon>Options.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="Resources\NemerleImageList.bmp" />
     <ZipProject Include="Templates\Projects\WindowsApplication\NemerleMacroLibrary.vstemplate" />

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	Tue Mar 27 15:37:15 2007
@@ -463,9 +463,9 @@
 			return result;
 		}
 
-		internal void HandleIdleTime(string filePath, int line, int column, ISource source)
+		internal void HighlightUsages(string filePath, int line, int column, ISource source)
 		{
-			Trace.WriteLine(">>>> ##### HandleIdleTime!");
+			Trace.WriteLine(">>>> ##### HighlightUsages!");
 			ErrorHelper.ThrowIfPathNullOrEmpty(filePath, "filePath");
 			SourceTextManager manager = source as SourceTextManager;
 			if (manager == null)
@@ -473,9 +473,9 @@
 			ScanLexer lexer = manager.Source.Scanner.GetLexer();
 			if (lexer == null)
 				return;
-			Project.HandleIdleTime(lexer, filePath, line + 1, column + 1);
+			Project.HighlightUsages(lexer, filePath, line + 1, column + 1);
 			manager.Source.Recolorize(1, source.LineCount);
-			Trace.WriteLine("<<<< ##### HandleIdleTime!");
+			Trace.WriteLine("<<<< ##### HighlightUsages!");
 		}
 	}
 }

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.Designer.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.Designer.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.Designer.cs	Tue Mar 27 15:37:15 2007
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.308
+//     Runtime Version:2.0.50727.312
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -34,5 +34,29 @@
                 this["AutoShowAst"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]
+        public bool HighlightUsages {
+            get {
+                return ((bool)(this["HighlightUsages"]));
+            }
+            set {
+                this["HighlightUsages"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]
+        public bool HighlightUsagesUnlessTerminalSession {
+            get {
+                return ((bool)(this["HighlightUsagesUnlessTerminalSession"]));
+            }
+            set {
+                this["HighlightUsagesUnlessTerminalSession"] = value;
+            }
+        }
     }
 }

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.settings
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.settings	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.settings	Tue Mar 27 15:37:15 2007
@@ -5,5 +5,11 @@
     <Setting Name="AutoShowAst" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">True</Value>
     </Setting>
+    <Setting Name="HighlightUsages" Type="System.Boolean" Scope="User">
+      <Value Profile="(Default)">True</Value>
+    </Setting>
+    <Setting Name="HighlightUsagesUnlessTerminalSession" Type="System.Boolean" Scope="User">
+      <Value Profile="(Default)">False</Value>
+    </Setting>
   </Settings>
 </SettingsFile>
\ No newline at end of file

Modified: vs-plugin/trunk/Nemerle.VsIntegration/app.config
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/app.config	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/app.config	Tue Mar 27 15:37:15 2007
@@ -10,6 +10,12 @@
             <setting name="AutoShowAst" serializeAs="String">
                 <value>True</value>
             </setting>
+            <setting name="HighlightUsages" serializeAs="String">
+                <value>True</value>
+            </setting>
+            <setting name="HighlightUsagesUnlessTerminalSession" serializeAs="String">
+                <value>False</value>
+            </setting>
         </Nemerle.VisualStudio.Properties.Settings>
     </userSettings>
 </configuration>
\ No newline at end of file



More information about the svn mailing list