[svn] r6703: vs-plugin/trunk/Nemerle.VsIntegration: LanguageService/NemerleAuthoringSink.cs Nemerle.VsInte...

IT svnadmin at nemerle.org
Sun Sep 24 07:08:49 CEST 2006


Log:
C# integration project refactoring.

Author: IT
Date: Sun Sep 24 07:08:42 2006
New Revision: 6703

Added:
   vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs
Modified:
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj
   vs-plugin/trunk/Nemerle.VsIntegration/Project/Library.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/LibraryNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
   vs-plugin/trunk/Nemerle.VsIntegration/TextLineEventListener.cs

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs
==============================================================================

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj	Sun Sep 24 07:08:42 2006
@@ -71,13 +71,9 @@
   <ItemGroup>
     <Compile Include="Engine\ScopeNode.cs" />
     <Compile Include="HierarchyListener.cs" />
-    <Compile Include="Library.cs" />
-    <Compile Include="LibraryNode.cs" />
     <Compile Include="NemerleConstants.cs" />
     <Compile Include="LanguageService\NemerleDeclarations.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="NemerleLibraryManager.cs" />
-    <Compile Include="NemerleLibraryNode.cs" />
     <Compile Include="Package\NemerleMethods.cs" />
     <Compile Include="Package\NemerleViewFilter.cs" />
     <Compile Include="RegisterSnippetsAttribute.cs" />
@@ -135,6 +131,11 @@
     <Compile Include="LanguageService\NemerleSource.cs" />
     <Compile Include="NemerlePackage.cs" />
     <Compile Include="Package\Automation\NemerleOAFileItem.cs" />
+    <Compile Include="Project\INemerleLibraryManager.cs" />
+    <Compile Include="Project\Library.cs" />
+    <Compile Include="Project\LibraryNode.cs" />
+    <Compile Include="Project\NemerleLibraryManager.cs" />
+    <Compile Include="Project\NemerleLibraryNode.cs" />
     <Compile Include="Project\NemerleProjectFactory.cs" />
     <Compile Include="Project\NemerleProjectNode.cs" />
     <Compile Include="Project\NemerleProjectNodeProperties.cs" />

Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs	Sun Sep 24 07:08:42 2006
@@ -0,0 +1,21 @@
+using System;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio.Shell.Interop;
+
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+namespace Nemerle.VisualStudio.Project
+{
+	/// <summary>
+	/// This interface defines the service that finds Nemerle files inside 
+	/// a hierarchy and builds the informations to expose to the class view or 
+	/// object browser.
+	/// </summary>
+	[Guid(GlobalConstants.LibraryManagerServiceGuidString)]
+	public interface INemerleLibraryManager
+	{
+		void RegisterHierarchy  (IVsHierarchy hierarchy);
+		void UnregisterHierarchy(IVsHierarchy hierarchy);
+	}
+}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/Library.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/Library.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/Library.cs	Sun Sep 24 07:08:42 2006
@@ -1,19 +1,10 @@
-/***************************************************************************
-
-Copyright (c) Microsoft Corporation. All rights reserved.
-This code is licensed under the Visual Studio SDK license terms.
-THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-
-***************************************************************************/
 using System;
+
 using Microsoft.VisualStudio;
 using Microsoft.VisualStudio.OLE.Interop;
 using Microsoft.VisualStudio.Shell.Interop;
 
