[svn] r6677: vs-plugin/trunk/Nemerle.VsIntegration:
EditorFactory.cs Engine/ProjectInfo.cs Nemerle.VsInteg...
IT
svnadmin at nemerle.org
Fri Sep 22 06:22:52 CEST 2006
Log:
C# integration project refactoring.
Author: IT
Date: Fri Sep 22 06:22:40 2006
New Revision: 6677
Added:
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleAuthoringSink.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleConfigProvider.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleDeclarations.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNodeProperties.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleMethods.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectPackage.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleScanner.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleSource.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleViewFilter.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs
Removed:
vs-plugin/trunk/Nemerle.VsIntegration/EditorFactory.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleAuthoringSink.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleConfigProvider.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleDeclarations.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleFileNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleFileNodeProperties.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleMethods.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleScanner.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleSource.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleViewFilter.cs
vs-plugin/trunk/Nemerle.VsIntegration/SelectionElementValueChangedListener.cs
Modified:
vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs
vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj
vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectFactory.cs
vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/RegisterSnippetsAttribute.cs
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Engine/ProjectInfo.cs Fri Sep 22 06:22:40 2006
@@ -16,6 +16,7 @@
using Utils = Nemerle.VsIntegration.Project.Utils;
using Microsoft.VisualStudio;
using Nemerle.VsIntegration;
+using Nemerle.VisualStudio.Package;
namespace Microsoft.Samples.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 Fri Sep 22 06:22:40 2006
@@ -77,17 +77,17 @@
<Compile Include="LibraryNode.cs" />
<Compile Include="NemerleColorableItem.cs" />
<Compile Include="NemerleConstants.cs" />
- <Compile Include="NemerleDeclarations.cs" />
+ <Compile Include="Package\NemerleDeclarations.cs" />
<Compile Include="Package\NemerleLanguageService.cs" />
<Compile Include="Package\NemerleAuthoringScope.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="NemerleLibraryManager.cs" />
<Compile Include="NemerleLibraryNode.cs" />
- <Compile Include="NemerleMethods.cs" />
- <Compile Include="NemerlePackage.cs" />
- <Compile Include="NemerleScanner.cs" />
- <Compile Include="NemerleSource.cs" />
- <Compile Include="NemerleViewFilter.cs" />
+ <Compile Include="Package\NemerleMethods.cs" />
+ <Compile Include="Package\NemerleProjectPackage.cs" />
+ <Compile Include="Package\NemerleScanner.cs" />
+ <Compile Include="Package\NemerleSource.cs" />
+ <Compile Include="Package\NemerleViewFilter.cs" />
<Compile Include="RegisterSnippetsAttribute.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
@@ -136,10 +136,10 @@
<Link>RegistrationAttributes\WebSiteProjectRelatedFilesAttribute.cs</Link>
</Compile>
<Compile Include="Package\Automation\NemerleOAFileItem.cs" />
- <Compile Include="NemerleAuthoringSink.cs" />
+ <Compile Include="Package\NemerleAuthoringSink.cs" />
<Compile Include="Utils.cs" />
<Compile Include="ConfigurationPropertyPages.cs" />
- <Compile Include="EditorFactory.cs" />
+ <Compile Include="Package\NemerleEditorFactory.cs" />
<Compile Include="FileCodeModel\CodeClassElement.cs" />
<Compile Include="FileCodeModel\CodeDomUtils.cs" />
<Compile Include="FileCodeModel\CodeElementBase.cs" />
@@ -157,13 +157,13 @@
<Compile Include="FileCodeModel\NemerleFileCodeModel.cs" />
<Compile Include="Package\NemerleProjectFactory.cs" />
<Compile Include="PropertyPages.cs" />
- <Compile Include="NemerleConfigProvider.cs" />
- <Compile Include="NemerleFileNode.cs" />
- <Compile Include="NemerleFileNodeProperties.cs" />
+ <Compile Include="Package\NemerleConfigProvider.cs" />
+ <Compile Include="Package\NemerleFileNode.cs" />
+ <Compile Include="Package\NemerleFileNodeProperties.cs" />
<Compile Include="NemerleMenus.cs" />
<Compile Include="Package\NemerleProjectNodeProperties.cs" />
<Compile Include="Resources.cs" />
- <Compile Include="SelectionElementValueChangedListener.cs" />
+ <Compile Include="Package\SelectionElementValueChangedListener.cs" />
<Compile Include="VSMDNemerleProvider.cs" />
<Compile Include="$(CommonRegAttributes)\SingleFileGeneratorSupportRegistrationAttribute.cs">
<Link>RegistrationAttributes\SingleFileGeneratorSupportRegistrationAttribute.cs</Link>
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleLibraryNode.cs Fri Sep 22 06:22:40 2006
@@ -15,6 +15,7 @@
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TextManager.Interop;
+using Nemerle.VisualStudio.Package;
namespace Microsoft.Samples.VisualStudio.LanguageService
{
@@ -183,7 +184,7 @@
{
// Get a reference to the RDT.
IVsRunningDocumentTable rdt =
- NemerlePackage.GetGlobalService(typeof (SVsRunningDocumentTable)) as
+ NemerleProjectPackage.GetGlobalService(typeof (SVsRunningDocumentTable)) as
IVsRunningDocumentTable;
if (null == rdt)
return IntPtr.Zero;
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleAuthoringSink.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleAuthoringSink.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,28 @@
+using System;
+
+using Microsoft.VisualStudio.Package;
+
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+namespace Nemerle.VisualStudio.Package
+{
+ public class NemerleAuthoringSink : AuthoringSink
+ {
+ public NemerleAuthoringSink(
+ NemerleSource source,
+ ParseReason reason,
+ int line,
+ int col,
+ int maxErrors)
+ : base(reason, line, col, maxErrors)
+ {
+ _source = source;
+ }
+
+ private NemerleSource _source;
+ public NemerleSource Source
+ {
+ get { return _source; }
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleConfigProvider.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleConfigProvider.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,50 @@
+using System;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Package;
+
+namespace Nemerle.VisualStudio.Package
+{
+ /// <summary>
+ /// Enables the Any CPU Platform form name for Nemerle Projects
+ /// </summary>
+ [ComVisible(true), CLSCompliant(false)]
+ public class NemerleConfigProvider : ConfigProvider
+ {
+ #region ctors
+
+ public NemerleConfigProvider(ProjectNode manager)
+ : base(manager)
+ {
+ }
+
+ #endregion
+
+ #region Overridden Methods
+
+ public override int GetPlatformNames(uint celt, string[] names, uint[] actual)
+ {
+ if (names != null)
+ names[0] = "Any CPU";
+
+ if (actual != null)
+ actual[0] = 1;
+
+ return VSConstants.S_OK;
+ }
+
+ public override int GetSupportedPlatformNames(uint celt, string[] names, uint[] actual)
+ {
+ if (names != null)
+ names[0] = "Any CPU";
+
+ if (actual != null)
+ actual[0] = 1;
+
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleDeclarations.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleDeclarations.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Nemerle.Completion2;
+
+namespace Nemerle.VisualStudio.Package
+{
+ public class NemerleDeclarations : Declarations
+ {
+ readonly CompletionElem[] _overloadPossibility;
+
+ public NemerleDeclarations(CompletionElem[] overloadPossibility)
+ {
+ _overloadPossibility = overloadPossibility;
+ Sort();
+ }
+
+ [SuppressMessage("Microsoft.Design", "CA1024")]
+ public override int GetCount()
+ {
+ return _overloadPossibility.Length;
+ }
+
+ public override string GetDisplayText(int index)
+ {
+ return _overloadPossibility[index].DisplayName;
+ }
+
+ public override string GetDescription(int index)
+ {
+ return _overloadPossibility[index].Description;
+ }
+
+ public override string GetName(int index)
+ {
+ return _overloadPossibility[index].DisplayName;
+ }
+
+ public override int GetGlyph(int index)
+ {
+ return _overloadPossibility[index].GlyphType;
+ }
+
+ class ByNameComparer : IComparer<CompletionElem>
+ {
+ public static readonly ByNameComparer Instace = new ByNameComparer();
+
+ public int Compare(CompletionElem x, CompletionElem y)
+ {
+ return x.DisplayName.CompareTo(y.DisplayName);
+ }
+ }
+
+ public void Sort()
+ {
+ Array.Sort(_overloadPossibility, ByNameComparer.Instace);
+ }
+
+ // This method is called to get the string to commit to the source buffer.
+ // 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)
+ {
+ // We intercept this call only to get the initial extent
+ // of what was committed to the source buffer.
+
+ //commitSpan = initialExtent;
+ return base.OnCommit(textView, textSoFar, commitCharacter, index,
+ ref initialExtent);
+ }
+
+ // This method is called after the string has been committed to the source buffer.
+ //
+ public override char OnAutoComplete(IVsTextView textView,
+ string committedText, char commitCharacter, int index)
+ {
+ //const char defaultReturnValue = '\0';
+ //Declaration item = declarations[index] as Declaration;
+ //if (item == null)
+ // return defaultReturnValue;
+
+ //// In this example, NemerleDeclaration identifies types with an enum.
+ //// You can choose a different approach.
+ //if (item.Type != Declaration.DeclarationType.Snippet)
+ // return defaultReturnValue;
+
+ //Source src = languageService.GetSource(textView);
+ //if (src == null)
+ // return defaultReturnValue;
+
+ //ExpansionProvider ep = src.GetExpansionProvider();
+ //if (ep == null)
+ // return defaultReturnValue;
+
+ //string title;
+ //string path;
+ //int commitLength = commitSpan.iEndIndex - commitSpan.iStartIndex;
+ //if (commitLength < committedText.Length)
+ //{
+ // // Replace everything that was inserted so calculate the span of the
+ // // full
+ // // insertion, taking into account what was inserted when the
+ // // commitSpan was obtained in the first place.
+ // commitSpan.iEndIndex += (committedText.Length - commitLength);
+ //}
+
+ //if (ep.FindExpansionByShortcut(textView, committedText, commitSpan,
+ // true, out title, out path) >= 0)
+ //{
+ // ep.InsertNamedExpansion(textView, title, path, commitSpan, false);
+ //}
+ //return defaultReturnValue;
+ //throw new NotImplementedException();
+
+ return base.OnAutoComplete(textView, committedText,
+ commitCharacter, index);
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleEditorFactory.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,349 @@
+using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Designer.Interfaces;
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
+
+namespace Nemerle.VisualStudio.Package
+{
+ [Guid(GlobalConstants.EditorFactoryGuidString)]
+ public class NemerlEditorFactory : IVsEditorFactory
+ {
+ #region ctors
+
+ public NemerlEditorFactory(NemerleProjectPackage package)
+ {
+ _package = package;
+ }
+
+ #endregion
+
+ #region Consts
+
+ internal static readonly Guid EditorFactoryGuid = new Guid(GlobalConstants.EditorFactoryGuidString);
+
+ #endregion
+
+ #region Fields
+
+ NemerleProjectPackage _package;
+ ServiceProvider _serviceProvider;
+
+ #endregion
+
+ #region IVsEditorFactory Members
+
+ public virtual int SetSite(IOleServiceProvider psp)
+ {
+ _serviceProvider = new ServiceProvider(psp);
+ return VSConstants.S_OK;
+ }
+
+ public virtual object GetService(Type serviceType)
+ {
+ return _serviceProvider.GetService(serviceType);
+ }
+
+ // This method is called by the Environment (inside IVsUIShellOpenDocument::
+ // OpenStandardEditor and OpenSpecificEditor) to map a LOGICAL view to a
+ // PHYSICAL view. A LOGICAL view identifies the purpose of the view that is
+ // desired (e.g. a view appropriate for Debugging [LOGVIEWID_Debugging], or a
+ // view appropriate for text view manipulation as by navigating to a find
+ // result [LOGVIEWID_TextView]). A PHYSICAL view identifies an actual type
+ // of view implementation that an IVsEditorFactory can create.
+ //
+ // NOTE: Physical views are identified by a string of your choice with the
+ // one constraint that the default/primary physical view for an editor
+ // *MUST* use a NULL string as its physical view name (*pbstrPhysicalView = NULL).
+ //
+ // NOTE: It is essential that the implementation of MapLogicalView properly
+ // validates that the LogicalView desired is actually supported by the editor.
+ // If an unsupported LogicalView is requested then E_NOTIMPL must be returned.
+ //
+ // NOTE: The special Logical Views supported by an Editor Factory must also
+ // be registered in the local registry hive. LOGVIEWID_Primary is implicitly
+ // supported by all editor types and does not need to be registered.
+ // For example, an editor that supports a ViewCode/ViewDesigner scenario
+ // might register something like the following:
+ // HKLM\Software\Microsoft\VisualStudio\8.0\Editors\
+ // {...guidEditor...}\
+ // LogicalViews\
+ // {...LOGVIEWID_TextView...} = s ''
+ // {...LOGVIEWID_Code...} = s ''
+ // {...LOGVIEWID_Debugging...} = s ''
+ // {...LOGVIEWID_Designer...} = s 'Form'
+ //
+ public virtual int MapLogicalView(ref Guid logicalView, out string physicalView)
+ {
+ // Initialize out parameter.
+ //
+ physicalView = null;
+
+ bool isSupportedView = false;
+
+ // Determine the physical view.
+ //
+ if (VSConstants.LOGVIEWID_Primary == logicalView)
+ {
+ // Primary view uses NULL as pbstrPhysicalView.
+ //
+ isSupportedView = true;
+ }
+ else if (VSConstants.LOGVIEWID_Designer == logicalView)
+ {
+ physicalView = "Design";
+ isSupportedView = true;
+ }
+
+ if (isSupportedView)
+ return VSConstants.S_OK;
+ else
+ // E_NOTIMPL must be returned for any unrecognized rguidLogicalView values
+ return VSConstants.E_NOTIMPL;
+ }
+
+ public virtual int Close()
+ {
+ return VSConstants.S_OK;
+ }
+
+ public virtual int CreateEditorInstance(
+ uint createEditorFlags,
+ string documentMoniker,
+ string physicalView,
+ IVsHierarchy hierarchy,
+ uint itemid,
+ IntPtr docDataExisting,
+ out IntPtr docView,
+ out IntPtr docData,
+ out string editorCaption,
+ out Guid commandUIGuid,
+ out int createDocumentWindowFlags)
+ {
+ // Initialize output parameters.
+ //
+ docView = IntPtr.Zero;
+ docData = IntPtr.Zero;
+ commandUIGuid = EditorFactoryGuid;
+ createDocumentWindowFlags = 0;
+ editorCaption = null;
+
+ // Validate inputs.
+ //
+ if ((createEditorFlags & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
+ return VSConstants.E_INVALIDARG;
+
+ // Get a text buffer.
+ //
+ IVsTextLines textLines = GetTextBuffer(docDataExisting);
+
+ // Assign docData IntPtr to either existing docData or the new text buffer.
+ //
+ if (docDataExisting != IntPtr.Zero)
+ {
+ docData = docDataExisting;
+ Marshal.AddRef(docData);
+ }
+ else
+ docData = Marshal.GetIUnknownForObject(textLines);
+
+ try
+ {
+ docView = CreateDocumentView(
+ physicalView, hierarchy, itemid, textLines, out editorCaption, out commandUIGuid);
+ }
+ finally
+ {
+ if (docView == IntPtr.Zero && docDataExisting != docData && docData != IntPtr.Zero)
+ {
+ // Cleanup the instance of the docData that we have addref'ed.
+ //
+ Marshal.Release(docData);
+ docData = IntPtr.Zero;
+ }
+ }
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ #region Helper methods
+
+ IVsTextLines GetTextBuffer(IntPtr docDataExisting)
+ {
+ IVsTextLines textLines;
+
+ if (docDataExisting == IntPtr.Zero)
+ {
+ // Create a new IVsTextLines buffer.
+ //
+ Type textLinesType = typeof(IVsTextLines);
+ Guid riid = textLinesType.GUID;
+ Guid clsid = typeof(VsTextBufferClass).GUID;
+ textLines = _package.CreateInstance(ref clsid, ref riid, textLinesType) as IVsTextLines;
+
+ // Set the buffer's site/
+ //
+ ((IObjectWithSite)textLines).SetSite(_serviceProvider.GetService(typeof(IOleServiceProvider)));
+ }
+ else
+ {
+ // Use the existing text buffer.
+ //
+ Object dataObject = Marshal.GetObjectForIUnknown(docDataExisting);
+
+ textLines = dataObject as IVsTextLines;
+
+ if (textLines == null)
+ {
+ // Try get the text buffer from textbuffer provider.
+ //
+ IVsTextBufferProvider textBufferProvider = dataObject as IVsTextBufferProvider;
+
+ if (textBufferProvider != null)
+ textBufferProvider.GetTextBuffer(out textLines);
+ }
+
+ if (textLines == null)
+ // Unknown docData type then, so we have to force VS to close the other editor.
+ //
+ NativeMethods.ThrowOnFailure(NativeMethods.VS_E_INCOMPATIBLEDOCDATA);
+ }
+
+ return textLines;
+ }
+
+ IntPtr CreateDocumentView(
+ string physicalView,
+ IVsHierarchy hierarchy,
+ uint itemid,
+ IVsTextLines textLines,
+ out string editorCaption,
+ out Guid cmdUI)
+ {
+ // Init out params.
+ //
+ editorCaption = string.Empty;
+ cmdUI = Guid.Empty;
+
+ if (string.IsNullOrEmpty(physicalView))
+ {
+ // Create code window as default physical view.
+ //
+ return CreateCodeView(textLines, ref editorCaption, ref cmdUI);
+ }
+ else if (string.Compare(physicalView, "design", true, CultureInfo.InvariantCulture) == 0)
+ {
+ // Create Form view.
+ //
+ return CreateFormView(hierarchy, itemid, textLines, ref editorCaption, ref cmdUI);
+ }
+
+ // We couldn't create the view.
+ // Return special error code so VS can try another editor factory.
+ //
+ NativeMethods.ThrowOnFailure(NativeMethods.VS_E_UNSUPPORTEDFORMAT);
+
+ return IntPtr.Zero;
+ }
+
+ IntPtr CreateFormView(
+ IVsHierarchy hierarchy,
+ uint itemid,
+ IVsTextLines textLines,
+ ref string editorCaption,
+ ref Guid cmdUI)
+ {
+ // Request the Designer Service.
+ //
+ IVSMDDesignerService designerService = (IVSMDDesignerService)GetService(typeof(IVSMDDesignerService));
+
+ // Create loader for the designer.
+ //
+ IVSMDDesignerLoader designerLoader =
+ (IVSMDDesignerLoader)designerService.CreateDesignerLoader(
+ "Microsoft.VisualStudio.Designer.Serialization.VSDesignerLoader");
+
+ bool loaderInitalized = false;
+
+ try
+ {
+ // Initialize designer loader.
+ //
+ designerLoader.Initialize(
+ _serviceProvider.GetService(typeof(IOleServiceProvider)), hierarchy, (int)itemid, textLines);
+
+ loaderInitalized = true;
+
+ // Create the designer.
+ //
+ IVSMDDesigner designer = designerService.CreateDesigner(
+ _serviceProvider.GetService(typeof (IOleServiceProvider)), designerLoader);
+
+ // Get editor caption.
+ //
+ editorCaption = designerLoader.GetEditorCaption((int)READONLYSTATUS.ROSTATUS_Unknown);
+
+ // Get view from designer.
+ //
+ object docView = designer.View;
+
+ // Get command guid from designer.
+ //
+ cmdUI = designer.CommandGuid;
+
+ /*
+ IVSMDCodeDomCreator codeDomCreator = designerService as IVSMDCodeDomCreator;
+
+ if(codeDomCreator != null)
+ {
+ IVSMDCodeDomProvider codeDomProvider = codeDomCreator.CreateCodeDomProvider(hierarchy, (int)itemid);
+
+ IServiceContainer serviceContainer = (IServiceContainer)GetService(typeof(IServiceContainer));
+ if(serviceContainer != null)
+ serviceContainer.AddService(typeof(CodeDomProvider), codeDomProvider);
+ }
+ */
+
+ return Marshal.GetIUnknownForObject(docView);
+ }
+ catch
+ {
+ // The designer loader may have created a reference to the shell or the text buffer.
+ // In case we fail to create the designer we should manually dispose the loader
+ // in order to release the references to the shell and the textbuffer.
+ //
+ if (loaderInitalized)
+ designerLoader.Dispose();
+ throw;
+ }
+ }
+
+ IntPtr CreateCodeView(IVsTextLines textLines, ref string editorCaption, ref Guid cmdUI)
+ {
+ Type codeWindowType = typeof(IVsCodeWindow);
+ Guid riid = codeWindowType.GUID;
+ Guid clsid = typeof(VsCodeWindowClass).GUID;
+ IVsCodeWindow window = (IVsCodeWindow)_package.CreateInstance(ref clsid, ref riid, codeWindowType);
+
+ NativeMethods.ThrowOnFailure(window.SetBuffer(textLines));
+ NativeMethods.ThrowOnFailure(window.SetBaseEditorCaption(null));
+ NativeMethods.ThrowOnFailure(window.GetEditorCaption(READONLYSTATUS.ROSTATUS_Unknown, out editorCaption));
+
+ cmdUI = NativeMethods.GUID_TextEditorFactory;
+
+ return Marshal.GetIUnknownForObject(window);
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNode.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNode.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,213 @@
+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 IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
+using VsCommands = Microsoft.VisualStudio.VSConstants.VSStd97CmdID;
+using VsMenus = Microsoft.VisualStudio.Shell.VsMenus;
+
+namespace Nemerle.VisualStudio.Package
+{
+ 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/Package/NemerleFileNodeProperties.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleFileNodeProperties.cs Fri Sep 22 06:22:40 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.Package
+{
+ [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
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleMethods.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleMethods.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+
+using Microsoft.VisualStudio.Package;
+
+using Nemerle.Completion2;
+using Nemerle.Builtins;
+using Nemerle.Compiler;
+
+namespace Nemerle.VisualStudio.Package
+{
+ public class NemerleMethods : Methods
+ {
+ public NemerleMethods(MethodTipInfo info)
+ {
+ _info = info;
+ }
+
+ MethodTipInfo _info;
+
+ public override int GetCount()
+ {
+ return _info.GetCount();
+ }
+
+ public override string Delimiter { get { return ", "; } }
+ public override bool TypePrefixed { get { return false; } }
+ public override string TypePrefix { get { return ": "; } }
+
+ public override int DefaultMethod
+ {
+ get { return _info.DefaultMethod; }
+ }
+
+ public override string GetDescription(int index)
+ {
+ return _info.GetDescription(index);
+ }
+
+ public override string GetType(int index)
+ {
+ return _info.GetType(index);
+ }
+
+ public override int GetParameterCount(int index)
+ {
+ return _info.GetParameterCount(index);
+ }
+
+ public override void GetParameterInfo(int index, int parameter,
+ out string name, out string display, out string description)
+ {
+ Tuple<string,string,string> info = _info.GetParameterInfo(index, parameter);
+
+ name = info.field0;
+ display = info.field1;
+ description = info.field2;
+ }
+
+ public override string GetName(int index)
+ {
+ return _info.GetName(index);
+ }
+
+ public Location StartName { get { return _info.StartName; } }
+ public Location StartParameters { get { return _info.StartParameters; } }
+ public List<Location> NextParameters { get { return _info.NextParameters; } }
+ public Location EndParameters { get { return _info.EndParameters; } }
+ }
+}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectFactory.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectFactory.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectFactory.cs Fri Sep 22 06:22:40 2006
@@ -12,7 +12,7 @@
[Guid(GlobalConstants.ProjectFactoryViewGuidString)]
public class NemerleProjectFactory : ProjectFactory
{
- public NemerleProjectFactory(NemerlePackage package)
+ public NemerleProjectFactory(NemerleProjectPackage package)
: base(package)
{
}
@@ -23,7 +23,7 @@
IOleServiceProvider oleServiceProvider =
(IOleServiceProvider)provider.GetService(typeof(IOleServiceProvider));
- ProjectNode project = new NemerleProjectNode((NemerlePackage)Package);
+ ProjectNode project = new NemerleProjectNode((NemerleProjectPackage)Package);
project.SetSite(oleServiceProvider);
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectNode.cs Fri Sep 22 06:22:40 2006
@@ -26,12 +26,12 @@
[Guid(GlobalConstants.ProjectNodeGuidString)]
public class NemerleProjectNode : ProjectNode, IVsProjectSpecificEditorMap2
{
- NemerlePackage _package;
+ NemerleProjectPackage _package;
static ImageList _nemerleImageList = LoadProjectImajeList();
#region ctor
- public NemerleProjectNode(NemerlePackage pkg)
+ public NemerleProjectNode(NemerleProjectPackage pkg)
{
_package = pkg;
@@ -529,7 +529,7 @@
// Nemerle only makes usage of one Editor Factory and therefore
// we will return that guid.
//
- guidEditorType = Nemerle.VsIntegration.Project.EditorFactory.guidEditorFactory;
+ guidEditorType = NemerlEditorFactory.EditorFactoryGuid;
return VSConstants.S_OK;
}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectPackage.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleProjectPackage.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,346 @@
+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;
+
+namespace Nemerle.VisualStudio.Package
+{
+ #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 NemerleProjectPackage : ProjectPackage/*Package*/, IOleComponent, IVsInstalledProduct
+ {
+ private uint _componentID;
+ private NemerleLibraryManager _libraryManager;
+
+ #region Initialize
+
+ public NemerleProjectPackage()
+ {
+ 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
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleScanner.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleScanner.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,155 @@
+using System;
+
+using Microsoft.VisualStudio.Package;
+
+using Nemerle.Compiler;
+
+namespace Nemerle.VisualStudio.Package
+{
+ class NemerleScanner : IScanner
+ {
+ static LexerHack _Root = new LexerHack();
+
+ public NemerleScanner()
+ {
+ _lexer = _Root.lexer;
+ }
+
+ private LexerColorizer _lexer;
+ private string _source;
+ private LexerColorizer.SyntaxToken _prevToken;
+
+ enum TC
+ {
+ Text = TokenColor.Text,
+ Keyword = TokenColor.Keyword,
+ Comment = TokenColor.Comment,
+ Identifier = TokenColor.Identifier,
+ String = TokenColor.String,
+ Number = TokenColor.Number,
+ Operator = 7,
+ }
+
+ // Its calling depends on IVsColorizer.GetStateMaintenanceFlag, which defaults to true.
+ //
+ public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
+ {
+ LexerColorizer.SyntaxToken token = _lexer.GetSyntaxToken(ref state);
+
+ // TokenInfo is only read in *.LanguageService.dll
+ //
+ tokenInfo.Trigger = TokenTriggers.None;
+ tokenInfo.StartIndex = token.StartPos;
+ tokenInfo.EndIndex = token.EndPos;
+
+ //TODO: it has to handle # (pragma, region, etc)
+
+ switch (token.Token)
+ {
+ case SyntaxType.WhiteSpace:
+ tokenInfo.Color = TokenColor.Text;
+ tokenInfo.Type = TokenType. WhiteSpace;
+
+ if (_prevToken != null) switch (_prevToken.Token)
+ {
+ case SyntaxType.Keyword:
+ if (_source == "using ")
+ tokenInfo.Trigger = TokenTriggers.MemberSelect;
+
+ break;
+
+ case SyntaxType.Operator:
+ switch (_source[_prevToken.StartPos])
+ {
+ case '|': tokenInfo.Trigger = TokenTriggers.MemberSelect; break;
+ }
+
+ break;
+ }
+
+ break;
+
+ case SyntaxType.OperatorBrace:
+ tokenInfo.Color = (TokenColor)TC.Operator;
+ tokenInfo.Type = TokenType.Operator;
+ tokenInfo.Trigger = TokenTriggers.MatchBraces;
+
+ switch (_source[token.StartPos])
+ {
+ case '(': tokenInfo.Trigger |= TokenTriggers.ParameterStart; break;
+ //case ')': tokenInfo.Trigger |= TokenTriggers.ParameterEnd; break;
+ }
+
+ break;
+
+ case SyntaxType.Operator:
+ tokenInfo.Color = (TokenColor)TC.Operator;
+ tokenInfo.Type = TokenType.Operator;
+
+ //switch (_source[token.StartPos])
+ //{
+ // case ',': tokenInfo.Trigger |= TokenTriggers.ParameterNext; break;
+ //}
+
+ break;
+
+ case SyntaxType.OperatorDot:
+ tokenInfo.Color = (TokenColor)TC.Operator;
+ tokenInfo.Type = TokenType.Operator;
+ tokenInfo.Trigger = TokenTriggers.MemberSelect;
+ break;
+
+ case SyntaxType.Keyword:
+ tokenInfo.Color = TokenColor.Keyword;
+ tokenInfo.Type = TokenType .Keyword;
+ break;
+
+ case SyntaxType.Identifier:
+ tokenInfo.Color = TokenColor.Identifier;
+ tokenInfo.Type = TokenType. Identifier;
+ break;
+
+ case SyntaxType.Comment:
+ tokenInfo.Color = TokenColor.Comment;
+ tokenInfo.Type = state == 0? TokenType.LineComment : TokenType.Comment;
+ break;
+
+ case SyntaxType.CharLiteral:
+ tokenInfo.Color = TokenColor.String;
+ tokenInfo.Type = TokenType. Literal;
+ break;
+
+ case SyntaxType.IntLiteral:
+ case SyntaxType.FloatLiteral:
+ tokenInfo.Color = TokenColor.Number;
+ tokenInfo.Type = TokenType. Literal;
+ break;
+
+ case SyntaxType.StringLiteral:
+ tokenInfo.Color = TokenColor.String;
+ tokenInfo.Type = TokenType. String;
+ break;
+
+ default:
+ tokenInfo.Color = TokenColor.Text;
+ tokenInfo.Type = TokenType. Text;
+ break;
+
+ case SyntaxType.EndOfFile:
+ return false;
+ }
+
+ _prevToken = token;
+
+ return true;
+ }
+
+ // The current implementation in *.LanguageService.dll always uses offset 0.
+ //
+ public void SetSource(string source, int offset)
+ {
+ _prevToken = null;
+ _lexer.SetString(_source = source, offset);
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleSource.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleSource.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,347 @@
+using System;
+using System.Collections.Generic;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+
+using Microsoft.Samples.VisualStudio.LanguageService;
+
+namespace Nemerle.VisualStudio.Package
+{
+ public delegate AuthoringScope ScopeCreatorCallback(ParseRequest request);
+
+ public class NemerleSource : Source
+ {
+ ScopeCreatorCallback scopeCreator;
+
+ public NemerleSource(NemerleLanguageService service, IVsTextLines textLines,
+ Colorizer colorizer) : base(service, textLines, colorizer) {}
+
+ public override CommentInfo GetCommentFormat()
+ {
+ CommentInfo commentInfo = new CommentInfo();
+
+ commentInfo.UseLineComments = true;
+ commentInfo.LineStart = "//";
+ commentInfo.BlockStart = "/*";
+ commentInfo.BlockEnd = "*/";
+
+ return commentInfo;
+ }
+
+ public ScopeCreatorCallback ScopeCreator
+ {
+ get { return scopeCreator; }
+ set { scopeCreator = value; }
+ }
+
+ public override void Completion(IVsTextView textView, TokenInfo info, ParseReason reason)
+ {
+ base.Completion(textView, info, reason);
+ }
+
+ public override void OnChangeLineText(TextLineChange[] lineChange, int last)
+ {
+ //TODO: Ńţäŕ íóćíî âńňŕâčňü ęîä îáíîâë˙ţůčé ëîęĺéřîíű â äĺđĺâĺ ňčďîâ ĺńëč đĺäŕęňčđîâŕíčĺ
+ // ďđîčńőîäčň âíóňđč âűđŕćĺíčé č îáíóë˙ňü äĺđĺâî ňčďîâ â îáđŕňîíîě ńëó÷ŕĺ.
+ // Ĺńëč äĺđĺâî ňčďîâ íĺň, ňî íč÷ĺăî íĺ äĺëŕĺě.
+
+ string fileName = GetFilePath();
+ ProjectInfo projectInfo = ProjectInfo.FindProject(fileName);
+
+ for (int i = 0; i < lineChange.Length; i++)
+ {
+ TextLineChange changes = ConvertToLocation(lineChange[i]);
+
+ projectInfo.AddRelocation(
+ fileName,
+ changes.iNewEndIndex,
+ changes.iNewEndLine,
+ changes.iOldEndIndex,
+ changes.iOldEndLine,
+ changes.iStartIndex,
+ changes.iStartLine);
+ }
+
+ base.OnChangeLineText(lineChange, last);
+ }
+
+ private static TextLineChange ConvertToLocation(TextLineChange changes)
+ {
+ changes.iNewEndIndex++;
+ changes.iNewEndLine++;
+ changes.iOldEndIndex++;
+ changes.iOldEndLine++;
+ changes.iStartIndex++;
+ changes.iStartLine++;
+
+ return changes;
+ }
+
+ internal class ErrorNode
+ {
+ public string Uri;
+ public string Message;
+ public TextSpan Context;
+ public Severity Severity;
+
+ public ErrorNode(string uri, string message, TextSpan context, Severity severity)
+ {
+ Uri = uri;
+ Message = message;
+ Context = context;
+ Severity = severity;
+ }
+ }
+
+ internal void ReportMessage(IList<ErrorNode> errors)
+ {
+ TaskProvider taskProvider = GetTaskProvider();
+
+ if (errors == null || errors.Count == 0)
+ {
+ if (taskProvider.Tasks.Count > 0)
+ taskProvider.Tasks.Clear();
+
+ return;
+ }
+
+ int removed = 0;
+ int added = 0;
+ int merged = 0;
+ int errorMax = LanguageService.Preferences.MaxErrorMessages;
+ string fname = GetFilePath();
+
+ RunningDocumentTable rdt = new RunningDocumentTable(LanguageService.Site);
+ IVsHierarchy thisHeirarchy = rdt.GetHierarchyItem(fname);
+
+ // Here we merge errors lists to reduce flicker. It is not a very intelligent merge
+ // but that is ok, the worst case is the task list flickers a bit. But 99% of the time
+ // one error is added or removed as the user is typing, and this merge will reduce flicker
+ // in this case.
+ //
+ taskProvider.SuspendRefresh(); // batch updates.
+
+ try
+ {
+ int pos = 0;
+
+ TaskErrorCategory mostSevere = TaskErrorCategory.Message;
+
+ for (int i = 0, n = errors.Count; i < n; i++)
+ {
+ ErrorNode enode = errors[i];
+ string filename = enode.Uri;
+ bool thisFile = !string.IsNullOrEmpty(filename) && NativeMethods.IsSamePath(fname, filename);
+ TextSpan span = enode.Context;
+ Severity severity = enode.Severity;
+ string message = enode.Message;
+
+ if (message == null)
+ continue;
+
+ // Don't do multi-line squiggles, instead just squiggle to the
+ // end of the first line.
+ //
+ if (span.iEndLine > span.iStartLine)
+ {
+ span.iEndLine = span.iStartLine;
+ NativeMethods.ThrowOnFailure(GetTextLines().GetLengthOfLine(span.iStartLine, out span.iEndIndex));
+ }
+
+ // Normalize text span.
+ //
+ if (thisFile)
+ FixupMarkerSpan(ref span);
+ else
+ TextSpanHelper.MakePositive(ref span);
+
+ // Set options.
+ //
+ TaskPriority priority = TaskPriority.Normal;
+ TaskCategory category = TaskCategory.BuildCompile;
+ MARKERTYPE markerType = MARKERTYPE.MARKER_CODESENSE_ERROR;
+ TaskErrorCategory errorCategory = TaskErrorCategory.Warning;
+
+ if (severity == Severity.Fatal || severity == Severity.Error)
+ {
+ priority = TaskPriority.High;
+ errorCategory = TaskErrorCategory.Error;
+ }
+ else if (severity == Severity.Hint)
+ {
+ category = TaskCategory.Comments;
+ markerType = MARKERTYPE.MARKER_INVISIBLE;
+ errorCategory = TaskErrorCategory.Message;
+ }
+ else if (severity == Severity.Warning)
+ {
+ markerType = MARKERTYPE.MARKER_COMPILE_ERROR;
+ errorCategory = TaskErrorCategory.Warning;
+ }
+
+ if (errorCategory < mostSevere)
+ mostSevere = errorCategory;
+
+ IVsHierarchy hierarchy = thisHeirarchy;
+
+ if (!thisFile)
+ {
+ // Must be an error reference to another file.
+ //
+ hierarchy = rdt.GetHierarchyItem(filename);
+ markerType = MARKERTYPE.MARKER_OTHER_ERROR; // indicate to CreateErrorTaskItem
+ }
+
+ bool found = false;
+
+ while (pos < taskProvider.Tasks.Count)
+ {
+ Task current = taskProvider.Tasks[pos];
+
+ if (current is DocumentTask)
+ {
+ DocumentTask dt = (DocumentTask)current;
+
+ if (dt.IsMarkerValid && // marker is still valid?
+ NativeMethods.IsSamePath(current.Document, filename) &&
+ current.Text == message && TextSpanHelper.IsSameSpan(span, dt.Span) &&
+ current.Category == category &&
+ current.Priority == priority &&
+ dt.ErrorCategory == errorCategory)
+ {
+ pos++;
+ merged++;
+ found = true;
+
+ // Since we're reusing the existing entry, let's make sure the line
+ // line number we are displaying the right line number information.
+ // (The DocumentTask gets out of sync with the IVsTextLineMarker because
+ // the IVsTextLineMarker is a bookmark that tracks user edits).
+ //
+ if (dt.Column != span.iStartIndex || dt.Line != span.iStartLine)
+ {
+ dt.Column = span.iStartIndex;
+ dt.Line = span.iStartLine;
+ taskProvider.Refresh(); // mark it as dirty.
+ }
+ break;
+ }
+ }
+
+ removed++;
+ taskProvider.Tasks.RemoveAt(pos);
+ }
+
+ if (!found)
+ {
+ added++;
+
+ DocumentTask docTask = CreateErrorTaskItem(
+ span, filename, message, priority, category, markerType, errorCategory);
+
+ docTask.HierarchyItem = hierarchy;
+
+ taskProvider.Tasks.Insert(pos, docTask);
+
+ pos++;
+ }
+
+ // Check error count.
+ //
+ if (pos == errorMax)
+ {
+ string maxMsg = "MaxErrorsReached";
+ string localFile = GetFilePath();
+
+ span = GetDocumentSpan();
+ span.iStartIndex = span.iEndIndex;
+ span.iStartLine = span.iEndLine;
+
+ DocumentTask error = CreateErrorTaskItem(
+ span,
+ localFile,
+ maxMsg,
+ TaskPriority.High,
+ TaskCategory.CodeSense,
+ MARKERTYPE.MARKER_INVISIBLE, mostSevere);
+
+ error.HierarchyItem = hierarchy;
+
+ taskProvider.Tasks.Insert(pos, error);
+ pos++;
+
+ break;
+ }
+ }
+
+ // Remove trailing errors that should no longer exist.
+ //
+ while (pos < taskProvider.Tasks.Count)
+ {
+ removed++;
+ taskProvider.Tasks.RemoveAt(pos);
+ }
+ }
+ finally
+ {
+ taskProvider.ResumeRefresh(); // batch updates.
+ }
+ }
+
+ internal void FixupMarkerSpan(ref TextSpan span)
+ {
+ // This is similar to TextSpanHelper.Normalize except that
+ // we try not to create empty spans at end of line, since VS doesn't like
+ // empty spans for text markers. See comment in CreateMaker in DocumentTask.cs
+
+ // Adjust max. lines.
+ //
+ int lineCount;
+
+ if (NativeMethods.Failed(GetTextLines().GetLineCount(out lineCount)))
+ return;
+
+ span.iEndLine = Math.Min(span.iEndLine, lineCount - 1);
+
+ // Make sure the start is still before the end.
+ //
+ if (!TextSpanHelper.IsPositive(span))
+ {
+ span.iStartLine = span.iEndLine;
+ span.iStartIndex = span.iEndIndex;
+ }
+
+ // Adjust for line length.
+ //
+ int lineLength;
+
+ if (NativeMethods.Failed(GetTextLines().GetLengthOfLine(span.iStartLine, out lineLength)))
+ return;
+
+ span.iStartIndex = Math.Min(span.iStartIndex, lineLength);
+
+ if (NativeMethods.Failed(GetTextLines().GetLengthOfLine(span.iEndLine, out lineLength)))
+ return;
+
+ span.iEndIndex = Math.Min(span.iEndIndex, lineLength);
+
+ if (TextSpanHelper.IsEmpty(span) && span.iStartIndex == lineLength && span.iEndLine + 1 < lineCount)
+ {
+ // Make the span include the newline if it was empty and at the end of the line.
+ //
+ span.iEndLine++;
+ span.iEndIndex = 0;
+ }
+ }
+
+ public override AuthoringSink CreateAuthoringSink(ParseReason reason, int line, int col)
+ {
+ int maxErrors = LanguageService.Preferences.MaxErrorMessages;
+ return new NemerleAuthoringSink(this, reason, line, col, maxErrors);
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleViewFilter.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/NemerleViewFilter.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,61 @@
+using System;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Nemerle.VsIntegration;
+
+namespace Nemerle.VisualStudio.Package
+{
+ class NemerleViewFilter : ViewFilter
+ {
+ public NemerleViewFilter(CodeWindowManager mgr, IVsTextView view)
+ : base(mgr, view)
+ {
+ }
+
+ protected override int QueryCommandStatus(ref Guid guidCmdGroup, uint nCmdId)
+ {
+ if (guidCmdGroup == VSConstants.VSStd2K &&
+ nCmdId == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET ||
+ nCmdId == (uint)VSConstants.VSStd2KCmdID.SURROUNDWITH)
+ {
+ return (int)(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED);
+ }
+
+ return base.QueryCommandStatus(ref guidCmdGroup, nCmdId);
+ }
+
+ public override bool HandlePreExec(
+ ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
+ {
+ if (guidCmdGroup == VSConstants.VSStd2K)
+ {
+ if (nCmdId == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET)
+ {
+ ExpansionProvider ep = GetExpansionProvider();
+
+ if (TextView != null && ep != null)
+ ep.DisplayExpansionBrowser(TextView, Resources.InsertSnippet, null, false, null, false);
+
+ return true; // Handled the command.
+ }
+ else if (nCmdId == (uint)VSConstants.VSStd2KCmdID.SURROUNDWITH)
+ {
+ ExpansionProvider ep = GetExpansionProvider();
+
+ if (TextView != null && ep != null)
+ ep.DisplayExpansionBrowser(TextView, Resources.SurroundWith, null, false, null, false);
+
+ return true; // Handled the command.
+ }
+ }
+
+ // Base class handled the command. Do nothing more here.
+ //
+ return base.HandlePreExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut);
+ }
+ }
+}
\ No newline at end of file
Added: vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Package/SelectionElementValueChangedListener.cs Fri Sep 22 06:22:40 2006
@@ -0,0 +1,66 @@
+using System;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+
+namespace Nemerle.VisualStudio.Package
+{
+ public class SelectionElementValueChangedListener : SelectionListener
+ {
+ #region ctors
+
+ public SelectionElementValueChangedListener(
+ ServiceProvider serviceProvider, ProjectNode proj) : base(serviceProvider)
+ {
+ projMgr = proj;
+ }
+
+ #endregion
+
+ #region Fileds
+
+ ProjectNode projMgr;
+
+ #endregion
+
+ #region Overridden Methods
+
+ public override int OnElementValueChanged(uint elementid, object varValueOld, object varValueNew)
+ {
+ int hr = VSConstants.S_OK;
+
+ if (elementid == VSConstants.DocumentFrame)
+ {
+ IVsWindowFrame pWindowFrame = varValueOld as IVsWindowFrame;
+
+ if (pWindowFrame != null)
+ {
+ object document;
+
+ // Get the name of the document associated with the old window frame.
+ //
+ hr = pWindowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_pszMkDocument, out document);
+
+ if (ErrorHandler.Succeeded(hr))
+ {
+ uint itemid;
+ IVsHierarchy hier = projMgr;
+
+ hr = hier.ParseCanonicalName((string)document, out itemid);
+
+ NemerleFileNode node = projMgr.NodeFromItemId(itemid) as NemerleFileNode;
+
+ if (null != node)
+ node.RunGenerator((string)document);
+ }
+ }
+ }
+
+ return hr;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: vs-plugin/trunk/Nemerle.VsIntegration/RegisterSnippetsAttribute.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/RegisterSnippetsAttribute.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/RegisterSnippetsAttribute.cs Fri Sep 22 06:22:40 2006
@@ -14,8 +14,9 @@
using System.Globalization;
using System.IO;
using Microsoft.VisualStudio.Shell;
+using Microsoft.Samples.VisualStudio.LanguageService;
-namespace Microsoft.Samples.VisualStudio.LanguageService
+namespace Nemerle.VisualStudio.Shell
{
/// <summary>
/// This attribute registers code snippets for a package. The attributes on
More information about the svn
mailing list