[svn] r7192: vs-plugin/trunk:
Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
Nemerle.Compiler.Utils/...
VladD2
svnadmin at nemerle.org
Tue Jan 2 02:49:15 CET 2007
Log:
Work on AstToolWindow.
Author: VladD2
Date: Tue Jan 2 02:49:11 2007
New Revision: 7192
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstNodeInfo.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n
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.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj
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/Nemerle.VisualStudio.csproj
vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Tue Jan 2 02:49:11 2007
@@ -182,6 +182,12 @@
<ItemGroup>
<Compile Include="FormCodeInfo.n" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\Debug\AstNodeInfo.n" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\Debug\AstUtils.n" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.nproj Tue Jan 2 02:49:11 2007
@@ -6,6 +6,7 @@
<ItemGroup>
<Folder Include="Nemerle.Completion2\" />
<Folder Include="Nemerle.Completion2\CodeModel\" />
+ <Folder Include="Nemerle.Completion2\Debug\" />
<Folder Include="Nemerle.Completion2\Engine\" />
<Folder Include="Nemerle.Completion2\Tests\" />
<Folder Include="Nemerle.Completion2\Tests\Content\" />
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstNodeInfo.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstNodeInfo.n Tue Jan 2 02:49:11 2007
@@ -0,0 +1,17 @@
+using Nemerle.Compiler;
+using Nemerle.Utility;
+
+namespace Nemerle.Compiler.Utils
+{
+ [Record]
+ public class AstNodeInfo
+ {
+ public Text : string;
+ public Location : Location;
+
+ public override ToString() : string
+ {
+ $"$Text\n$(this.Location)"
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Debug/AstUtils.n Tue Jan 2 02:49:11 2007
@@ -0,0 +1,96 @@
+using System.Diagnostics;
+using System.Reflection;
+using Nemerle.Assertions;
+using Nemerle.Compiler;
+using Nemerle.Completion2;
+using Nemerle.Utility;
+using Nemerle.Compiler.Parsetree;
+//using Nemerle.Compiler.Typedtree;
+using TExpr = Nemerle.Compiler.Typedtree.TExpr;
+using SCG = System.Collections.Generic;
+using System.Collections.ArrayList;
+
+namespace Nemerle.Compiler.Utils
+{
+ public module AstUtils
+ {
+ public FillList(rootNamespase : Decl.Namespace, items : SCG.List[AstNodeInfo]) : void
+ {
+ items.Clear();
+
+ def scan(node : Decl, indent)
+ {
+ match (node)
+ {
+ | Using as us => items.Add(AstNodeInfo($"$(indent)$us", us.Location));
+ | Namespace as n => //(Name, NameLocations, Alias, AliasLocation)
+ def name = n.Name.ToString(".");
+ items.Add(AstNodeInfo($"$(indent)ns $name", n.Location));
+ unless (n.NameLocations.IsEmpty)
+ items.Add(AstNodeInfo($"$(indent)ns name: $name", n.NameLocations.EnclosingLocation()));
+ items.Add(AstNodeInfo($"$(indent){", n.Location.FromStart()));
+
+ foreach (subNode in n.Decls)
+ scan(subNode, indent + " ");
+
+ items.Add(AstNodeInfo($"$(indent)} // ns $name", n.Location.FromEnd()));
+
+ | Type(tb) =>
+ def scanType(tb : TypeBuilder, indent)
+ {
+ def name = tb.Name;
+ def fileIndex = rootNamespase.Location.FileIndex;
+ items.Add(AstNodeInfo($"$(indent)type $name", tb.Location));
+
+ def scanMethod(method : MemberBuilder, indent)
+ {
+ def name = method.Name;
+ items.Add(AstNodeInfo($"$(indent)method $name(...)", method.Location));
+ items.Add(AstNodeInfo($"$(indent){", method.BodyLocation.FromStart()));
+ items.Add(AstNodeInfo($"$(indent)} // method $name", method.BodyLocation.FromEnd()));
+ }
+ def scanField(field : FieldBuilder, indent)
+ {
+ ignore(field);
+ ignore(indent);
+ }
+ def scanProp(prop : PropertyBuilder, indent)
+ {
+ ignore(prop);
+ ignore(indent);
+ }
+
+ items.Add(AstNodeInfo($"$(indent)type name $name", tb.Location));
+ match (tb.PartsLocation.Find(x => x.FileIndex == fileIndex))
+ {
+ | Some(loc) =>
+ items.Add(AstNodeInfo($"$(indent){", loc.FromStart()));
+ foreach (subTb in tb.GetNestedTypes())
+ scanType(subTb :> TypeBuilder, indent + " ");
+ //
+ def mems = tb.GetDirectMembers(); //GetMembers(BindingFlags.NonPublic | BindingFlags.DeclaredOnly | BindingFlags.Public);
+ foreach (mem is MemberBuilder when mem.Location.FileIndex == fileIndex in mems)
+ match (mem)
+ {
+ | method is MethodBuilder => scanMethod(method, indent + " ");
+ | field is FieldBuilder => scanField(field, indent + " ");
+ | prop is PropertyBuilder => scanProp(prop, indent + " ");
+ | _ => ()
+ }
+
+ items.Add(AstNodeInfo($"$(indent)} // type $name", loc.FromEnd()));
+
+ | _ => ()
+ }
+ }
+
+ scanType(tb, indent);
+
+ | _ => ()
+ }
+ }
+
+ scan(rootNamespase, "");
+ }
+ }
+}
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 Tue Jan 2 02:49:11 2007
@@ -18,26 +18,6 @@
{
InvariantCultureCompareInfo : CompareInfo = CultureInfo.InvariantCulture.CompareInfo;
- public FillList(rootNamespase : Decl.Namespace, items : SCG.List[string * Location]) : void
- {
- //def cnt = items.Count;
- items.Clear();
-
- items.Add(("{BOF", rootNamespase.Location.FromStart()));
- items.Add(("EOF}", rootNamespase.Location.FromEnd()));
-
-
-
- //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
{
@@ -384,6 +364,15 @@
(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]
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 Tue Jan 2 02:49:11 2007
@@ -36,12 +36,14 @@
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.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit();
this.SuspendLayout();
//
// panel1
//
+ this.panel1.Controls.Add(this._checkCountLabel);
this.panel1.Controls.Add(this._col);
this.panel1.Controls.Add(this._line);
this.panel1.Controls.Add(this._autoUpdateCheckBox);
@@ -80,6 +82,7 @@
this._autoUpdateCheckBox.TabIndex = 0;
this._autoUpdateCheckBox.Text = "Auto update";
this._autoUpdateCheckBox.UseVisualStyleBackColor = true;
+ this._autoUpdateCheckBox.CheckedChanged += new System.EventHandler(this._autoUpdateCheckBox_CheckedChanged);
//
// _grid
//
@@ -107,6 +110,16 @@
this._astColumn.ReadOnly = true;
this._astColumn.Width = 53;
//
+ // _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");
+ //
// AstToolControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -131,5 +144,6 @@
private System.Windows.Forms.Label _col;
private System.Windows.Forms.Label _line;
private System.Windows.Forms.ToolTip _toolTip;
+ private System.Windows.Forms.Label _checkCountLabel;
}
}
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 Tue Jan 2 02:49:11 2007
@@ -9,6 +9,8 @@
using CompUtils = Nemerle.Compiler.Utils.Utils;
using Nemerle.Compiler;
using Nemerle.Builtins;
+using Nemerle.Compiler.Utils;
+using Nemerle.VisualStudio.Properties;
namespace Nemerle.VisualStudio.GUI
{
@@ -17,20 +19,26 @@
public AstToolControl()
{
InitializeComponent();
+ _autoUpdateCheckBox.Checked = Settings.Default.AutoShowAst;
}
- List<Tuple<string, Location>> _items = new List<Tuple<string, Location>>(10000);
+ 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;
- CompUtils.FillList(_rootNamespase, _items);
+ AstUtils.FillList(_rootNamespase, _items);
_grid.RowCount = _items.Count;
+ _grid.Invalidate();
+ _grid.Update();
}
}
@@ -49,7 +57,7 @@
{
try
{
- e.Value = _items[e.RowIndex].field0;
+ e.Value = _items[e.RowIndex].Text;
}
catch { }
}
@@ -70,9 +78,14 @@
try
{
if (ShowLocation != null)
- ShowLocation(_items[e.RowIndex].field1);
+ ShowLocation(_items[e.RowIndex].Location);
}
catch { }
}
+
+ private void _autoUpdateCheckBox_CheckedChanged(object sender, EventArgs e)
+ {
+ Settings.Default.AutoShowAst = _autoUpdateCheckBox.Checked;
+ }
}
}
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 Tue Jan 2 02:49:11 2007
@@ -123,7 +123,4 @@
<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/Nemerle.VisualStudio.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VisualStudio.csproj Tue Jan 2 02:49:11 2007
@@ -273,7 +273,17 @@
<DependentUpon>AstToolControl.cs</DependentUpon>
</Compile>
<Compile Include="GUI\AstToolWindow.cs" />
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
<Compile Include="RegistrationAttributes\SingleFileGeneratorSupportRegistrationAttribute.cs" />
+ <None Include="app.config" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
<None Include="Resources\Nemerle.ico" />
<EmbeddedResource Include="GUI\AstToolControl.resx">
<SubType>Designer</SubType>
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs Tue Jan 2 02:49:11 2007
@@ -16,6 +16,7 @@
using System.Diagnostics;
using Nemerle.VisualStudio.GUI;
+using Nemerle.VisualStudio.Properties;
namespace Nemerle.VisualStudio
{
@@ -110,10 +111,21 @@
private uint _componentID;
private NemerleLibraryManager _libraryManager;
+ protected override int QueryClose(out bool canClose)
+ {
+ int res = base.QueryClose(out canClose);
+ if (canClose)
+ {
+ Settings.Default.Save();
+ }
+ return res;
+ }
+
#region Initialize
public NemerlePackage()
{
+ //Settings.Default.Reload();
IServiceContainer container = this;
container.AddService(typeof(NemerleLanguageService), CreateService, true);
Added: vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.Designer.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.Designer.cs Tue Jan 2 02:49:11 2007
@@ -0,0 +1,38 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.308
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Nemerle.VisualStudio.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool AutoShowAst {
+ get {
+ return ((bool)(this["AutoShowAst"]));
+ }
+ set {
+ this["AutoShowAst"] = value;
+ }
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.settings
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Properties/Settings.settings Tue Jan 2 02:49:11 2007
@@ -0,0 +1,9 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Nemerle.VisualStudio.Properties" GeneratedClassName="Settings">
+ <Profiles />
+ <Settings>
+ <Setting Name="AutoShowAst" Type="System.Boolean" Scope="User">
+ <Value Profile="(Default)">True</Value>
+ </Setting>
+ </Settings>
+</SettingsFile>
\ No newline at end of file
Added: vs-plugin/trunk/Nemerle.VsIntegration/app.config
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/app.config Tue Jan 2 02:49:11 2007
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
+ <section name="Nemerle.VisualStudio.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+ <userSettings>
+ <Nemerle.VisualStudio.Properties.Settings>
+ <setting name="AutoShowAst" serializeAs="String">
+ <value>True</value>
+ </setting>
+ </Nemerle.VisualStudio.Properties.Settings>
+ </userSettings>
+</configuration>
\ No newline at end of file
More information about the svn
mailing list