-namespace Microsoft.Samples.VisualStudio.LanguageService
+namespace Nemerle.VisualStudio.Project
 {
 	public class Library : IVsSimpleLibrary2
 	{
@@ -53,22 +44,22 @@
 
 		#region IVsSimpleLibrary2 Members
 
-		public int AddBrowseContainer(VSCOMPONENTSELECTORDATA[] pcdComponent,
-			ref uint pgrfOptions, out string pbstrComponentAdded)
+		public int AddBrowseContainer(
+			VSCOMPONENTSELECTORDATA[] pcdComponent, ref uint pgrfOptions, out string pbstrComponentAdded)
 		{
 			pbstrComponentAdded = null;
 			return VSConstants.E_NOTIMPL;
 		}
 
-		public int CreateNavInfo(SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes,
-			uint ulcNodes, out IVsNavInfo ppNavInfo)
+		public int CreateNavInfo(
+			SYMBOL_DESCRIPTION_NODE[] rgSymbolNodes, uint ulcNodes, out IVsNavInfo ppNavInfo)
 		{
 			ppNavInfo = null;
 			return VSConstants.E_NOTIMPL;
 		}
 
-		public int GetBrowseContainersForHierarchy(IVsHierarchy pHierarchy,
-			uint celt, VSBROWSECONTAINER[] rgBrowseContainers, uint[] pcActual)
+		public int GetBrowseContainersForHierarchy(
+			IVsHierarchy pHierarchy, uint celt, VSBROWSECONTAINER[] rgBrowseContainers, uint[] pcActual)
 		{
 			return VSConstants.E_NOTIMPL;
 		}
@@ -85,7 +76,9 @@
 			return VSConstants.S_OK;
 		}
 
-		public int GetList2(uint ListType, uint flags, 
+		public int GetList2(
+			uint                     ListType,
+			uint                     flags, 
 			VSOBSEARCHCRITERIA2[] pobSrch,
 			out IVsSimpleObjectList2 ppIVsSimpleObjectList2)
 		{
@@ -101,8 +94,7 @@
 
 		public int GetSupportedCategoryFields2(int Category, out uint pgrfCatField)
 		{
-			pgrfCatField = (uint)_LIB_CATEGORY2.LC_HIERARCHYTYPE
-				| (uint)_LIB_CATEGORY2.LC_PHYSICALCONTAINERTYPE;
+			pgrfCatField = (uint)_LIB_CATEGORY2.LC_HIERARCHYTYPE | (uint)_LIB_CATEGORY2.LC_PHYSICALCONTAINERTYPE;
 			return VSConstants.S_OK;
 		}
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/LibraryNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/LibraryNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/LibraryNode.cs	Sun Sep 24 07:08:42 2006
@@ -1,32 +1,21 @@
-/***************************************************************************
-
-Copyright (c) Microsoft Corporation. All rights reserved.
-This code is licensed under the Visual Studio SDK license terms.
-THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-
-***************************************************************************/
 using System;
 using System.Collections.Generic;
 using System.ComponentModel.Design;
 
 using Microsoft.VisualStudio.OLE.Interop;
-using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+
 using ErrorHandler = Microsoft.VisualStudio.ErrorHandler;
 using VSConstants = Microsoft.VisualStudio.VSConstants;
 
-namespace Microsoft.Samples.VisualStudio.LanguageService
+namespace Nemerle.VisualStudio.Project
 {
-
 	/// <summary>
 	/// Single node inside the tree of the libraries in the object browser or class view.
 	/// </summary>
-	internal class LibraryNode : IVsSimpleObjectList2, IVsNavInfoNode
+	class LibraryNode : IVsSimpleObjectList2, IVsNavInfoNode
 	{
-
 		public const uint NullIndex = (uint)0xFFFFFFFF;
 
 		/// <summary>
@@ -34,7 +23,7 @@
 		/// to support more capabilities.
 		/// This enumeration is a copy of _LIB_LISTCAPABILITIES with the Flags attribute set.
 		/// </summary>
-		[Flags()]
+		[Flags]
 		public enum LibraryNodeCapabilities
 		{
 			None = _LIB_LISTCAPABILITIES.LLC_NONE,
@@ -81,7 +70,7 @@
 		private List<LibraryNode> _children;
 		private LibraryNodeCapabilities _capabilities;
 		private List<VSOBJCLIPFORMAT> _clipboardFormats;
-		public VSTREEDISPLAYDATA _displayData;
+		private VSTREEDISPLAYDATA       _displayData;
 		private _VSTREEFLAGS _flags;
 		private CommandID _contextMenuID;
 		private string _tooltip;
@@ -90,11 +79,16 @@
 
 		public LibraryNode(string name)
 			: this(name, LibraryNodeType.None, LibraryNodeCapabilities.None, null)
-		{ }
+		{
+		}
+
 		public LibraryNode(string name, LibraryNodeType type)
 			: this(name, type, LibraryNodeCapabilities.None, null)
-		{ }
-		public LibraryNode(string name, LibraryNodeType type, LibraryNodeCapabilities capabilities, CommandID contextMenuID)
+		{
+		}
+
+		public LibraryNode(
+			string name, LibraryNodeType type, LibraryNodeCapabilities capabilities, CommandID contextMenuID)
 		{
 			_capabilities = capabilities;
 			_contextMenuID = contextMenuID;
@@ -105,6 +99,7 @@
 			_clipboardFormats = new List<VSOBJCLIPFORMAT>();
 			_filteredView = new Dictionary<LibraryNodeType, LibraryNode>();
 		}
+
 		public LibraryNode(LibraryNode node)
 		{
 			_capabilities = node._capabilities;
@@ -114,10 +109,10 @@
 			_tooltip = node._tooltip;
 			_type = node._type;
 			_children = new List<LibraryNode>();
+
 			foreach (LibraryNode child in node._children)
 				_children.Add(child);
 
-
 			_clipboardFormats = new List<VSOBJCLIPFORMAT>();
 
 			foreach (VSOBJCLIPFORMAT format in node._clipboardFormats)
@@ -129,10 +124,8 @@
 
 		protected void SetCapabilityFlag(LibraryNodeCapabilities flag, bool value)
 		{
-			if (value)
-				_capabilities |= flag;
-			else
-				_capabilities &= ~flag;
+			if (value) _capabilities |= flag;
+			else       _capabilities &= ~flag;
 		}
 
 		/// <summary>
@@ -140,10 +133,7 @@
 		/// </summary>
 		public bool CanDelete
 		{
-			get
-			{
-				 return (0 != (_capabilities & LibraryNodeCapabilities.AllowDelete));
-			}
+			get { return (_capabilities & LibraryNodeCapabilities.AllowDelete) != 0; }
 			set { SetCapabilityFlag(LibraryNodeCapabilities.AllowDelete, value); }
 		}
 
@@ -152,10 +142,7 @@
 		/// </summary>
 		public bool CanGoToSource
 		{
-			get
-			{
-				 return 0 != (_capabilities & LibraryNodeCapabilities.HasSourceContext);
-			}
+			get { return (_capabilities & LibraryNodeCapabilities.HasSourceContext) != 0; }
 			set { SetCapabilityFlag(LibraryNodeCapabilities.HasSourceContext, value); }
 		}
 
@@ -164,7 +151,7 @@
 		/// </summary>
 		public bool CanRename
 		{
-			get { return (0 != (_capabilities & LibraryNodeCapabilities.AllowRename)); }
+			get { return (_capabilities & LibraryNodeCapabilities.AllowRename) != 0; }
 			set { SetCapabilityFlag(LibraryNodeCapabilities.AllowRename, value); }
 		}
 
@@ -192,15 +179,18 @@
 			{
 				_children.Add(node);
 			}
-			_updateCount += 1;
+
+			_updateCount++;
 		}
+
 		internal void RemoveNode(LibraryNode node)
 		{
 			lock (_children)
 			{
 				_children.Remove(node);
 			}
-			_updateCount += 1;
+
+			_updateCount++;
 		}
 
 		protected virtual object BrowseObject
@@ -210,27 +200,22 @@
 
 		protected virtual uint CategoryField(LIB_CATEGORY category)
 		{
-			uint fieldValue;
-			
 			switch (category)
 			{
 				case LIB_CATEGORY.LC_LISTTYPE:
-					{
 						LibraryNodeType subTypes = LibraryNodeType.None;
+
 						foreach (LibraryNode node in _children)
-						{
 							subTypes |= node._type;
-						}
-						fieldValue = (uint)subTypes;
-					}
-					break;
+
+					return (uint)subTypes;
+
 				case (LIB_CATEGORY)_LIB_CATEGORY2.LC_HIERARCHYTYPE:
-					fieldValue = (uint)_LIBCAT_HIERARCHYTYPE.LCHT_UNKNOWN;
-					break;
+					return (uint)_LIBCAT_HIERARCHYTYPE.LCHT_UNKNOWN;
+
 				default:
 					throw new NotImplementedException();
 			}
-			return fieldValue;
 		}
 
 		protected virtual LibraryNode Clone()
@@ -255,15 +240,15 @@
 		protected virtual uint EnumClipboardFormats(_VSOBJCFFLAGS flags, VSOBJCLIPFORMAT[] formats)
 		{
 			if ((null == formats) || (formats.Length == 0))
-			{
 				return (uint)_clipboardFormats.Count;
-			}
+
 			uint itemsToCopy = (uint)_clipboardFormats.Count;
+
 			if (itemsToCopy > (uint)formats.Length)
-			{
 				itemsToCopy = (uint)formats.Length;
-			}
+
 			Array.Copy(_clipboardFormats.ToArray(), formats, (int)itemsToCopy);
+
 			return itemsToCopy;
 		}
 
@@ -276,10 +261,12 @@
 		protected IVsSimpleObjectList2 FilterView(LibraryNodeType filterType)
 		{
 			LibraryNode filtered;
+
 			if (_filteredView.TryGetValue(filterType, out filtered))
 				return filtered;
 
 			filtered = Clone();
+
 			for (int i = 0; i < filtered._children.Count; )
 			{
 				if (0 == (filtered._children[i]._type & filterType))
@@ -289,6 +276,7 @@
 			}
 			
 			_filteredView.Add(filterType, filtered);
+
 			return filtered;
 		}
 
@@ -315,8 +303,7 @@
 		/// <param name="hierarchy">The hierarchy containing the items.</param>
 		/// <param name="itemId">The item id of the item.</param>
 		/// <param name="itemsCount">Number of items.</param>
-		protected virtual void SourceItems(out IVsHierarchy hierarchy,
-			out uint itemId, out uint itemsCount)
+		protected virtual void SourceItems(out IVsHierarchy hierarchy, out uint itemId, out uint itemsCount)
 		{
 			hierarchy = null;
 			itemId = 0;
@@ -338,9 +325,8 @@
 		int IVsSimpleObjectList2.CanDelete(uint index, out int pfOK)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			pfOK = _children[(int)index].CanDelete ? 1 : 0;
 			return VSConstants.S_OK;
 		}
@@ -348,9 +334,8 @@
 		int IVsSimpleObjectList2.CanGoToSource(uint index, VSOBJGOTOSRCTYPE SrcType, out int pfOK)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			pfOK = _children[(int)index].CanGoToSource ? 1 : 0;
 			return VSConstants.S_OK;
 		}
@@ -358,9 +343,8 @@
 		int IVsSimpleObjectList2.CanRename(uint index, string pszNewName, out int pfOK)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			pfOK = _children[(int)index].CanRename ? 1 : 0;
 			return VSConstants.S_OK;
 		}
@@ -368,9 +352,8 @@
 		int IVsSimpleObjectList2.CountSourceItems(uint index, out IVsHierarchy ppHier, out uint pItemid, out uint pcItems)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			_children[(int)index].SourceItems(out ppHier, out pItemid, out pcItems);
 			return VSConstants.S_OK;
 		}
@@ -378,31 +361,31 @@
 		int IVsSimpleObjectList2.DoDelete(uint index, uint grfFlags)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			_children[(int)index].Delete();
 			_children.RemoveAt((int)index);
+
 			return VSConstants.S_OK;
 		}
 
 		int IVsSimpleObjectList2.DoDragDrop(uint index, IDataObject pDataObject, uint grfKeyState, ref uint pdwEffect)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			OleDataObject dataObject = new OleDataObject(pDataObject);
+
 			_children[(int)index].DoDragDrop(dataObject, grfKeyState, pdwEffect);
+
 			return VSConstants.S_OK;
 		}
 
 		int IVsSimpleObjectList2.DoRename(uint index, string pszNewName, uint grfFlags)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			_children[(int)index].Rename(pszNewName, grfFlags);
 			return VSConstants.S_OK;
 		}
