[svn] r6696: vs-plugin/trunk/Nemerle.VsIntegration: HierarchyListener.cs LanguageService/NemerleAuthoringS...

IT svnadmin at nemerle.org
Sun Sep 24 05:43:42 CEST 2006


Log:
C# integration project refactoring.

Author: IT
Date: Sun Sep 24 05:43:29 2006
New Revision: 6696

Added:
   vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs
Removed:
   vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNodeProperties.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerlePackage.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfoCollection.cs
Modified:
   vs-plugin/trunk/Nemerle.VsIntegration/HierarchyListener.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleDeclarations.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj
   vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/ObjectModelExtenders/ReferenceContainerNodeEx.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Package/Automation/NemerleOAFileItem.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectFactory.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNode.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNodeProperties.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Project/ProjectInfo.cs
   vs-plugin/trunk/Nemerle.VsIntegration/PropertyPages.cs
   vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs

Modified: vs-plugin/trunk/Nemerle.VsIntegration/HierarchyListener.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/HierarchyListener.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/HierarchyListener.cs	Sun Sep 24 05:43:29 2006
@@ -14,6 +14,7 @@
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.TextManager.Interop;
 using Nemerle;
+using Nemerle.VisualStudio;
 
 namespace Microsoft.Samples.VisualStudio.LanguageService
 {

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringScope.cs	Sun Sep 24 05:43:29 2006
@@ -6,7 +6,7 @@
 
 using Nemerle.Completion2;
 
-using Microsoft.Samples.VisualStudio.LanguageService;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VisualStudio.LanguageService
 {

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleAuthoringSink.cs	Sun Sep 24 05:43:29 2006
@@ -2,8 +2,6 @@
 
 using Microsoft.VisualStudio.Package;
 
-using Microsoft.Samples.VisualStudio.LanguageService;
-
 namespace Nemerle.VisualStudio.LanguageService
 {
 	public class NemerleAuthoringSink : AuthoringSink

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleDeclarations.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleDeclarations.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleDeclarations.cs	Sun Sep 24 05:43:29 2006
@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
 
 using Microsoft.VisualStudio.Package;
 using Microsoft.VisualStudio.TextManager.Interop;
@@ -19,7 +18,6 @@
 			Sort();
 		}
 
-		[SuppressMessage("Microsoft.Design", "CA1024")]
 		public override int GetCount()
 		{
 			return _overloadPossibility.Length;
@@ -64,7 +62,6 @@
 		// Note that the initial extent is only what the user has typed so far.
 		// Disable the "ParameterNamesShouldMatchBaseDeclaration" warning.
 		//
-		[SuppressMessage("Microsoft.Naming", "CA1725")]
 		public override string OnCommit(
 			IVsTextView textView, string textSoFar, char commitCharacter, int index, ref TextSpan initialExtent)
 		{

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	Sun Sep 24 05:43:29 2006
@@ -23,6 +23,7 @@
 using Nemerle.VisualStudio;
 
 using Nemerle.VisualStudio.Package;
+using Nemerle.VisualStudio.Project;
 using Microsoft.Samples.VisualStudio.LanguageService;
 
 using VsShell = Microsoft.VisualStudio.Shell.VsShellUtilities;
@@ -211,7 +212,7 @@
 				projectInfo.Engine.ProcessMessages = true;
 				projectInfo.UpdateFile(request);
 
-				Project project = projectInfo.Project;
+				Nemerle.Completion2.Project project = projectInfo.Project;
 
 				project.CheckErrors(
 					request.FileName,

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleSource.cs	Sun Sep 24 05:43:29 2006
@@ -7,7 +7,7 @@
 using Microsoft.VisualStudio.Shell;
 using Microsoft.VisualStudio.Shell.Interop;
 
-using Microsoft.Samples.VisualStudio.LanguageService;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VisualStudio.LanguageService
 {

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 05:43:29 2006
@@ -69,8 +69,6 @@
     <Reference Include="..\Nemerle.Compiler.Utils\bin\$(Configuration)\Nemerle.Compiler.Utils.dll" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Engine\ProjectInfo.cs" />
-    <Compile Include="Engine\ProjectInfoCollection.cs" />
     <Compile Include="Engine\ScopeNode.cs" />
     <Compile Include="HierarchyListener.cs" />
     <Compile Include="Library.cs" />
@@ -82,7 +80,6 @@
     <Compile Include="NemerleLibraryManager.cs" />
     <Compile Include="NemerleLibraryNode.cs" />
     <Compile Include="Package\NemerleMethods.cs" />
-    <Compile Include="Package\NemerleProjectPackage.cs" />
     <Compile Include="Package\NemerleViewFilter.cs" />
     <Compile Include="RegisterSnippetsAttribute.cs" />
     <Compile Include="Resources.Designer.cs">
@@ -136,7 +133,12 @@
     <Compile Include="LanguageService\NemerleLanguageService.cs" />
     <Compile Include="LanguageService\NemerleScanner.cs" />
     <Compile Include="LanguageService\NemerleSource.cs" />
+    <Compile Include="NemerlePackage.cs" />
     <Compile Include="Package\Automation\NemerleOAFileItem.cs" />
+    <Compile Include="Project\NemerleProjectFactory.cs" />
+    <Compile Include="Project\NemerleProjectNode.cs" />
+    <Compile Include="Project\NemerleProjectNodeProperties.cs" />
+    <Compile Include="Project\ProjectInfo.cs" />
     <Compile Include="Utils.cs" />
     <Compile Include="ConfigurationPropertyPages.cs" />
     <Compile Include="Package\NemerleEditorFactory.cs" />
@@ -151,17 +153,14 @@
     <Compile Include="FileCodeModel\NemerleCodeElements.cs" />
     <Compile Include="FileCodeModel\NullTextPoint.cs" />
     <Compile Include="FileCodeModel\VoidCodeTypeRef.cs" />
-    <Compile Include="Package\NemerleProjectNode.cs" />
     <Compile Include="ObjectModelExtenders\ReferenceContainerNodeEx.cs" />
     <Compile Include="ObjectModelExtenders\TokenProcessorEx.cs" />
     <Compile Include="FileCodeModel\NemerleFileCodeModel.cs" />
-    <Compile Include="Package\NemerleProjectFactory.cs" />
     <Compile Include="PropertyPages.cs" />
     <Compile Include="Package\NemerleConfigProvider.cs" />
-    <Compile Include="Package\NemerleFileNode.cs" />
-    <Compile Include="Package\NemerleFileNodeProperties.cs" />
+    <Compile Include="Project\NemerleFileNode.cs" />
+    <Compile Include="Project\NemerleFileNodeProperties.cs" />
     <Compile Include="NemerleMenus.cs" />
-    <Compile Include="Package\NemerleProjectNodeProperties.cs" />
     <Compile Include="Resources.cs" />
     <Compile Include="Package\SelectionElementValueChangedListener.cs" />
     <Compile Include="VSMDNemerleProvider.cs" />
@@ -257,9 +256,6 @@
   <ItemGroup>
     <Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />
   </ItemGroup>
-  <ItemGroup>
-    <Folder Include="Project\" />
-  </ItemGroup>
   <PropertyGroup>
     <TargetRegistryRoot>Software\Microsoft\VisualStudio\8.0Exp</TargetRegistryRoot>
     <RegisterOutputPackage>true</RegisterOutputPackage>

Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs	Sun Sep 24 05:43:29 2006
@@ -16,6 +16,7 @@
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.VisualStudio.TextManager.Interop;
 using Nemerle.VisualStudio.Package;
+using Nemerle.VisualStudio;
 
 namespace Microsoft.Samples.VisualStudio.LanguageService
 {
@@ -184,7 +185,7 @@
 		{
 			// Get a reference to the RDT.
 			IVsRunningDocumentTable rdt =
-				NemerleProjectPackage.GetGlobalService(typeof (SVsRunningDocumentTable)) as
+				NemerlePackage.GetGlobalService(typeof (SVsRunningDocumentTable)) as
 					IVsRunningDocumentTable;
 			if (null == rdt)
 				return IntPtr.Zero;

Added: vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs	Sun Sep 24 05:43:29 2006
@@ -0,0 +1,348 @@
+using System;
+using System.ComponentModel.Design;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.Package;
+
+using Nemerle.Completion2;
+using Nemerle.Compiler;
+
+using Microsoft.VisualStudio.TextManager.Interop;
+using Nemerle.VisualStudio.Package;
+using Nemerle.VsIntegration.Project;
+using Nemerle.VisualStudio.Shell;
+using Microsoft.Samples.VisualStudio.LanguageService;
+using Nemerle.VisualStudio.LanguageService;
+using Nemerle.VisualStudio.Project;
+
+namespace Nemerle.VisualStudio
+{
+	#region Registration Attributes
+
+	//TODO: Add WebSiteProject support.
+	//[
+	//  SingleFileGeneratorSupportRegistrationAttribute(
+	//    typeof (NemerleProjectFactory))]
+	//[WebSiteProject(GlobalConstants.LanguageName , GlobalConstants.LanguageName)]
+	//[WebSiteProjectRelatedFiles("aspx", "n")]
+	//[WebSiteProjectRelatedFiles("master", "n")]
+	//[
+	//  LanguageIntellisenseProviderRegistration(
+	//    NemerleConstants.LanguageIntellisenseProviderGuidString, 
+	//    "NemerleCodeProvider",
+	//    GlobalConstants.LanguageName, ".n", 
+	//    GlobalConstants.LanguageName + ";" + GlobalConstants.LanguageName ,
+	//    GlobalConstants.LanguageName)]
+	[DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\8.0Exp")]
+	[ProvideProjectFactory(typeof(NemerleProjectFactory), 
+		GlobalConstants.LanguageName,
+		GlobalConstants.LanguageName + " Project Project Files (*." +
+			GlobalConstants.ProjectExtension + ");*." + GlobalConstants.ProjectExtension,
+		GlobalConstants.ProjectExtension,
+		GlobalConstants.ProjectExtension,
+		// Set the projectsTemplatesDirectory to a non-existant path to prevent VS 
+		// from including the working directory as a valid template path
+		@".\NullPath",
+		LanguageVsTemplate = GlobalConstants.LanguageName)]
+	[ProvideMenuResource   (1000, 1)]
+	[ProvideObject           (typeof(GeneralPropertyPage))]
+	[ProvideObject           (typeof(NemerleBuildPropertyPage))]
+	[ProvideEditorExtension  (typeof(NemerlEditorFactory), ".n", 32)]
+	[ProvideEditorLogicalView(typeof(NemerlEditorFactory), GlobalConstants.EditorLogicalViewGuidString)]
+	//LOGVIEWID_Designer
+	//[ProvideEditorLogicalView(typeof(NP.EditorFactory),
+	//  "{7651a701-06e5-11d1-8ebd-00a0c90f26ea}")
+	//] //LOGVIEWID_Code
+	[PackageRegistration(UseManagedResourcesOnly = true)]
+	// Showing the splash screen requires "devenv /rootsuffix Exp /setup" during the installation.
+	// For more information please see: http://blogs.msdn.com/jim_glass/archive/2005/05/23/421152.aspx
+	[InstalledProductRegistration(
+		true, 
+		GlobalConstants.LanguageName, 
+		GlobalConstants.ProductDetails, 
+		GlobalConstants.ProductID, 
+		IconResourceID=300)]
+	[ProvideLoadKey("standard", GlobalConstants.ProductID, GlobalConstants.ProductDetails, "", 104)]
+	[ProvideService(typeof(NemerleLanguageService), ServiceName = GlobalConstants.LanguageName)]
+	[ProvideService(typeof(INemerleLibraryManager))]
+	[ProvideLanguageService(
+		typeof(NemerleLanguageService),
+		GlobalConstants.LanguageName,
+		100,
+		CodeSense = true,
+		EnableCommenting = true,
+		MatchBraces = true,
+		ShowCompletion = true,
+		ShowMatchingBrace = true)]
+	[ProvideLanguageExtension(typeof(NemerleLanguageService), GlobalConstants.FileExtension)]
+	[Guid(GlobalConstants.PackageGuidString)]
+	[RegisterSnippets(
+		GlobalConstants.LanguageServiceGuidString,
+		false,
+		100,
+		GlobalConstants.LanguageName,
+		@"CodeSnippets\SnippetsIndex.xml",
+		@"CodeSnippets\Snippets\",
+		@"CodeSnippets\Snippets\")
+	]
+
+	#endregion
+
+	public class NemerlePackage : ProjectPackage/*Package*/, IOleComponent, IVsInstalledProduct
+	{
+		private uint                  _componentID;
+		private NemerleLibraryManager _libraryManager;
+
+		#region Initialize
+
+		public NemerlePackage()
+		{
+			IServiceContainer      container = this;
+			ServiceCreatorCallback callback  = new ServiceCreatorCallback(CreateService);
+
+			container.AddService(typeof(NemerleLanguageService), callback, true);
+			container.AddService(typeof(INemerleLibraryManager), callback, true);
+		}
+
+		protected override void Initialize()
+		{
+			base.Initialize();
+
+			RegisterProjectFactory(new NemerleProjectFactory(this));
+			RegisterEditorFactory (new NemerlEditorFactory  (this));
+
+			//Microsoft.VisualStudio.Shell.Interop.IVsRegisterEditors registerEditors = 
+			//  GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsRegisterEditors))
+			//  as Microsoft.VisualStudio.Shell.Interop.IVsRegisterEditors;
+
+			//uint cookie;
+			//Guid riid = editorFactory.GetType().GUID;
+
+			//int result = registerEditors.RegisterEditor(ref riid, editorFactory, out cookie);
+			//NativeMethods.ThrowOnFailure(result);
+		}
+		
+		#endregion
+
+		#region RegisterForIdleTime()
+
+		private void RegisterForIdleTime()
+		{
+			IOleComponentManager mgr = GetIOleComponentManager();
+
+			if (_componentID == 0)
+			{
+				OLECRINFO[] crinfo = new OLECRINFO[1];
+				crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
+				crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime
+					| (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
+				crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal
+					| (uint)_OLECADVF.olecadvfRedrawOff
+					| (uint)_OLECADVF.olecadvfWarningsOff;
+				crinfo[0].uIdleTimeInterval = 1000;
+				ErrorHandler.ThrowOnFailure(mgr.FRegisterComponent(this, crinfo, out _componentID));
+			}
+		}
+		
+		#endregion
+
+		#region GetService()
+
+		internal T GetService<T>(bool throwIfFail)
+		where T : class
+		{
+			return GetService<T, T>(throwIfFail);
+		}
+
+		internal T GetService<T>()
+				where T : class
+		{
+			return GetService<T, T>(false);
+		}
+
+		internal TItf GetService<TItf, TSrv>()
+				where TItf : class
+		{
+			return GetService<TItf, TSrv>(false);
+		}
+
+		internal void GetService<T>(out T itf)
+				where T : class
+		{
+			itf = GetService<T, T>(false);
+		}
+
+		internal TItf GetService<TItf, TSrv>(bool throwIfFail)
+				where TItf : class
+		{
+			TItf service = GetService(typeof(TSrv)) as TItf;
+
+			if (service == null && throwIfFail)
+				throw new ArgumentException("GetService() failed for query "
+					+ typeof(TSrv).Name);
+
+			return service;
+		}
+
+			IOleComponentManager GetIOleComponentManager()
+			{
+				return GetService<IOleComponentManager, SOleComponentManager>(true);
+			}
+
+
+		#endregion
+
+		#region Dispose()
+
+		protected override void Dispose(bool disposing)
+		{
+			try
+			{
+				if (_componentID != 0)
+				{
+					IOleComponentManager mgr = GetIOleComponentManager();
+					mgr.FRevokeComponent(_componentID);
+					_componentID = 0;
+				}
+
+				if (null != _libraryManager)
+				{
+					_libraryManager.Dispose();
+					_libraryManager = null;
+				}
+			}
+			finally
+			{
+				base.Dispose(disposing);
+			}
+		}
+		
+		#endregion
+
+		#region CreateService()
+
+		private object CreateService(IServiceContainer container, Type serviceType)
+		{
+			object service = null;
+			if (typeof(NemerleLanguageService) == serviceType)
+			{
+				NemerleLanguageService language = new NemerleLanguageService();
+				language.SetSite(this);
+				RegisterForIdleTime();
+				service = language;
+			}
+			else if (typeof(INemerleLibraryManager) == serviceType)
+			{
+				_libraryManager = new NemerleLibraryManager(this);
+				service = _libraryManager;
+			}
+
+			return service;
+		}
+		
+		#endregion
+
+		#region IOleComponent Members
+
+		public int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked)
+		{
+			return 1;
+		}
+
+		public int FDoIdle(uint grfidlef)
+		{
+			NemerleLanguageService lang = GetService(typeof(NemerleLanguageService)) as NemerleLanguageService;
+			
+			if (lang != null)
+				lang.OnIdle((grfidlef & (uint)_OLEIDLEF.oleidlefPeriodic) != 0);
+
+			if (null != _libraryManager)
+				_libraryManager.OnIdle();
+
+			return 0;
+		}
+
+		public int FPreTranslateMessage(MSG[] pMsg) { return 0; }
+		public int FQueryTerminate(int fPromptUser) { return 1; }
+
+		public int FReserved1(uint dwReserved, uint message, 
+			IntPtr wParam, IntPtr lParam)
+		{
+			return 1;
+		}
+
+		public IntPtr HwndGetWindow(uint dwWhich, uint dwReserved)
+		{
+			return IntPtr.Zero;
+		}
+
+		public void OnActivationChange(IOleComponent pic, int fSameComponent,
+			OLECRINFO[] pcrinfo, int fHostIsActivating, 
+			OLECHOSTINFO[] pchostinfo, uint dwReserved)
+		{
+		}
+
+		public void OnAppActivate(int fActive, uint dwOtherThreadID) { }
+		public void OnEnterState(uint uStateID, int fEnter) { }
+		public void OnLoseActivation() { }
+		public void Terminate() { }
+
+		#endregion
+
+		#region IVsInstalledProduct Members
+		/// <summary>
+		/// This method is called during Devenv /Setup to get the bitmap to display on the splash screen for this package.
+		/// </summary>
+		/// <param name="pIdBmp">The resource id corresponding to the bitmap to display on the splash screen</param>
+		/// <returns>HRESULT, indicating success or failure</returns>
+		public int IdBmpSplash(out uint pIdBmp) {
+			pIdBmp = 300; // nevermind, does not called by VS2005
+			return VSConstants.S_OK;
+		}
+
+		/// <summary>
+		/// This method is called to get the icon that will be displayed in the Help About dialog when this package is selected.
+		/// </summary>
+		/// <param name="pIdIco">The resource id corresponding to the icon to display on the Help About dialog</param>
+		/// <returns>HRESULT, indicating success or failure</returns>
+		public int IdIcoLogoForAboutbox(out uint pIdIco) {
+			pIdIco = 300; // used for splash screen also
+			return VSConstants.S_OK;
+		}
+
+		/// <summary>
+		/// This methods provides the product official name, it will be displayed in the help about dialog.
+		/// </summary>
+		/// <param name="pbstrName">Out parameter to which to assign the product name</param>
+		/// <returns>HRESULT, indicating success or failure</returns>
+		public int OfficialName(out string pbstrName) {
+			pbstrName = GlobalConstants.LanguageName;
+			return VSConstants.S_OK;
+		}
+
+		/// <summary>
+		/// This methods provides the product description, it will be displayed in the help about dialog.
+		/// </summary>
+		/// <param name="pbstrProductDetails">Out parameter to which to assign the description of the package</param>
+		/// <returns>HRESULT, indicating success or failure</returns>
+		public int ProductDetails(out string pbstrProductDetails) {
+			pbstrProductDetails = GlobalConstants.ProductDetails;
+			return VSConstants.S_OK;
+		}
+
+		/// <summary>
+		/// This methods provides the product version, it will be displayed in the help about dialog.
+		/// </summary>
+		/// <param name="pbstrPID">Out parameter to which to assign the version number</param>
+		/// <returns>HRESULT, indicating success or failure</returns>
+		public int ProductID(out string pbstrPID) {
+			pbstrPID = GlobalConstants.ProductID;
+			return VSConstants.S_OK;
+		}
+		#endregion
+	}
+}

Modified: vs-plugin/trunk/Nemerle.VsIntegration/ObjectModelExtenders/ReferenceContainerNodeEx.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/ObjectModelExtenders/ReferenceContainerNodeEx.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/ObjectModelExtenders/ReferenceContainerNodeEx.cs	Sun Sep 24 05:43:29 2006
@@ -4,6 +4,7 @@
 using Microsoft.VisualStudio.Package;
 using Microsoft.VisualStudio.Package.Automation;
 using Nemerle.VisualStudio.Package;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VsIntegration.Project
 {

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Package/Automation/NemerleOAFileItem.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Package/Automation/NemerleOAFileItem.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/Automation/NemerleOAFileItem.cs	Sun Sep 24 05:43:29 2006
@@ -7,6 +7,7 @@
 
 using Microsoft.Samples.VisualStudio.LanguageService;
 using Nemerle.VsIntegration.Project;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VisualStudio.Package.Automation
 {

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs	Sun Sep 24 05:43:29 2006
@@ -20,7 +20,7 @@
 	{
 		#region ctors
 
-		public NemerlEditorFactory(NemerleProjectPackage package)
+		public NemerlEditorFactory(NemerlePackage package)
 		{
 			_package = package;
 		}
@@ -35,7 +35,7 @@
 
 		#region Fields
 
-		NemerleProjectPackage  _package;
+		NemerlePackage  _package;
 		ServiceProvider _serviceProvider;
 
 		#endregion

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs	Sun Sep 24 05:43:29 2006
@@ -4,6 +4,7 @@
 using Microsoft.VisualStudio.Package;
 using Microsoft.VisualStudio.Shell;
 using Microsoft.VisualStudio.Shell.Interop;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VisualStudio.Package
 {

Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs	Sun Sep 24 05:43:29 2006
@@ -0,0 +1,214 @@
+using System;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+
+using VSLangProj;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.Package.Automation;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+using Nemerle.VisualStudio.Package.Automation;
+using Nemerle.VsIntegration.Project;
+using Nemerle.VisualStudio.Package;
+
+using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
+using VsCommands          = Microsoft.VisualStudio.VSConstants.VSStd97CmdID;
+using VsMenus             = Microsoft.VisualStudio.Shell.VsMenus;
+
+namespace Nemerle.VisualStudio.Project
+{
+	class NemerleFileNode : FileNode
+	{
+		#region ctors
+
+		internal NemerleFileNode(ProjectNode root, ProjectElement e) : base(root, e)
+		{
+			_selectionChangedListener =
+				new SelectionElementValueChangedListener(
+					new ServiceProvider((IOleServiceProvider)root.GetService(typeof (IOleServiceProvider))), root);
+
+			_selectionChangedListener.Init();
+
+			((FileNodeProperties)NodeProperties).OnCustomToolChanged          += OnCustomToolChanged;
+			((FileNodeProperties)NodeProperties).OnCustomToolNameSpaceChanged += OnCustomToolNameSpaceChanged;
+		}
+
+		#endregion
+
+		#region Fields
+
+		OAVSProjectItem                      _vsProjectItem;
+		SelectionElementValueChangedListener _selectionChangedListener;
+
+		#endregion
+
+		#region Properties
+
+		/// <summary>
+		/// Returns bool indicating whether this node is of subtype "Form"
+		/// </summary>
+		public bool IsFormSubType
+		{
+			get
+			{
+				string result = ItemNode.GetMetadata(ProjectFileConstants.SubType);
+
+				return
+					!string.IsNullOrEmpty(result) &&
+					 string.Compare(result, ProjectFileAttributeValue.Form, true, CultureInfo.InvariantCulture) == 0;
+			}
+		}
+
+		/// <summary>
+		/// Returns the SubType of an Nemerle FileNode. It is 
+		/// </summary>
+		public string SubType
+		{
+			get { return ItemNode.GetMetadata(ProjectFileConstants.SubType); }
+			set { ItemNode.SetMetadata(ProjectFileConstants.SubType, value); }
+		}
+
+		protected internal VSProjectItem VSProjectItem
+		{
+			get
+			{
+				if (null == _vsProjectItem)
+					_vsProjectItem = new OAVSProjectItem(this);
+				return _vsProjectItem;
+			}
+		}
+
+		#endregion
+
+		#region Overridden Properties
+
+		internal override object Object { get { return VSProjectItem; } }
+
+		#endregion
+
+		#region overridden methods
+
+		public override int Close()
+		{
+			if (_selectionChangedListener != null)
+				_selectionChangedListener.Dispose();
+
+			return base.Close();
+		}
+
+		public override object GetAutomationObject()
+		{
+			return new NemerleOAFileItem((OAProject)ProjectMgr.GetAutomationObject(), this);
+		}
+
+		// Called since the FileNode.ImageIndex returns -1 by default.
+		//
+		public override object GetIconHandle(bool open)
+		{
+			if (FileName.EndsWith(GlobalConstants.FileExtension, StringComparison.InvariantCultureIgnoreCase))
+				return PackageUtilities.GetIntPointerFromImage(
+					NemerleProjectNode.NemerleImageList.Images[(int)GlobalConstants.ImageListIndex.NemerleSource]);
+
+			return base.GetIconHandle(open);
+		}
+
+		/// <summary>
+		/// Open a file depending on the SubType property associated with the file item in the project file
+		/// </summary>
+		protected override void DoDefaultAction()
+		{
+			FileDocumentManager manager = GetDocumentManager() as FileDocumentManager;
+
+			Debug.Assert(manager != null, "Could not get the FileDocumentManager");
+
+			Guid viewGuid = IsFormSubType? NativeMethods.LOGVIEWID_Designer : NativeMethods.LOGVIEWID_Code;
+
+			IVsWindowFrame frame;
+
+			manager.Open(false, false, viewGuid, out frame, WindowFrameShowAction.Show);
+		}
+
+		protected override int ExecCommandOnNode(
+			Guid guidCmdGroup, uint cmd, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
+		{
+			Debug.Assert(ProjectMgr != null, "The NemerleFileNode has no project manager");
+
+			if (ProjectMgr == null)
+				throw new InvalidOperationException();
+
+			if (guidCmdGroup == NemerleMenus.guidNemerleProjectCmdSet && cmd == (uint)NemerleMenus.SetAsMain.ID)
+			{
+				// Set the MainFile project property to the Filename of this Node.
+				//
+				ProjectMgr.SetProjectProperty(NemerleProjectNodeProperties.MainFilePropertyName, GetRelativePath());
+
+				return VSConstants.S_OK;
+			}
+
+			return base.ExecCommandOnNode(guidCmdGroup, cmd, nCmdexecopt, pvaIn, pvaOut);
+		}
+
+		/// <summary>
+		/// Handles the menuitems
+		/// </summary>		
+		protected override int QueryStatusOnNode(
+			Guid guidCmdGroup, uint cmd, IntPtr pCmdText, ref QueryStatusResult result)
+		{
+			if (guidCmdGroup == VsMenus.guidStandardCommandSet97)
+			{
+				switch ((VsCommands)cmd)
+				{
+					case VsCommands.AddNewItem:
+					case VsCommands.AddExistingItem:
+					case VsCommands.ViewCode:
+						result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
+						return VSConstants.S_OK;
+
+					case VsCommands.ViewForm:
+						if (IsFormSubType)
+							result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
+						return VSConstants.S_OK;
+				}
+			}
+			else if (guidCmdGroup == NemerleMenus.guidNemerleProjectCmdSet)
+				if (cmd == (uint)NemerleMenus.SetAsMain.ID)
+				{
+					result |= QueryStatusResult.SUPPORTED | QueryStatusResult.ENABLED;
+					return VSConstants.S_OK;
+				}
+
+			return base.QueryStatusOnNode(guidCmdGroup, cmd, pCmdText, ref result);
+		}
+
+		protected override NodeProperties CreatePropertiesObject()
+		{
+			return new NemerleFileNodeProperties(this);
+		}
+
+		#endregion
+
+		#region Helper Methods
+
+		protected string GetRelativePath()
+		{
+			string        relativePath = Path.GetFileName(ItemNode.GetMetadata(ProjectFileConstants.Include));
+			HierarchyNode parent       = Parent;
+
+			while (parent != null && !(parent is ProjectNode))
+			{
+				relativePath = Path.Combine(parent.Caption, relativePath);
+				parent       = parent.Parent;
+			}
+
+			return relativePath;
+		}
+
+		#endregion
+	}
+}
\ No newline at end of file

Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs	Sun Sep 24 05:43:29 2006
@@ -0,0 +1,34 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio.Package;
+
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+namespace Nemerle.VisualStudio.Project
+{
+	[ComVisible(true)]
+	[CLSCompliant(false)]
+	[Guid(GlobalConstants.FileNodePropertiesGuidString)]
+	public class NemerleFileNodeProperties : FileNodeProperties
+	{
+		public NemerleFileNodeProperties(HierarchyNode node)
+			: base(node)
+		{
+		}
+
+		[Browsable(false)]
+		public string Url
+		{
+			get { return "file:///" + Node.Url; }
+		}
+
+		[Browsable(false)]
+		public string SubType
+		{
+			get { return ((NemerleFileNode)Node).SubType;  }
+			set { ((NemerleFileNode)Node).SubType = value; }
+		}
+	}
+}
\ No newline at end of file

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectFactory.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectFactory.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectFactory.cs	Sun Sep 24 05:43:29 2006
@@ -7,12 +7,12 @@
 
 using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
 
-namespace Nemerle.VisualStudio.Package
+namespace Nemerle.VisualStudio.Project
 {
 	[Guid(GlobalConstants.ProjectFactoryViewGuidString)]
 	public class NemerleProjectFactory : ProjectFactory
 	{
-		public NemerleProjectFactory(NemerleProjectPackage package)
+		public NemerleProjectFactory(NemerlePackage package)
 			: base(package)
 		{ 
 		}
@@ -23,7 +23,7 @@
 			IOleServiceProvider oleServiceProvider =
 				(IOleServiceProvider)provider.GetService(typeof(IOleServiceProvider));
 
-			ProjectNode project = new NemerleProjectNode((NemerleProjectPackage)Package);
+			ProjectNode project = new NemerleProjectNode((NemerlePackage)Package);
 
 			project.SetSite(oleServiceProvider);
 

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 05:43:29 2006
@@ -20,18 +20,19 @@
 using Nemerle.VisualStudio.Package.Automation;
 
 using PkgUtils = Microsoft.VisualStudio.Package.Utilities;
+using Nemerle.VisualStudio.Package;
 
-namespace Nemerle.VisualStudio.Package
+namespace Nemerle.VisualStudio.Project
 {
 	[Guid(GlobalConstants.ProjectNodeGuidString)]
 	public class NemerleProjectNode : ProjectNode, IVsProjectSpecificEditorMap2
 	{
-		NemerleProjectPackage _package;
+		NemerlePackage _package;
 		static ImageList _nemerleImageList = LoadProjectImajeList();
 		
 		#region ctor
 
-		public NemerleProjectNode(NemerleProjectPackage pkg)
+		public NemerleProjectNode(NemerlePackage pkg)
 		{
 			_package = pkg;
 
@@ -51,7 +52,7 @@
 			//
 			Type     type         = typeof(NemerleProjectNode);
 			Assembly assembly     = type.Assembly;
-			string   resourceName = Nemerle.VsIntegration.Project.Utils.GetModuleName(type) + "." + GlobalConstants.ProjectImageListName;
+			string   resourceName = Utils.GetModuleName(type) + "." + GlobalConstants.ProjectImageListName;
 			Stream   imageStream  = assembly.GetManifestResourceStream(resourceName);
 
 			Trace.Assert(imageStream != null);

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNodeProperties.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNodeProperties.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleProjectNodeProperties.cs	Sun Sep 24 05:43:29 2006
@@ -6,7 +6,7 @@
 
 using Microsoft.Samples.VisualStudio.LanguageService;
 
-namespace Nemerle.VisualStudio.Package
+namespace Nemerle.VisualStudio.Project
 {
 	[ComVisible(true)]
 	[CLSCompliant(false)]

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 05:43:29 2006
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Collections.ObjectModel;
 using System.Diagnostics;
 using System.IO;
 using System.Reflection;
@@ -13,18 +14,19 @@
 using MSBuild = Microsoft.Build.BuildEngine;
 using NCC = Nemerle.Compiler;
 using Nemerle.Compiler.Utils;
-using Utils = Nemerle.VsIntegration.Project.Utils;
+//using Utils = Nemerle.VsIntegration.Project.Utils;
 using Microsoft.VisualStudio;
 using Nemerle.VsIntegration;
 using Nemerle.VisualStudio.Package;
+using Microsoft.Samples.VisualStudio.LanguageService;
 
-namespace Microsoft.Samples.VisualStudio.LanguageService
+namespace Nemerle.VisualStudio.Project
 {
 	public class ProjectInfo
 	{
 		private HierarchyListener            _listener;
 		private Dictionary<string, int>      _filesMap      = new Dictionary<string, int>();
-		private static ProjectInfoCollection _projectsInfos = new ProjectInfoCollection();
+		private static Collection<ProjectInfo> _projectsInfos = new Collection<ProjectInfo>();
 		private string                       _projectLocation;
 		private readonly IServiceProvider    _site;
 
@@ -81,7 +83,7 @@
 
 		public Engine Engine { get { return _engine; } }
 
-		public static ProjectInfoCollection ProjectsInfos
+		public static Collection<ProjectInfo> ProjectsInfos
 		{
 			get { return _projectsInfos; }
 		}
@@ -230,7 +232,7 @@
 			return null;
 		}
 
-		Project _project;
+		Nemerle.Completion2.Project _project;
 
 		public bool IsTypeTreeParsed
 		{
@@ -277,7 +279,7 @@
 		}
 
 
-		public Project Project
+		public Nemerle.Completion2.Project Project
 		{
 			get
 			{

Modified: vs-plugin/trunk/Nemerle.VsIntegration/PropertyPages.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/PropertyPages.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/PropertyPages.cs	Sun Sep 24 05:43:29 2006
@@ -21,6 +21,7 @@
 using Microsoft.VisualStudio.Shell.Interop;
 using Microsoft.Samples.VisualStudio.LanguageService;
 using Nemerle.VisualStudio.Package;
+using Nemerle.VisualStudio.Project;
 
 namespace Nemerle.VsIntegration.Project
 {

Modified: vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs	Sun Sep 24 05:43:29 2006
@@ -1,31 +1,24 @@
 using System;
 using System.IO;
 
-using Microsoft.Samples.VisualStudio.LanguageService;
+using Microsoft.VisualStudio.Package;
 
 using Nemerle.Compiler;
-using System.Reflection;
-using Msbuild = Microsoft.Build.BuildEngine;
-using Nemerle.VisualStudio.Package;
-using Microsoft.VisualStudio.Package;
+
 using Nemerle.VisualStudio.LanguageService;
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+using Msbuild = Microsoft.Build.BuildEngine;
 
-namespace Nemerle
+namespace Nemerle.VisualStudio
 {
-	//TODO: ńëčňü ęëŕńńű Utils
-	namespace VsIntegration.Project
-	{
 		static class Utils
 		{
-			//public static string GetFileCode(int fileIndex)
-			//{
-			//  return GetFileCode(Location.GetFileName(fileIndex));
-			//}
-
 			public static string GetFileCode(IServiceProvider site, string filePath)
 			{
 				NemerleLanguageService lang = (NemerleLanguageService)site.GetService(typeof(NemerleLanguageService));
 				Source source = lang.GetSource(filePath);
+
 				return source.GetText();
 			}
 
@@ -36,8 +29,7 @@
 
 			public static bool Eq(string str1, string str2)
 			{
-				return string.Compare(str1, str2, 
-					StringComparison.InvariantCultureIgnoreCase) == 0;
+			return string.Compare(str1, str2, StringComparison.InvariantCultureIgnoreCase) == 0;
 			}
 
 			public static string GetModuleName(Type type)
@@ -51,16 +43,13 @@
 			{
 				return provider.GetService(typeof(T)) as T;
 			}
-		}
-	}
 
-	internal static class Utils
-	{
 		public static bool IsNemerleFileExtension(string path)
 		{
 			ErrorHelper.ThrowIsNullOrEmpty(path, "path");
 
-			return String.Compare(Path.GetExtension(path),
+			return String.Compare(
+				Path.GetExtension(path),
 							GlobalConstants.FileExtension,
 										StringComparison.OrdinalIgnoreCase) == 0;
 		}
@@ -74,16 +63,13 @@
 			}
 		}
 
-		public static T GetService<T>(IServiceProvider provider) where T : class
-		{
-			return provider.GetService(typeof(T)) as T;
-		}
-
 		public static T GetRequiredService<T>(IServiceProvider provider)
 			where T : class
 		{
 			T service = GetService<T>(provider);
+
 			ErrorHelper.ThrowIsNull(service, "service", typeof(T).FullName);
+
 			return service;
 		}
 	}



More information about the svn mailing list