@@ -410,23 +393,21 @@
 		int IVsSimpleObjectList2.EnumClipboardFormats(uint index, uint grfFlags, uint celt, VSOBJCLIPFORMAT[] rgcfFormats, uint[] pcActual)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			uint copied = _children[(int)index].EnumClipboardFormats((_VSOBJCFFLAGS)grfFlags, rgcfFormats);
+
 			if ((null != pcActual) && (pcActual.Length > 0))
-			{
 				pcActual[0] = copied;
-			}
+
 			return VSConstants.S_OK;
 		}
 
 		int IVsSimpleObjectList2.FillDescription2(uint index, uint grfOptions, IVsObjectBrowserDescription3 pobDesc)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			_children[(int)index].FillDescription((_VSOBJDESCOPTIONS)grfOptions, pobDesc);
 			return VSConstants.S_OK;
 		}
@@ -434,14 +415,13 @@
 		int IVsSimpleObjectList2.GetBrowseObject(uint index, out object ppdispBrowseObj)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			ppdispBrowseObj = _children[(int)index].BrowseObject;
+
 			if (null == ppdispBrowseObj)
-			{
 				return VSConstants.E_NOTIMPL;
-			}
+
 			return VSConstants.S_OK;
 		}
 
@@ -454,6 +434,7 @@
 		int IVsSimpleObjectList2.GetCategoryField2(uint index, int Category, out uint pfCatField)
 		{
 			LibraryNode node;
+
 			if (NullIndex == index)
 			{
 				node = this;
@@ -466,6 +447,7 @@
 			{
 				throw new ArgumentOutOfRangeException("index");
 			}
+
 			pfCatField = node.CategoryField((LIB_CATEGORY)Category);
 			return VSConstants.S_OK;
 		}
@@ -478,29 +460,31 @@
 		int IVsSimpleObjectList2.GetContextMenu(uint index, out Guid pclsidActive, out int pnMenuId, out IOleCommandTarget ppCmdTrgtActive)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			CommandID commandId = _children[(int)index]._contextMenuID;
-			if (null == commandId)
+
+			if (commandId == null)
 			{
 				pclsidActive = Guid.Empty;
 				pnMenuId = 0;
 				ppCmdTrgtActive = null;
+
 				return VSConstants.E_NOTIMPL;
 			}
+
 			pclsidActive = commandId.Guid;
 			pnMenuId = commandId.ID;
 			ppCmdTrgtActive = _children[(int)index] as IOleCommandTarget;
+
 			return VSConstants.S_OK;
 		}
 
 		int IVsSimpleObjectList2.GetDisplayData(uint index, VSTREEDISPLAYDATA[] pData)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			pData[0] = _children[(int)index]._displayData;
 			return VSConstants.S_OK;
 		}
@@ -535,9 +519,8 @@
 		{
 			// TODO: Use the flags and list type to actually filter the result.
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			ppIVsSimpleObjectList2 = _children[(int)index].FilterView((LibraryNodeType)ListType);
 			return VSConstants.S_OK;
 		}
@@ -556,9 +539,8 @@
 		int IVsSimpleObjectList2.GetNavInfoNode(uint index, out IVsNavInfoNode ppNavInfoNode)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			ppNavInfoNode = _children[(int)index] as IVsNavInfoNode;
 			return VSConstants.S_OK;
 		}
@@ -580,9 +562,8 @@
 		{
 			// TODO: make use of the text option.
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			pbstrText = _children[(int)index]._name;
 			return VSConstants.S_OK;
 		}
@@ -591,9 +572,8 @@
 		{
 			// TODO: Make use of the tooltip type.
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			pbstrText = _children[(int)index].TooltipText;
 			return VSConstants.S_OK;
 		}
@@ -607,9 +587,8 @@
 		int IVsSimpleObjectList2.GoToSource(uint index, VSOBJGOTOSRCTYPE SrcType)
 		{
 			if (index >= (uint)_children.Count)
-			{
 				throw new ArgumentOutOfRangeException("index");
-			}
+
 			_children[(int)index].GotoSource(SrcType);
 			return VSConstants.S_OK;
 		}
@@ -617,12 +596,14 @@
 		int IVsSimpleObjectList2.LocateNavInfoNode(IVsNavInfoNode pNavInfoNode, out uint pulIndex)
 		{
 			if (null == pNavInfoNode)
-			{
 				throw new ArgumentNullException("pNavInfoNode");
-			}
+
 			pulIndex = NullIndex;
+
 			string nodeName;
+
 			ErrorHandler.ThrowOnFailure(pNavInfoNode.get_Name(out nodeName));
+
 			for (int i = 0; i < _children.Count; i++)
 			{
 				if (0 == string.Compare(_children[i].UniqueName, nodeName, StringComparison.OrdinalIgnoreCase))
@@ -631,6 +612,7 @@
 					return VSConstants.S_OK;
 				}
 			}
+
 			return VSConstants.S_FALSE;
 		}
 

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs	Sun Sep 24 07:08:42 2006
@@ -12,7 +12,6 @@
 using Microsoft.VisualStudio.Shell.Interop;
 
 using Microsoft.Samples.VisualStudio.LanguageService;
-
 using Nemerle.VisualStudio.Package.Automation;
 using Nemerle.VsIntegration.Project;
 using Nemerle.VisualStudio.Package;

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs	Sun Sep 24 07:08:42 2006
@@ -1,83 +1,58 @@
-/***************************************************************************
-
-Copyright (c) Microsoft Corporation. All rights reserved.
-This code is licensed under the Visual Studio SDK license terms.
-THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-
-***************************************************************************/
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
 using System.Runtime.InteropServices;
 using System.Threading;
+
 using Microsoft.Samples.VisualStudio.NemerleInference;
 using Microsoft.VisualStudio;
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.TextManager.Interop;
 
-namespace Microsoft.Samples.VisualStudio.LanguageService
-{
-	/// <summary>
-	/// This interface defines the service that finds Nemerle files inside 
-	/// a hierarchy and builds the informations to expose to the class view or 
-	/// object browser.
-	/// </summary>
-	[Guid(GlobalConstants.LibraryManagerServiceGuidString)]
-	public interface INemerleLibraryManager
-	{
-		void RegisterHierarchy(IVsHierarchy hierarchy);
-		void UnregisterHierarchy(IVsHierarchy hierarchy);
-	}
+using Microsoft.Samples.VisualStudio.LanguageService;
 
+namespace Nemerle.VisualStudio.Project
+{
 	/// <summary>
 	/// Inplementation of the service that build the information to expose to the symbols
 	/// navigation tools (class view or object browser) from the Nemerle files 
 	/// inside a hierarchy.
 	/// </summary>
 	[Guid(GlobalConstants.LibraryManagerGuidString)]
-	internal class NemerleLibraryManager : INemerleLibraryManager,
-		IVsRunningDocTableEvents, IDisposable
+	internal class NemerleLibraryManager : INemerleLibraryManager, IVsRunningDocTableEvents, IDisposable
 	{
 		/// <summary>
 		/// Class storing the data about a parsing task on a nemerle module.
 		/// A module in Nemerle is a source file, so here we use the file name to
 		/// identify it.
 		/// </summary>
+		[DebuggerStepThrough] 
 		class LibraryTask
 		{
-			string fileName;
-			string text;
-			ModuleId moduleId;
-
-			[DebuggerStepThrough]
 			public LibraryTask(string fileName, string text)
 			{
-				this.fileName = fileName;
-				this.text = text;
+				_fileName = fileName;
+				_text     = text;
 			}
 
+			private string _fileName;
 			public string FileName
 			{
-				[DebuggerStepThrough]
-				get { return fileName; }
+				get { return _fileName; }
 			}
 
-			public ModuleId ModuleID
+			private ModuleID _moduleID;
+			public  ModuleID  ModuleID
 			{
-				[DebuggerStepThrough]
-				get { return moduleId; }
-				[DebuggerStepThrough]
-				set { moduleId = value; }
+				get { return _moduleID;  }
+				set { _moduleID = value; }
 			}
 
+			private string _text;
 			public string Text
 			{
-				[DebuggerStepThrough]
-				get { return text; }
+				get { return _text; }
 			}
 		}
 
@@ -85,78 +60,81 @@
 		/// Class used to identify a module. The module is identify using the
 		/// hierarchy that contains it and its item id inside the hierarchy.
 		/// </summary>
-		internal sealed class ModuleId
-		{
-			IVsHierarchy _ownerHierarchy;
-			uint itemId;
-
 			[DebuggerStepThrough]
-			public ModuleId(IVsHierarchy owner, uint id)
+		internal sealed class ModuleID
+		{
+			public ModuleID(IVsHierarchy owner, uint id)
 			{
-				_ownerHierarchy = owner;
-				itemId = id;
+				_hierarchy = owner;
+				_itemID    = id;
 			}
 
+			private IVsHierarchy _hierarchy;
 			public IVsHierarchy Hierarchy
 			{
-				[DebuggerStepThrough]
-				get { return _ownerHierarchy; }
+				get { return _hierarchy; }
 			}
 
+			private uint _itemID;
 			public uint ItemID
 			{
 				[DebuggerStepThrough]
-				get { return itemId; }
+				get { return _itemID; }
 			}
 
-			[DebuggerStepThrough]
 			public override int GetHashCode()
 			{
 				int hash = 0;
-				if (null != _ownerHierarchy)
-					hash = _ownerHierarchy.GetHashCode();
-				hash = hash ^ (int)itemId;
+
+				if (null != _hierarchy)
+					hash = _hierarchy.GetHashCode();
+
+				hash = hash ^ (int)_itemID;
+
 				return hash;
 			}
 
-			[DebuggerStepThrough]
 			public override bool Equals(object obj)
 			{
-				ModuleId other = obj as ModuleId;
+				ModuleID other = obj as ModuleID;
+
 				if (null == obj)
 					return false;
 
-				if (!_ownerHierarchy.Equals(other._ownerHierarchy))
+				if (!_hierarchy.Equals(other._hierarchy))
 					return false;
 
-				return (itemId == other.itemId);
+				return _itemID == other._itemID;
 			}
 		}
 
 		IServiceProvider _provider;
 		uint _objectManagerCookie;
 		uint _runningDocTableCookie;
-		Dictionary<uint, TextLineEventListener> _documents;
-		Dictionary<IVsHierarchy, HierarchyListener> _hierarchies;
-		Dictionary<ModuleId, LibraryNode> _files;
 		Library _library;
 		Thread _parseThread;
 		ManualResetEvent _requestPresent;
 		ManualResetEvent _shutDownStarted;
 		Queue<LibraryTask> _requests;
 
+		Dictionary<uint, TextLineEventListener>     _documents;
+		Dictionary<IVsHierarchy, HierarchyListener> _hierarchies;
+		Dictionary<ModuleID, LibraryNode>           _files;
+
 		public NemerleLibraryManager(IServiceProvider provider)
 		{
+			_provider        = provider;
 			_documents = new Dictionary<uint, TextLineEventListener>();
 			_hierarchies = new Dictionary<IVsHierarchy, HierarchyListener>();
-			_library = new Library(new Guid(GlobalConstants.LibraryGuidString));
-			_library.LibraryCapabilities = (_LIB_FLAGS2)_LIB_FLAGS.LF_PROJECT;
-			_files = new Dictionary<ModuleId, LibraryNode>();
-			_provider = provider;
+			_files           = new Dictionary<ModuleID, LibraryNode>();
 			_requests = new Queue<LibraryTask>();
 			_requestPresent = new ManualResetEvent(false);
 			_shutDownStarted = new ManualResetEvent(false);
 			_parseThread = new Thread(new ThreadStart(ParseThread));
+
+			_library         = new Library(new Guid(GlobalConstants.LibraryGuidString));
+			_library.LibraryCapabilities = (_LIB_FLAGS2)_LIB_FLAGS.LF_PROJECT;
+
 			_parseThread.Start();
 		}
 
@@ -164,9 +142,10 @@
 		{
 			if (0 != _runningDocTableCookie)
 				return;
+
 			IVsRunningDocumentTable rdt =
-				_provider.GetService(typeof (SVsRunningDocumentTable)) as
-					IVsRunningDocumentTable;
+				_provider.GetService(typeof (SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+
 			if (null != rdt)
 				// Do not throw here in case of error, simply skip the registration.
 				rdt.AdviseRunningDocTableEvents(this, out _runningDocTableCookie);
@@ -176,12 +155,14 @@
 		{
 			if (0 == _runningDocTableCookie)
 				return;
+
 			IVsRunningDocumentTable rdt =
-				_provider.GetService(typeof (SVsRunningDocumentTable)) as
-					IVsRunningDocumentTable;
+				_provider.GetService(typeof (SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+
 			if (null != rdt)
 				// Do not throw in case of error.
 				rdt.UnadviseRunningDocTableEvents(_runningDocTableCookie);
+
 			_runningDocTableCookie = 0;
 		}
 
@@ -190,46 +171,58 @@
 		public void Dispose()
 		{
 			// Make sure that the parse thread can exit.
+			//
 			if (null != _shutDownStarted)
 				_shutDownStarted.Set();
+
 			if ((null != _parseThread) && _parseThread.IsAlive)
 			{
 				_parseThread.Join(500);
+
 				if (_parseThread.IsAlive)
 					_parseThread.Abort();
+
 				_parseThread = null;
 			}
 
 			_requests.Clear();
 
 			// Dispose all the listeners.
+			//
 			foreach (HierarchyListener listener in _hierarchies.Values)
 				listener.Dispose();
+
 			_hierarchies.Clear();
 
 			foreach (TextLineEventListener textListener in _documents.Values)
 				textListener.Dispose();
+
 			_documents.Clear();
 
 			// Remove this library from the object manager.
+			//
 			if (0 != _objectManagerCookie)
 			{
-				IVsObjectManager2 mgr =
-					_provider.GetService(typeof (SVsObjectManager)) as IVsObjectManager2;
+				IVsObjectManager2 mgr = _provider.GetService(typeof (SVsObjectManager)) as IVsObjectManager2;
+
 				if (null != mgr)
 					mgr.UnregisterLibrary(_objectManagerCookie);
+
 				_objectManagerCookie = 0;
 			}
 
 			// Unregister this object from the RDT events.
+			//
 			UnregisterRDTEvents();
 
 			// Dispose the events used to syncronize the threads.
+			//
 			if (null != _requestPresent)
 			{
 				_requestPresent.Close();
 				_requestPresent = null;
 			}
+
 			if (null != _shutDownStarted)
 			{
 				_shutDownStarted.Close();
@@ -259,8 +252,10 @@
 			}
 
 			HierarchyListener listener = new HierarchyListener(hierarchy);
+
 			listener.ItemAdded += OnNewFile;
 			listener.ItemDeleted += OnDeleteFile;
+
 			listener.StartListening(true);
 
 			_hierarchies.Add(hierarchy, listener);
@@ -271,29 +266,43 @@
 		{
 			if ((null == hierarchy) || !_hierarchies.ContainsKey(hierarchy))
 				return;
+
 			HierarchyListener listener = _hierarchies[hierarchy];
+
 			if (null != listener)
 				listener.Dispose();
+
 			_hierarchies.Remove(hierarchy);
+
 			if (0 == _hierarchies.Count)
 				UnregisterRDTEvents();
+
 			lock (_files)
 			{
-				ModuleId[] keys = new ModuleId[_files.Keys.Count];
+				ModuleID[] keys = new ModuleID[_files.Keys.Count];
+
 				_files.Keys.CopyTo(keys, 0);
-				foreach (ModuleId id in keys)
+
+				foreach (ModuleID id in keys)
+				{
 					if (hierarchy.Equals(id.Hierarchy))
 					{
 						_library.RemoveNode(_files[id]);
 						_files.Remove(id);
 					}
 			}
+			}
+
 			// Remove the document listeners.
+			//
 			uint[] docKeys = new uint[_documents.Keys.Count];
+
 			_documents.Keys.CopyTo(docKeys, 0);
+
 			foreach (uint id in docKeys)
 			{
 				TextLineEventListener docListener = _documents[id];
+
 				if (hierarchy.Equals(docListener.FileID.Hierarchy))
 				{
 					_documents.Remove(id);
@@ -316,13 +325,17 @@
 		void ParseThread()
 		{
 			const int waitTimeout = 500;
+
 			// Define the array of events this function is interest in.
-			WaitHandle[] eventsToWait =
-				new WaitHandle[] { _requestPresent, _shutDownStarted };
+			//
+			WaitHandle[] eventsToWait = new WaitHandle[] { _requestPresent, _shutDownStarted };
+
 			// Execute the tasks.
+			//
 			while (true)
 			{
 				// Wait for a task or a shutdown request.
+				//
 				int waitResult = WaitHandle.WaitAny(eventsToWait, waitTimeout, false);
 
 				if (1 == waitResult)
@@ -344,32 +357,28 @@
 					continue;
 
 				ScopeNode scope = null;
-				if (null == task.Text)
+
+				if (task.Text == null)
 				{
 					if (File.Exists(task.FileName))
 					{
-						//scope = ScopeWalker.GetScopesFromFile(task.FileName);
-						Debug.WriteLine("Parse request (no text): " + task.FileName + " "
-							+ task.ModuleID);
+						Debug.WriteLine("Parse request (no text): " + task.FileName + " " + task.ModuleID);
 						return;
-						//throw new NotImplementedException();
 					}
 				}
 				else
 				{
-					Debug.WriteLine("Parse request: " + task.FileName + " "
-						+ task.ModuleID);
+					Debug.WriteLine("Parse request: " + task.FileName + " " + task.ModuleID);
 					return;
-					//scope = ScopeWalker.GetScopesFromText(task.Text);
-					//throw new NotImplementedException();
 				}
 
-				LibraryNode module =
-					new LibraryNode(Path.GetFileName(task.FileName),
+				LibraryNode module = new LibraryNode(
+					Path.GetFileName(task.FileName),
 						LibraryNode.LibraryNodeType.PhysicalContainer);
+
 				CreateModuleTree(module, module, scope, "", task.ModuleID);
 
-				if (null != task.ModuleID)
+				if (task.ModuleID != null)
 				{
 					LibraryNode previousItem;
 
@@ -382,48 +391,57 @@
 
 				_library.AddNode(module);
 
-				if (null != task.ModuleID)
+				if (task.ModuleID != null)
 					lock (_files)
 						_files.Add(task.ModuleID, module);
 			}
 		}
 
-		void CreateModuleTree(LibraryNode root, LibraryNode current, ScopeNode scope,
-			string namePrefix, ModuleId moduleId)
+		void CreateModuleTree(
+			LibraryNode root,
+			LibraryNode current,
+			ScopeNode   scope,
+			string      namePrefix,
+			ModuleID    moduleId)
 		{
 			if ((null == root) || (null == scope) || (null == scope.NestedScopes))
 				return;
+
 			foreach (ScopeNode subItem in scope.NestedScopes)
 			{
-				NemerleLibraryNode newNode =
-					new NemerleLibraryNode(subItem, namePrefix, moduleId.Hierarchy,
-						moduleId.ItemID);
+				NemerleLibraryNode newNode = new NemerleLibraryNode(
+					subItem, namePrefix, moduleId.Hierarchy, moduleId.ItemID);
+
 				string newNamePrefix = namePrefix;
 
-				// The classes are always added to the root node, the functions to the
-				// current node.
-				if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members)
-					!= LibraryNode.LibraryNodeType.None)
+				// The classes are always added to the root node, the functions to the current node.
+				//
+				if ((newNode.NodeType & LibraryNode.LibraryNodeType.Members) != LibraryNode.LibraryNodeType.None)
+				{
 					current.AddNode(newNode);
-				else if ((newNode.NodeType & LibraryNode.LibraryNodeType.Classes)
-					!= LibraryNode.LibraryNodeType.None)
+				}
+				else if ((newNode.NodeType & LibraryNode.LibraryNodeType.Classes) != LibraryNode.LibraryNodeType.None)
 				{
 					// Classes are always added to the root.
+					//
 					root.AddNode(newNode);
 					newNamePrefix = newNode.Name + ".";
 				}
 
 				// Now use recursion to get the other types.
+				//
 				CreateModuleTree(root, newNode, subItem, newNamePrefix, moduleId);
 			}
 		}
 
 		#endregion
 
-		void CreateParseRequest(string file, string text, ModuleId id)
+		void CreateParseRequest(string file, string text, ModuleID id)
 		{
 			LibraryTask task = new LibraryTask(file, text);
+
 			task.ModuleID = id;
+
 			lock (_requests)
 				_requests.Enqueue(task);
 
@@ -435,6 +453,7 @@
 		void OnNewFile(object sender, HierarchyEventArgs args)
 		{
 			IVsHierarchy hierarchy = sender as IVsHierarchy;
+
 			if (null == hierarchy)
 				return;
 
@@ -445,26 +464,29 @@
 				int lastLine;
 				int lastIndex;
 				int hr = args.TextBuffer.GetLastLineIndex(out lastLine, out lastIndex);
+
 				if (ErrorHandler.Failed(hr))
 					return;
 
-				hr = args.TextBuffer.GetLineText(0, 0, lastLine, lastIndex, 
-					out fileText);
+				hr = args.TextBuffer.GetLineText(0, 0, lastLine, lastIndex, out fileText);
+
 				if (ErrorHandler.Failed(hr))
 					return;
 			}
 
-			CreateParseRequest(args.FileName, fileText,
-				new ModuleId(hierarchy, args.ItemID));
+			CreateParseRequest(args.FileName, fileText, new ModuleID(hierarchy, args.ItemID));
 		}
 
 		void OnDeleteFile(object sender, HierarchyEventArgs args)
 		{
 			IVsHierarchy hierarchy = sender as IVsHierarchy;
+
 			if (null == hierarchy)
 				return;
-			ModuleId id = new ModuleId(hierarchy, args.ItemID);
+
+			ModuleID    id = new ModuleID(hierarchy, args.ItemID);
 			LibraryNode node;
+
 			lock (_files)
 				if (_files.TryGetValue(id, out node))
 					_files.Remove(id);
@@ -479,23 +501,29 @@
 
 		public int OnAfterAttributeChange(uint docCookie, uint grfAttribs)
 		{
-			if ((grfAttribs & (uint)(__VSRDTATTRIB.RDTA_MkDocument))
-				== (uint)__VSRDTATTRIB.RDTA_MkDocument)
+			if ((grfAttribs & (uint)(__VSRDTATTRIB.RDTA_MkDocument)) == (uint)__VSRDTATTRIB.RDTA_MkDocument)
 			{
 				IVsRunningDocumentTable rdt =
-					_provider.GetService(typeof (SVsRunningDocumentTable)) as
-						IVsRunningDocumentTable;
+					_provider.GetService(typeof (SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+
 				if (rdt != null)
 				{
 					uint flags, readLocks, editLocks, itemid;
 					IVsHierarchy hier;
 					IntPtr docData = IntPtr.Zero;
 					string moniker;
+
 					try
 					{
-						ErrorHandler.Failed(
-							rdt.GetDocumentInfo(docCookie, out flags, out readLocks, 
-								out editLocks, out moniker, out hier, out itemid, out docData));
+						ErrorHandler.Failed(rdt.GetDocumentInfo(
+							docCookie,
+							out flags,
+							out readLocks,
+							out editLocks,
+							out moniker,
+							out hier,
+							out itemid,
+							out docData));
 
 						TextLineEventListener listner;
 
@@ -509,6 +537,7 @@
 					}
 				}
 			}
+
 			return VSConstants.S_OK;
 		}
 
@@ -517,8 +546,11 @@
 			return VSConstants.S_OK;
 		}
 
-		public int OnAfterFirstDocumentLock(uint docCookie, uint dwRDTLockType,
-			uint dwReadLocksRemaining, uint dwEditLocksRemaining)
+		public int OnAfterFirstDocumentLock(
+			uint docCookie,
+			uint dwRDTLockType,
+			uint dwReadLocksRemaining,
+			uint dwEditLocksRemaining)
 		{
 			return VSConstants.S_OK;
 		}
@@ -528,16 +560,18 @@
 			return VSConstants.S_OK;
 		}
 
-		public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow,
-			IVsWindowFrame pFrame)
+		public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
 		{
 			// Check if this document is in the list of the documents.
+			//
 			if (_documents.ContainsKey(docCookie))
 				return VSConstants.S_OK;
+
 			// Get the information about this document from the RDT.
+			//
 			IVsRunningDocumentTable rdt =
-				_provider.GetService(typeof (SVsRunningDocumentTable)) as
-					IVsRunningDocumentTable;
+				_provider.GetService(typeof (SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+
 			if (null != rdt)
 			{
 				// Note that here we don't want to throw in case of error.
@@ -548,45 +582,55 @@
 				IVsHierarchy hierarchy;
 				uint itemId;
 				IntPtr unkDocData;
-				int hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, 
-						out writeLoks, out documentMoniker, out hierarchy, out itemId,
+
+				int hr = rdt.GetDocumentInfo(
+					docCookie,
+					out flags,
+					out readLocks, 
+					out writeLoks,
+					out documentMoniker,
+					out hierarchy,
+					out itemId,
 						out unkDocData);
+
 				try
 				{
 					if (ErrorHandler.Failed(hr) || (IntPtr.Zero == unkDocData))
 						return VSConstants.S_OK;
 
-					// Check if the herarchy is one of the hierarchies this service
-					// is monitoring.
+					// Check if the herarchy is one of the hierarchies this service is monitoring.
+					//
 					if (!_hierarchies.ContainsKey(hierarchy))
 						// This hierarchy is not monitored, we can exit now.
 						return VSConstants.S_OK;
 
-
 					// Check the extension of the file to see if a listener is required.
+					//
 					string extension = Path.GetExtension(documentMoniker);
-					if (0
-						!=
-						string.Compare(extension, GlobalConstants.FileExtension,
-							StringComparison.OrdinalIgnoreCase))
+
+					if (string.Compare(extension, GlobalConstants.FileExtension, StringComparison.OrdinalIgnoreCase) != 0)
 						return VSConstants.S_OK;
 
 					// Create the module id for this document.
-					ModuleId docId = new ModuleId(hierarchy, itemId);
+					//
+					ModuleID docId = new ModuleID(hierarchy, itemId);
 
 					// Try to get the text buffer.
-					IVsTextLines buffer =
-						Marshal.GetObjectForIUnknown(unkDocData) as IVsTextLines;
+					//
+					IVsTextLines buffer = Marshal.GetObjectForIUnknown(unkDocData) as IVsTextLines;
 
 					// Create the listener.
-					TextLineEventListener listener =
-						new TextLineEventListener(buffer, documentMoniker, docId);
+					//
+					TextLineEventListener listener = new TextLineEventListener(buffer, documentMoniker, docId);
+
 					// Set the event handler for the change event. Note that there is no
 					// difference between the AddFile and FileChanged operation, so we 
 					// can use the same handler.
+					//
 					listener.OnFileChanged += OnNewFile;
-					// Add the listener to the dictionary, so we will not create it 
-					// anymore.
+
+					// Add the listener to the dictionary, so we will not create it anymore.
+					//
 					_documents.Add(docCookie, listener);
 				}
 				finally
@@ -595,26 +639,36 @@
 						Marshal.Release(unkDocData);
 				}
 			}
+
 			// Always return success.
+			//
 			return VSConstants.S_OK;
 		}
 
-		public int OnBeforeLastDocumentUnlock(uint docCookie, uint dwRDTLockType,
-			uint dwReadLocksRemaining, uint dwEditLocksRemaining)
+		public int OnBeforeLastDocumentUnlock(
+			uint docCookie,
+			uint dwRDTLockType,
+			uint dwReadLocksRemaining,
+			uint dwEditLocksRemaining)
 		{
 			if ((0 != dwEditLocksRemaining) || (0 != dwReadLocksRemaining))
 				return VSConstants.S_OK;
+
 			TextLineEventListener listener;
+
 			if (!_documents.TryGetValue(docCookie, out listener) || (null == listener))
 				return VSConstants.S_OK;
+
 			using (listener)
 			{
 				_documents.Remove(docCookie);
+
 				// Now make sure that the information about this file are up to date
 				// (e.g. it is possible that Class View shows something strange if the
 				// file was closed without saving the changes).
-				HierarchyEventArgs args =
-					new HierarchyEventArgs(listener.FileID.ItemID, listener.FileName);
+				//
+				HierarchyEventArgs args = new HierarchyEventArgs(listener.FileID.ItemID, listener.FileName);
+
 				OnNewFile(listener.FileID.Hierarchy, args);
 			}
 			return VSConstants.S_OK;

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs	Sun Sep 24 07:08:42 2006
@@ -1,24 +1,14 @@
-/***************************************************************************
-
-Copyright (c) Microsoft Corporation. All rights reserved.
-This code is licensed under the Visual Studio SDK license terms.
-THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-
-***************************************************************************/
 using System;
 using System.Globalization;
 using System.Runtime.InteropServices;
-using Microsoft.Samples.VisualStudio.NemerleInference;
+
 using Microsoft.VisualStudio;
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.TextManager.Interop;
-using Nemerle.VisualStudio.Package;
-using Nemerle.VisualStudio;
 
-namespace Microsoft.Samples.VisualStudio.LanguageService
+using Microsoft.Samples.VisualStudio.NemerleInference;
+
+namespace Nemerle.VisualStudio.Project
 {
 	/// <summary>
 	/// This is a specialized version of the LibraryNode that handles the
@@ -28,15 +18,20 @@
 	/// </summary>
 	internal class NemerleLibraryNode : LibraryNode
 	{
-		IVsHierarchy ownerHierarchy;
-		uint fileId;
-		TextSpan sourceSpan;
-		string fileMoniker;
-
-		internal NemerleLibraryNode(ScopeNode scope, string namePrefix,
-			IVsHierarchy hierarchy, uint itemId) : base(scope.Name)
+		IVsHierarchy _ownerHierarchy;
+		uint         _fileId;
+		TextSpan     _sourceSpan;
+		string       _fileMoniker;
+
+		internal NemerleLibraryNode(
+			ScopeNode    scope,
+			string       namePrefix,
+			IVsHierarchy hierarchy,
+			uint         itemId)
+			: base(scope.Name)
 		{
-			sourceSpan = new TextSpan();
+			_sourceSpan = new TextSpan();
+
 			//if (scope is FunctionNode)
 			//{
 			//  this.NodeType = LibraryNodeType.Members;
@@ -69,14 +64,15 @@
 			//    this.CanGoToSource = true;
 			//  }
 			//}
+
 			throw new NotImplementedException();
 		}
 
 		internal NemerleLibraryNode(NemerleLibraryNode node) : base(node)
 		{
-			fileId = node.fileId;
-			ownerHierarchy = node.ownerHierarchy;
-			fileMoniker = node.fileMoniker;
+			_fileId         = node._fileId;
+			_ownerHierarchy = node._ownerHierarchy;
+			_fileMoniker    = node._fileMoniker;
 		}
 
 		protected override uint CategoryField(LIB_CATEGORY category)
@@ -88,6 +84,7 @@
 						return (uint)_LIBCAT_MEMBERINHERITANCE.LCMI_IMMEDIATE;
 					break;
 			}
+
 			return base.CategoryField(category);
 		}
 
@@ -99,6 +96,7 @@
 		protected override void GotoSource(VSOBJGOTOSRCTYPE gotoType)
 		{
 			// We do not support the "Goto Reference"
+			//
 			if (VSOBJGOTOSRCTYPE.GS_REFERENCE == gotoType)
 				return;
 
@@ -107,16 +105,20 @@
 
 			IVsWindowFrame frame;
 			IntPtr documentData = FindDocDataFromRDT();
+
 			try
 			{
 				// Now we can try to open the editor. We assume that the owner hierarchy is
 				// a project and we want to use its OpenItem method.
-				IVsProject3 project = ownerHierarchy as IVsProject3;
+				//
+				IVsProject3 project = _ownerHierarchy as IVsProject3;
+
 				if (null == project)
 					return;
+
 				Guid viewGuid = VSConstants.LOGVIEWID_Code;
-				ErrorHandler.ThrowOnFailure(
-					project.OpenItem(fileId, ref viewGuid, documentData, out frame));
+
+				ErrorHandler.ThrowOnFailure(project.OpenItem(_fileId, ref viewGuid, documentData, out frame));
 			}
 			finally
 			{
@@ -128,44 +130,55 @@
 			}
 
 			// Make sure that the document window is visible.
+			//
 			ErrorHandler.ThrowOnFailure(frame.Show());
 
 			// Get the code window from the window frame.
+			//
 			object docView;
-			ErrorHandler.ThrowOnFailure(
-				frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out docView));
+
+			ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out docView));
+
 			IVsCodeWindow codeWindow = docView as IVsCodeWindow;
+
 			if (null == codeWindow)
 			{
 				object docData;
-				ErrorHandler.ThrowOnFailure(
-					frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData));
+
+				ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData));
+
 				codeWindow = docData as IVsCodeWindow;
-				if (null == codeWindow)
+
+				if (codeWindow == null)
 					return;
 			}
 
 			// Get the primary view from the code window.
+			//
 			IVsTextView textView;
+
 			ErrorHandler.ThrowOnFailure(codeWindow.GetPrimaryView(out textView));
 
 			// Set the cursor at the beginning of the declaration.
-			ErrorHandler.ThrowOnFailure(
-				textView.SetCaretPos(sourceSpan.iStartLine, sourceSpan.iStartIndex));
+			//
+			ErrorHandler.ThrowOnFailure(textView.SetCaretPos(_sourceSpan.iStartLine, _sourceSpan.iStartIndex));
+
 			// Make sure that the text is visible.
+			//
 			TextSpan visibleSpan = new TextSpan();
-			visibleSpan.iStartLine = sourceSpan.iStartLine;
-			visibleSpan.iStartIndex = sourceSpan.iStartIndex;
-			visibleSpan.iEndLine = sourceSpan.iStartLine;
-			visibleSpan.iEndIndex = sourceSpan.iStartIndex + 1;
+
+			visibleSpan.iStartLine  = _sourceSpan.iStartLine;
+			visibleSpan.iStartIndex = _sourceSpan.iStartIndex;
+			visibleSpan.iEndLine    = _sourceSpan.iStartLine;
+			visibleSpan.iEndIndex   = _sourceSpan.iStartIndex + 1;
+
 			ErrorHandler.ThrowOnFailure(textView.EnsureSpanVisible(visibleSpan));
 		}
 
-		protected override void SourceItems(out IVsHierarchy hierarchy,
-			out uint itemId, out uint itemsCount)
+		protected override void SourceItems(out IVsHierarchy hierarchy, out uint itemId, out uint itemsCount)
 		{
-			hierarchy = ownerHierarchy;
-			itemId = fileId;
+			hierarchy  = _ownerHierarchy;
+			itemId     = _fileId;
 			itemsCount = 1;
 		}
 
@@ -173,32 +186,34 @@
 		{
 			get
 			{
-				if (string.IsNullOrEmpty(fileMoniker))
-					ErrorHandler.ThrowOnFailure(
-						ownerHierarchy.GetCanonicalName(fileId, out fileMoniker));
-				return
-					string.Format(CultureInfo.InvariantCulture, "{0}/{1}", fileMoniker, Name);
+				if (string.IsNullOrEmpty(_fileMoniker))
+					ErrorHandler.ThrowOnFailure(_ownerHierarchy.GetCanonicalName(_fileId, out _fileMoniker));
+
+				return string.Format(CultureInfo.InvariantCulture, "{0}/{1}", _fileMoniker, Name);
 			}
 		}
 
 		IntPtr FindDocDataFromRDT()
 		{
 			// Get a reference to the RDT.
+			//
 			IVsRunningDocumentTable rdt =
-				NemerlePackage.GetGlobalService(typeof (SVsRunningDocumentTable)) as
-					IVsRunningDocumentTable;
-			if (null == rdt)
+				NemerlePackage.GetGlobalService(typeof (SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+
+			if (rdt == null)
 				return IntPtr.Zero;
 
 			// Get the enumeration of the running documents.
+			//
 			IEnumRunningDocuments documents;
+
 			ErrorHandler.ThrowOnFailure(rdt.GetRunningDocumentsEnum(out documents));
 
 			IntPtr documentData = IntPtr.Zero;
 			uint[] docCookie = new uint[1];
 			uint fetched;
-			while ((VSConstants.S_OK == documents.Next(1, docCookie, out fetched))
-				&& (1 == fetched))
+
+			while ((VSConstants.S_OK == documents.Next(1, docCookie, out fetched)) && (1 == fetched))
 			{
 				uint flags;
 				uint editLocks;
@@ -207,13 +222,22 @@
 				IVsHierarchy docHierarchy;
 				uint docId;
 				IntPtr docData = IntPtr.Zero;
+
 				try
 				{
-					ErrorHandler.ThrowOnFailure(
-						rdt.GetDocumentInfo(docCookie[0], out flags, out readLocks,
-							out editLocks, out moniker, out docHierarchy, out docId, out docData));
+					ErrorHandler.ThrowOnFailure(rdt.GetDocumentInfo(
+						docCookie[0],
+						out flags,
+						out readLocks,
+						out editLocks,
+						out moniker,
+						out docHierarchy,
+						out docId,
+						out docData));
+
 					// Check if this document is the one we are looking for.
-					if ((docId == fileId) && (ownerHierarchy.Equals(docHierarchy)))
+					//
+					if ((docId == _fileId) && (_ownerHierarchy.Equals(docHierarchy)))
 					{
 						documentData = docData;
 						docData = IntPtr.Zero;
@@ -222,7 +246,7 @@
 				}
 				finally
 				{
-					if (IntPtr.Zero != docData)
+					if (docData != IntPtr.Zero)
 						Marshal.Release(docData);
 				}
 			}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs	Sun Sep 24 07:08:42 2006
@@ -17,10 +17,10 @@
 using Microsoft.Samples.VisualStudio.LanguageService;
 
 using Nemerle.VsIntegration.Project;
+using Nemerle.VisualStudio.Package;
 using Nemerle.VisualStudio.Package.Automation;
 
 using PkgUtils = Microsoft.VisualStudio.Package.Utilities;
-using Nemerle.VisualStudio.Package;
 
 namespace Nemerle.VisualStudio.Project
 {

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	Sun Sep 24 07:08:42 2006
@@ -5,21 +5,20 @@
 using System.IO;
 using System.Reflection;
 using System.Windows.Forms;
+
+using Microsoft.VisualStudio;
 using Microsoft.VisualStudio.Package;
 using Microsoft.VisualStudio.Shell.Interop;
+
 using Nemerle.Compiler;
 using Nemerle.Completion2;
-using Nemerle.VsIntegration.Project;
 
-using MSBuild = Microsoft.Build.BuildEngine;
-using NCC = Nemerle.Compiler;
-using Nemerle.Compiler.Utils;
-//using Utils = Nemerle.VsIntegration.Project.Utils;
-using Microsoft.VisualStudio;
-using Nemerle.VsIntegration;
 using Nemerle.VisualStudio.Package;
 using Microsoft.Samples.VisualStudio.LanguageService;
 
+using MSBuild = Microsoft.Build.BuildEngine;
+using NCC     = Nemerle.Compiler;
+
 namespace Nemerle.VisualStudio.Project
 {
 	public class ProjectInfo
@@ -38,9 +37,11 @@
 			string location
 		)
 		{
-			_site = site;
 			ErrorHelper.ThrowIsNull(hierarchy, "hierarchy");
+
+			_site         = site;
 			_buildProject = buildProject;
+
 			CompilationOptions options = new CompilationOptions();
 
 			options.DoNotLoadStdlib = NoStdLib;
@@ -63,7 +64,7 @@
 			_engine.Init();
 		}
 
-		MSBuild.Project _buildProject;
+		private MSBuild.Project  _buildProject;
 		public MSBuild.Project MSBuildProject { get { return _buildProject; } }
 
 		public bool NoStdLib    { get { return Utils.IsTrue(MSBuildProject, "NoStdLib");    } }
@@ -74,13 +75,14 @@
 		public void InitListener()
 		{
 			_listener = new HierarchyListener(_hierarchy);
+
 			_listener.ItemAdded += FileAdded;
 			_listener.ItemDeleted += FileDeleted;
+
 			_listener.StartListening(true);
 		}
 
-		Engine _engine;
-
+		private Engine _engine;
 		public Engine Engine { get { return _engine; } }
 
 		public static Collection<ProjectInfo> ProjectsInfos
@@ -151,8 +153,7 @@
 			int timestamp = request.Timestamp;
 
 			if (!_filesMap.TryGetValue(filePath, out oldTimestamp))
-				throw new ArgumentException("File '" + filePath + "' tot found.",
-					"filePath");
+				throw new ArgumentException("File '" + filePath + "' tot found.", "filePath");
 
 			if (timestamp != oldTimestamp)
 			{
@@ -174,14 +175,10 @@
 		private static NemerleFileNodeProperties GetNodeProperties(IVsHierarchy hierarchy, uint itemID)
 		{
 			object propertyValue;
-			int hr = hierarchy.GetProperty(itemID,
-					(int)__VSHPROPID.VSHPROPID_BrowseObject,
-					out propertyValue);
+			int    hr = hierarchy.GetProperty(itemID, (int)__VSHPROPID.VSHPROPID_BrowseObject, out propertyValue);
 
 			if (hr != VSConstants.S_OK)
-				throw new ArgumentException(
-					"Can't obtain VSHPROPID_BrowseObject for item with ID " + itemID,
-					"itemID");
+				throw new ArgumentException("Can't obtain VSHPROPID_BrowseObject for item with ID " + itemID, "itemID");
 
 			return (NemerleFileNodeProperties)propertyValue;
 		}
@@ -190,8 +187,7 @@
 		{
 			Debug.Assert(ergs.TextBuffer == null);
 
-			NemerleFileNodeProperties nodeProps 
-				= GetNodeProperties((IVsHierarchy)sender, ergs.ItemID);
+			NemerleFileNodeProperties nodeProps = GetNodeProperties((IVsHierarchy)sender, ergs.ItemID);
 
 			if (nodeProps.BuildAction != BuildAction.Compile)
 				return;
@@ -208,6 +204,7 @@
 			{
 				// Same file can be included in different projects.
 				// VladD2: For now we don't support it. 
+				//
 				const string format = "Error add file '{0}' to Complation Engine.\r\n{1}";
 				Debug.WriteLine(string.Format(format, path, ex));
 			}
@@ -261,19 +258,26 @@
 			Trace.Assert(_project != null);
 
 			// If can't add relocation we must reparse types tree.
-			if (!Project.AddRelocation(filePath, newEndIndex, newEndLine, 
-				oldEndIndex, oldEndLine, startIndex, startLine)
-			)
+			//
+			if (!Project.AddRelocation(
+				filePath, newEndIndex, newEndLine, oldEndIndex, oldEndLine, startIndex, startLine))
 			{
 				// ×čńňî îňëŕäî÷íŕ˙ őđĺíü.
 				// Îáíîâëĺě ńîäĺđćčěîĺ ôŕéëŕ, ňŕę ęŕę îí čçěĺíčëń˙, ŕ Engine îá ýňîě ďîęŕ íĺçíŕĺň.
+				//
 				string code = Utils.GetFileCode(_site, filePath);
+
 				Project.Engine.Sources.AddOrUpdate(filePath, code);
+
 				// Îáíóë˙ĺě ńńűëęó íŕ ďđîĺęň. Ýňî ďđčâîäčň ę ňîěó, ÷ňî ńëĺäóţůĺĺ îáđŕůĺíčĺ
 				// ę ńâîéńňâó Project ńîçäŕńň íîâűé ďđîĺęň, ŕ ńňŕëî áűňü ďîńňđîčň íîâîĺ äĺđĺâî ňčďîâ.
+				//
 				ResetTypeTree();
+
 				// Îáíîâë˙ĺě GUI-äĺđĺâî âčçóŕëčçčđóţůĺĺ ŔŃŇ ňĺęóůĺăî ôŕéëŕ.
+				//
 				int fileIndex = Location.GetFileIndex(filePath);
+
 				Project.UpdateDebugTree(fileIndex);
 			}
 		}
@@ -290,8 +294,7 @@
 			}
 		}
 
-		public CompletionElem[] CompleteWord(
-			string filePath, int line, int col, GetText getText)
+		public CompletionElem[] CompleteWord(string filePath, int line, int col, GetText getText)
 		{
 			return Project.CompleteWord(filePath, line + 1, col + 1, getText);
 		}
@@ -314,7 +317,6 @@
 		public NemerleMethods GetMethodTip(string filePath, int line, int col, GetText getText)
 		{
 			MethodTipInfo info = Project.GetMethodTip(filePath, line + 1, col + 1, getText);
-
 			return info != null? new NemerleMethods(info): null;
 		}
 	}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/TextLineEventListener.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/TextLineEventListener.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/TextLineEventListener.cs	Sun Sep 24 07:08:42 2006
@@ -12,6 +12,7 @@
 using System.Diagnostics;
 using Microsoft.VisualStudio.OLE.Interop;
 using Microsoft.VisualStudio.TextManager.Interop;
+using Nemerle.VisualStudio.Project;
 
 namespace Microsoft.Samples.VisualStudio.LanguageService
 {
@@ -20,7 +21,7 @@
 		//private const int defaultDelay = 2000;
 
 		private string _fileName;
-		private NemerleLibraryManager.ModuleId _fileId;
+		private NemerleLibraryManager.ModuleID _fileId;
 		private IVsTextLines _buffer;
 		private bool isDirty;
 
@@ -28,7 +29,7 @@
 		private uint connectionCookie;
 
 		public TextLineEventListener(IVsTextLines buffer, string fileName,
-			NemerleLibraryManager.ModuleId id)
+			NemerleLibraryManager.ModuleID id)
 		{
 			_buffer = buffer;
 			_fileId = id;
@@ -45,7 +46,7 @@
 		}
 
 		#region Properties
-		public NemerleLibraryManager.ModuleId FileID
+		public NemerleLibraryManager.ModuleID FileID
 		{
 			get { return _fileId; }
 		}



More information about the svn mailing list