[svn] r6704: vs-plugin/trunk/Nemerle.VsIntegration:
CodeSnippets/Snippets/class.snippet CodeSnippets/Snipp...
IT
svnadmin at nemerle.org
Sun Sep 24 22:58:04 CEST 2006
Log:
C# integration project refactoring.
Author: IT
Date: Sun Sep 24 22:57:34 2006
New Revision: 6704
Added:
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleMethods.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/SnippetsEnumerator.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/ConfigurationPropertyPages.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/HierarchyEventArgs.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/HierarchyListener.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleConfigProvider.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleEditorFactory.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleMenus.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleOAFileItem.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleTokenProcessor.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleVSMDCodeDomProvider.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/PropertyPages.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/ScopeNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/SelectionElementValueChangedListener.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/TextLineEventListener.cs
Removed:
vs-plugin/trunk/Nemerle.VsIntegration/ConfigurationPropertyPages.cs
vs-plugin/trunk/Nemerle.VsIntegration/Engine/
vs-plugin/trunk/Nemerle.VsIntegration/HierarchyListener.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerleMenus.cs
vs-plugin/trunk/Nemerle.VsIntegration/ObjectModelExtenders/
vs-plugin/trunk/Nemerle.VsIntegration/Package/
vs-plugin/trunk/Nemerle.VsIntegration/PropertyPages.cs
vs-plugin/trunk/Nemerle.VsIntegration/SnippetsEnumerator.cs
vs-plugin/trunk/Nemerle.VsIntegration/TextLineEventListener.cs
vs-plugin/trunk/Nemerle.VsIntegration/VSMDNemerleProvider.cs
Modified:
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/class.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/ctor.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/for.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/foreach.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/if.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/match.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/unless.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/when.snippet
vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/SnippetsIndex.xml
vs-plugin/trunk/Nemerle.VsIntegration/ErrorHelper.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeClassElement.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeDomUtils.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeElementBase.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeNamespaceElement.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeElement.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeFunctionMember.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeMemberElement.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeReferenceElement.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleCodeElements.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleFileCodeModel.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NullTextPoint.cs
vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/VoidCodeTypeRef.cs
vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleLanguageService.cs
vs-plugin/trunk/Nemerle.VsIntegration/Nemerle.VsIntegration.csproj
vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs
vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs
vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.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/Properties/AssemblyInfo.cs
vs-plugin/trunk/Nemerle.VsIntegration/RegisterSnippetsAttribute.cs
vs-plugin/trunk/Nemerle.VsIntegration/Resources.Designer.cs
vs-plugin/trunk/Nemerle.VsIntegration/Resources.cs
vs-plugin/trunk/Nemerle.VsIntegration/Utils.cs
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/class.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/class.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/class.snippet Sun Sep 24 22:57:34 2006
@@ -19,7 +19,7 @@
<Default>MyClass</Default>
</Literal>
</Declarations>
- <Code Language="nemerle">
+ <Code Language="Nemerle">
<![CDATA[internal class $name$
{
$selected$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/ctor.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/ctor.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/ctor.snippet Sun Sep 24 22:57:34 2006
@@ -11,7 +11,7 @@
</SnippetTypes>
</Header>
<Snippet>
- <Code Language="nemerle">
+ <Code Language="Nemerle">
<![CDATA[public this()
{
$selected$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/for.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/for.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/for.snippet Sun Sep 24 22:57:34 2006
@@ -25,7 +25,7 @@
</Literal>
</Declarations>
- <Code Language="nemerle">
+ <Code Language="Nemerle">
<![CDATA[for (mutable $index$ = 0; $index$ < $max$; $index$++)
{
$selected$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/foreach.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/foreach.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/foreach.snippet Sun Sep 24 22:57:34 2006
@@ -25,7 +25,7 @@
</Literal>
</Declarations>
- <Code Language="nemerle">
+ <Code Language="Nemerle">
<![CDATA[foreach ($elem$ in $Collection$)
{
$selected$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/if.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/if.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/if.snippet Sun Sep 24 22:57:34 2006
@@ -28,7 +28,7 @@
<ToolTip>Expression evaluated if condition is false.</ToolTip>
<Default>false</Default>
</Literal>
- </Declarations><Code Language="nemerle">
+ </Declarations><Code Language="Nemerle">
<![CDATA[if ($expression$) $selected$$TrueExpr$ else $FalseExpr$$end$]]>
</Code>
</Snippet>
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/match.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/match.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/match.snippet Sun Sep 24 22:57:34 2006
@@ -28,7 +28,8 @@
<ToolTip>Expression evaluated if pattern matched.</ToolTip>
<Default>()</Default>
</Literal>
- </Declarations><Code Language="nemerle">
+ </Declarations>
+ <Code Language="Nemerle">
<![CDATA[match ($expression$)
{
| $Pattern1$ => $selected$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/unless.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/unless.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/unless.snippet Sun Sep 24 22:57:34 2006
@@ -23,7 +23,8 @@
<ToolTip>Expression evaluated if condition is false.</ToolTip>
<Default>true</Default>
</Literal>
- </Declarations><Code Language="nemerle">
+ </Declarations>
+ <Code Language="Nemerle">
<![CDATA[unless ($expression$)
{
$selected$$Expr$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/when.snippet
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/when.snippet (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/Snippets/when.snippet Sun Sep 24 22:57:34 2006
@@ -23,7 +23,8 @@
<ToolTip>Expression evaluated if condition is true.</ToolTip>
<Default>true</Default>
</Literal>
- </Declarations><Code Language="nemerle">
+ </Declarations>
+ <Code Language="nemerle">
<![CDATA[when ($expression$)
{
$selected$$Expr$
Modified: vs-plugin/trunk/Nemerle.VsIntegration/CodeSnippets/SnippetsIndex.xml
==============================================================================
Modified: vs-plugin/trunk/Nemerle.VsIntegration/ErrorHelper.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/ErrorHelper.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/ErrorHelper.cs Sun Sep 24 22:57:34 2006
@@ -1,18 +1,19 @@
using System;
-/// <summary>
-/// A helper class for checking arguments.
-/// </summary>
-public static class ErrorHelper
+namespace Nemerle.VisualStudio
{
/// <summary>
+ /// A helper class for checking arguments.
+ /// </summary>
+ public static class ErrorHelper
+ {
+ /// <summary>
/// Throws ArgumentException when value is null or value isn't validType.
/// </summary>
/// <param name="value">test object.</param>
/// <param name="validType">valid type for test object.</param>
/// <param name="paramName">parameter name for ArgumentException.</param>
- public static void ThrowIsNullOrInvalidType(object value, Type validType,
- string paramName)
+ public static void ThrowIsNullOrInvalidType(object value, Type validType, string paramName)
{
ThrowIsNull(value, paramName);
@@ -20,8 +21,7 @@
if (!valueType.Equals(validType) && !validType.IsAssignableFrom(valueType))
throw new ArgumentException(
- String.Format("Expected '{0}' type, but receives '{1}' type.",
- validType, valueType), paramName);
+ String.Format("Expected '{0}' type, but receives '{1}' type.", validType, valueType), paramName);
}
/// <summary>
@@ -30,15 +30,13 @@
/// <param name="value">The value.</param>
/// <param name="validType">valid type for test object.</param>
/// <param name="paramName">parameter name for ArgumentException.</param>
- public static void ThrowIsNullOrInvalidType(Type value, Type validType,
- string paramName)
+ public static void ThrowIsNullOrInvalidType(Type value, Type validType, string paramName)
{
ThrowIsNull(value, paramName);
if (!value.Equals(validType) && !validType.IsAssignableFrom(value))
throw new ArgumentException(
- String.Format("Expected '{0}' type, but receives '{1}' type.",
- validType, value), paramName);
+ String.Format("Expected '{0}' type, but receives '{1}' type.", validType, value), paramName);
}
/// <summary>
@@ -48,7 +46,8 @@
/// <param name="paramName">parameter name for ArgumentException.</param>
public static void ThrowIsNullOrEmpty(string value, string paramName)
{
- // check for null or empty
+ // Check for null or empty.
+ //
if (String.IsNullOrEmpty(value))
throw new ArgumentException("String is null or empty .", paramName);
}
@@ -77,4 +76,5 @@
else
throw new ArgumentNullException(paramName, message);
}
+ }
}
\ No newline at end of file
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeClassElement.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeClassElement.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeClassElement.cs Sun Sep 24 22:57:34 2006
@@ -1,16 +1,23 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
+
using EnvDTE;
-using CodeNamespace=EnvDTE.CodeNamespace;
-namespace Microsoft.VisualStudio.Package.Automation
+using CodeNamespace = EnvDTE.CodeNamespace;
+
+namespace Nemerle.VisualStudio.FileCodeModel
{
- internal class CodeClassElement : CodeTypeElement, CodeClass
+ class CodeClassElement : CodeTypeElement, CodeClass
{
- public CodeClassElement(DTE dte, ProjectItem projectItem,
- CodeTypeDeclaration codeType, CodeElementBase parent)
- : base(dte, projectItem, codeType, parent) {}
+ public CodeClassElement(
+ DTE dte,
+ ProjectItem projectItem,
+ CodeTypeDeclaration codeType,
+ CodeElementBase parent)
+ : base(dte, projectItem, codeType, parent)
+ {
+ }
public override vsCMElement Kind
{
@@ -24,8 +31,7 @@
throw new NotImplementedException();
}
- CodeAttribute CodeClass.AddAttribute(string name, string value,
- object position)
+ CodeAttribute CodeClass.AddAttribute(string name, string value, object position)
{
throw new NotImplementedException();
}
@@ -40,50 +46,69 @@
throw new NotImplementedException();
}
- CodeInterface CodeClass.AddImplementedInterface(object Base,
- object Position)
+ CodeInterface CodeClass.AddImplementedInterface(object Base, object Position)
{
throw new NotImplementedException();
}
- CodeFunction CodeClass.AddFunction(string Name, vsCMFunction Kind,
- object Type, object Position, vsCMAccess Access, object Location)
+ CodeFunction CodeClass.AddFunction(
+ string Name,
+ vsCMFunction Kind,
+ object Type,
+ object Position,
+ vsCMAccess Access,
+ object Location)
{
throw new NotImplementedException();
}
- CodeVariable CodeClass.AddVariable(string Name, object Type,
- object Position, vsCMAccess Access, object Location)
+ CodeVariable CodeClass.AddVariable(
+ string Name,
+ object Type,
+ object Position,
+ vsCMAccess Access,
+ object Location)
{
throw new NotImplementedException();
}
- CodeProperty CodeClass.AddProperty(string GetterName, string PutterName,
- object Type, object Position, vsCMAccess Access, object Location)
+ CodeProperty CodeClass.AddProperty(
+ string GetterName,
+ string PutterName,
+ object Type,
+ object Position,
+ vsCMAccess Access,
+ object Location)
{
throw new NotImplementedException();
}
- CodeClass CodeClass.AddClass(string Name, object Position, object Bases,
- object ImplementedInterfaces, vsCMAccess Access)
+ CodeClass CodeClass.AddClass(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeStruct CodeClass.AddStruct(string Name, object Position, object Bases,
- object ImplementedInterfaces, vsCMAccess Access)
+ CodeStruct CodeClass.AddStruct(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeEnum CodeClass.AddEnum(string Name, object Position, object Bases,
- vsCMAccess Access)
+ CodeEnum CodeClass.AddEnum(string Name, object Position, object Bases, vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeDelegate CodeClass.AddDelegate(string Name, object Type,
- object Position, vsCMAccess Access)
+ CodeDelegate CodeClass.AddDelegate(string Name, object Type, object Position, vsCMAccess Access)
{
throw new NotImplementedException();
}
@@ -99,43 +124,33 @@
}
object CodeClass.Parent { get { return Parent; } }
- CodeNamespace CodeClass.Namespace
- {
- get { return Parent as CodeNamespace; }
- }
+ CodeNamespace CodeClass.Namespace { get { return Parent as CodeNamespace; } }
CodeElements CodeClass.Bases { get { return LoadBases(); } }
+ CodeElements CodeClass.Members { get { return LoadMembers(); } }
CodeElements LoadBases()
{
- List<CodeElement> elements =
- new List<CodeElement>(codeType.BaseTypes.Count);
+ List<CodeElement> elements = new List<CodeElement>(codeType.BaseTypes.Count);
+
foreach (CodeTypeReference typeReference in codeType.BaseTypes)
- elements.Add(
- new CodeTypeReferenceElement(DTE, ProjectItem, typeReference, this));
+ elements.Add(new CodeTypeReferenceElement(DTE, ProjectItem, typeReference, this));
return new NemerleCodeElements(DTE, ProjectItem, this, elements.ToArray());
}
- CodeElements CodeClass.Members { get { return LoadMembers(); } }
-
CodeElements LoadMembers()
{
List<CodeElement> elements = new List<CodeElement>(codeType.Members.Count);
foreach (CodeTypeMember member in codeType.Members)
- elements.Add(CodeTypeMemberElement.Create(DTE, ProjectItem, member,
- this));
+ elements.Add(CodeTypeMemberElement.Create(DTE, ProjectItem, member, this));
return new NemerleCodeElements(DTE, ProjectItem, this, elements.ToArray());
}
vsCMAccess CodeClass.Access
{
- get
- {
- return CodeDomUtils.GetCMAccess(
- codeType.Attributes & MemberAttributes.AccessMask);
- }
+ get { return CodeDomUtils.GetCMAccess(codeType.Attributes & MemberAttributes.AccessMask); }
set { throw new NotImplementedException(); }
}
@@ -170,15 +185,12 @@
{
get
{
- return (codeType.Attributes & MemberAttributes.Abstract)
- == MemberAttributes.Abstract;
+ return (codeType.Attributes & MemberAttributes.Abstract) == MemberAttributes.Abstract;
}
set
{
- if (value)
- codeType.Attributes |= MemberAttributes.Abstract;
- else
- codeType.Attributes ^= MemberAttributes.Abstract;
+ if (value) codeType.Attributes |= MemberAttributes.Abstract;
+ else codeType.Attributes ^= MemberAttributes.Abstract;
}
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeDomUtils.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeDomUtils.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeDomUtils.cs Sun Sep 24 22:57:34 2006
@@ -1,28 +1,24 @@
+using System;
using System.CodeDom;
+
using EnvDTE;
-class CodeDomUtils
+namespace Nemerle.VisualStudio.FileCodeModel
{
+ class CodeDomUtils
+ {
public static vsCMAccess GetCMAccess(MemberAttributes attributes)
{
switch (attributes)
{
- case MemberAttributes.Public:
- return vsCMAccess.vsCMAccessPublic;
-
- case MemberAttributes.Private:
- return vsCMAccess.vsCMAccessPrivate;
-
- case MemberAttributes.Assembly:
- return vsCMAccess.vsCMAccessProject;
-
- case MemberAttributes.Family:
- return vsCMAccess.vsCMAccessProtected;
-
- case MemberAttributes.FamilyOrAssembly:
- return vsCMAccess.vsCMAccessProjectOrProtected;
+ case MemberAttributes.Public: return vsCMAccess.vsCMAccessPublic;
+ case MemberAttributes.Private: return vsCMAccess.vsCMAccessPrivate;
+ case MemberAttributes.Assembly: return vsCMAccess.vsCMAccessProject;
+ case MemberAttributes.Family: return vsCMAccess.vsCMAccessProtected;
+ case MemberAttributes.FamilyOrAssembly: return vsCMAccess.vsCMAccessProjectOrProtected;
}
return vsCMAccess.vsCMAccessPrivate;
}
+ }
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeElementBase.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeElementBase.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeElementBase.cs Sun Sep 24 22:57:34 2006
@@ -1,49 +1,43 @@
using System;
+
using EnvDTE;
-using Microsoft.Samples.VisualStudio.LanguageService;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal abstract class CodeElementBase : CodeElement
{
DTE _dte;
ProjectItem _projectItem;
- readonly CodeElementBase parent;
+ readonly CodeElementBase _parent;
TextPoint _nullTextPoint = new NullTextPoint();
public CodeElementBase(DTE dte, ProjectItem projectItem)
- : this(dte, projectItem, null) {}
+ : this(dte, projectItem, null)
+ {
+ }
public CodeElementBase(DTE dte, ProjectItem projectItem,
CodeElementBase parent)
{
_dte = dte;
_projectItem = projectItem;
- this.parent = parent;
+ _parent = parent;
}
- protected CodeElement Parent { get { return parent; } }
- public DTE DTE { get { return _dte; } }
public abstract string Name { get; set; }
+ public abstract vsCMElement Kind { get; }
+
+ protected CodeElement Parent { get { return _parent; } }
+ public DTE DTE { get { return _dte; } }
public virtual string FullName { get { return Name; } }
public ProjectItem ProjectItem { get { return _projectItem; } }
- public abstract vsCMElement Kind { get; }
public virtual bool IsCodeType { get { return false; } }
- public virtual vsCMInfoLocation InfoLocation
- {
- get { return vsCMInfoLocation.vsCMInfoLocationNone; }
- }
+ public virtual vsCMInfoLocation InfoLocation { get { return vsCMInfoLocation.vsCMInfoLocationNone; } }
public virtual TextPoint StartPoint { get { return _nullTextPoint; } }
public virtual TextPoint EndPoint { get { return _nullTextPoint; } }
- public virtual CodeElements Collection
- {
- get { throw new NotImplementedException(); }
- }
+ public virtual CodeElements Collection { get { throw new NotImplementedException(); } }
public virtual CodeElements Children { get { return null; } }
- public string Language
- {
- get { return GlobalConstants.LanguageServiceGuidString; }
- }
+ public string Language { get { return NemerleConstants.LanguageServiceGuidString; } }
public virtual object ExtenderNames { get { return null; } }
public virtual string ExtenderCATID { get { return String.Empty; } }
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeNamespaceElement.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeNamespaceElement.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeNamespaceElement.cs Sun Sep 24 22:57:34 2006
@@ -1,25 +1,30 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
+
using EnvDTE;
+
using CodeNamespace=System.CodeDom.CodeNamespace;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal class CodeNamespaceElement : CodeElementBase, EnvDTE.CodeNamespace
{
- readonly CodeNamespace codeNamespace;
+ readonly CodeNamespace _codeNamespace;
- public CodeNamespaceElement(DTE dte, ProjectItem projectItem,
- CodeNamespace codeNamespace) : base(dte, projectItem)
+ public CodeNamespaceElement(
+ DTE dte,
+ ProjectItem projectItem,
+ CodeNamespace codeNamespace)
+ : base(dte, projectItem)
{
- this.codeNamespace = codeNamespace;
+ _codeNamespace = codeNamespace;
}
public override string Name
{
- get { return codeNamespace.Name; }
- set { codeNamespace.Name = value; }
+ get { return _codeNamespace.Name; }
+ set { _codeNamespace.Name = value; }
}
public override vsCMElement Kind
@@ -29,38 +34,41 @@
#region CodeNamespace
- EnvDTE.CodeNamespace EnvDTE.CodeNamespace.AddNamespace(string Name,
- object Position)
+ EnvDTE.CodeNamespace EnvDTE.CodeNamespace.AddNamespace(string Name, object Position)
{
throw new NotImplementedException();
}
- CodeClass EnvDTE.CodeNamespace.AddClass(string Name, object Position,
- object Bases, object ImplementedInterfaces, vsCMAccess Access)
+ CodeClass EnvDTE.CodeNamespace.AddClass(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeInterface EnvDTE.CodeNamespace.AddInterface(string Name,
- object Position, object Bases, vsCMAccess Access)
+ CodeInterface EnvDTE.CodeNamespace.AddInterface(
+ string Name, object Position, object Bases, vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeStruct EnvDTE.CodeNamespace.AddStruct(string Name, object Position,
- object Bases, object ImplementedInterfaces, vsCMAccess Access)
+ CodeStruct EnvDTE.CodeNamespace.AddStruct(
+ string Name, object Position, object Bases, object ImplementedInterfaces, vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeEnum EnvDTE.CodeNamespace.AddEnum(string Name, object Position,
- object Bases, vsCMAccess Access)
+ CodeEnum EnvDTE.CodeNamespace.AddEnum(
+ string Name, object Position, object Bases, vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeDelegate EnvDTE.CodeNamespace.AddDelegate(string Name, object Type,
- object Position, vsCMAccess Access)
+ CodeDelegate EnvDTE.CodeNamespace.AddDelegate(
+ string Name, object Type, object Position, vsCMAccess Access)
{
throw new NotImplementedException();
}
@@ -75,16 +83,25 @@
CodeElements LoadMembers()
{
- List<CodeElement> elements =
- new List<CodeElement>(codeNamespace.Types.Count);
- foreach (CodeTypeDeclaration type in codeNamespace.Types)
+ List<CodeElement> elements = new List<CodeElement>(_codeNamespace.Types.Count);
+
+ foreach (CodeTypeDeclaration type in _codeNamespace.Types)
elements.Add(CodeTypeElement.Create(DTE, ProjectItem, type, this));
return new NemerleCodeElements(DTE, ProjectItem, this, elements.ToArray());
}
- string EnvDTE.CodeNamespace.DocComment { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
- string EnvDTE.CodeNamespace.Comment { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } }
+ string EnvDTE.CodeNamespace.DocComment
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
+
+ string EnvDTE.CodeNamespace.Comment
+ {
+ get { throw new NotImplementedException(); }
+ set { throw new NotImplementedException(); }
+ }
#endregion
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeElement.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeElement.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeElement.cs Sun Sep 24 22:57:34 2006
@@ -1,14 +1,15 @@
+using System;
using System.CodeDom;
+
using EnvDTE;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal abstract class CodeTypeElement : CodeElementBase
{
protected readonly CodeTypeDeclaration codeType;
- public CodeTypeElement(DTE dte, ProjectItem projectItem,
- CodeTypeDeclaration codeType, CodeElementBase parent)
+ public CodeTypeElement(DTE dte, ProjectItem projectItem, CodeTypeDeclaration codeType, CodeElementBase parent)
: base(dte, projectItem, parent)
{
this.codeType = codeType;
@@ -20,8 +21,8 @@
set { codeType.Name = value; }
}
- public static CodeTypeElement Create(DTE dte, ProjectItem projectItem,
- CodeTypeDeclaration codeType, CodeElementBase parent)
+ public static CodeTypeElement Create(
+ DTE dte, ProjectItem projectItem, CodeTypeDeclaration codeType, CodeElementBase parent)
{
if (codeType.IsClass)
return new CodeClassElement(dte, projectItem, codeType, parent);
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeFunctionMember.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeFunctionMember.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeFunctionMember.cs Sun Sep 24 22:57:34 2006
@@ -3,13 +3,17 @@
using EnvDTE;
-namespace Microsoft.VisualStudio.Package.Automation
+using Microsoft.VisualStudio;
+
+namespace Nemerle.VisualStudio.FileCodeModel
{
- internal class CodeTypeFunctionMember : CodeTypeMemberElement,
- CodeFunction, NativeMethods.IMethodXML
+ internal class CodeTypeFunctionMember : CodeTypeMemberElement, CodeFunction, NativeMethods.IMethodXML
{
- public CodeTypeFunctionMember(DTE dte, ProjectItem projectItem,
- CodeTypeMember member, CodeElementBase parent)
+ public CodeTypeFunctionMember(
+ DTE dte,
+ ProjectItem projectItem,
+ CodeTypeMember member,
+ CodeElementBase parent)
: base(dte, projectItem, member, parent)
{
}
@@ -21,14 +25,12 @@
#region CodeFunction
- CodeParameter CodeFunction.AddParameter(string Name, object Type,
- object Position)
+ CodeParameter CodeFunction.AddParameter(string Name, object Type, object Position)
{
throw new NotImplementedException();
}
- CodeAttribute CodeFunction.AddAttribute(string Name, string Value,
- object Position)
+ CodeAttribute CodeFunction.AddAttribute(string Name, string Value, object Position)
{
throw new NotImplementedException();
}
@@ -61,10 +63,7 @@
CodeElements CodeFunction.Parameters
{
- get
- {
- return new NemerleCodeElements(DTE, ProjectItem, this);
- }
+ get { return new NemerleCodeElements(DTE, ProjectItem, this); }
}
vsCMAccess CodeFunction.Access
@@ -75,31 +74,18 @@
bool CodeFunction.IsOverloaded
{
- get
- {
- return (member.Attributes & MemberAttributes.Override)
- == MemberAttributes.Override;
- }
+ get { return (member.Attributes & MemberAttributes.Override) == MemberAttributes.Override; }
}
bool CodeFunction.IsShared
{
- get
- {
- return (member.Attributes & MemberAttributes.Static)
- == MemberAttributes.Static;
- }
+ get { return (member.Attributes & MemberAttributes.Static) == MemberAttributes.Static; }
set { throw new NotImplementedException(); }
}
bool CodeFunction.MustImplement
{
- get
- {
- return (member.Attributes & MemberAttributes.Static)
- == MemberAttributes.Static;
- }
-
+ get { return (member.Attributes & MemberAttributes.Static) == MemberAttributes.Static; }
set { throw new NotImplementedException(); }
}
@@ -127,20 +113,17 @@
bool CodeFunction.CanOverride
{
- get
- {
- return (member.Attributes & MemberAttributes.VTableMask)
- == MemberAttributes.VTableMask;
- }
+ get { return (member.Attributes & MemberAttributes.VTableMask) == MemberAttributes.VTableMask; }
set { throw new NotImplementedException(); }
}
+
#endregion
#region IMethodXML
void NativeMethods.IMethodXML.GetXML(ref string xml)
{
- xml = String.Empty;
+ xml = string.Empty;
}
int NativeMethods.IMethodXML.SetXML(string xml)
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeMemberElement.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeMemberElement.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeMemberElement.cs Sun Sep 24 22:57:34 2006
@@ -1,14 +1,15 @@
+using System;
using System.CodeDom;
+
using EnvDTE;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal abstract class CodeTypeMemberElement : CodeElementBase
{
protected readonly CodeTypeMember member;
- public CodeTypeMemberElement(DTE dte, ProjectItem projectItem,
- CodeTypeMember member, CodeElementBase parent)
+ public CodeTypeMemberElement(DTE dte, ProjectItem projectItem, CodeTypeMember member, CodeElementBase parent)
: base(dte, projectItem, parent)
{
this.member = member;
@@ -20,8 +21,11 @@
set { member.Name = value; }
}
- public static CodeTypeMemberElement Create(DTE dte, ProjectItem projectItem,
- CodeTypeMember member, CodeElementBase parent)
+ public static CodeTypeMemberElement Create(
+ DTE dte,
+ ProjectItem projectItem,
+ CodeTypeMember member,
+ CodeElementBase parent)
{
return new CodeTypeFunctionMember(dte, projectItem, member, parent);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeReferenceElement.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeReferenceElement.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/CodeTypeReferenceElement.cs Sun Sep 24 22:57:34 2006
@@ -1,25 +1,30 @@
using System;
using System.CodeDom;
+
using EnvDTE;
+
using CodeNamespace=EnvDTE.CodeNamespace;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal class CodeTypeReferenceElement : CodeElementBase, CodeClass
{
- readonly CodeTypeReference typeReference;
+ readonly CodeTypeReference _typeReference;
- public CodeTypeReferenceElement(DTE dte, ProjectItem projectItem,
- CodeTypeReference typeReference, CodeClassElement codeClassElement)
+ public CodeTypeReferenceElement(
+ DTE dte,
+ ProjectItem projectItem,
+ CodeTypeReference typeReference,
+ CodeClassElement codeClassElement)
: base(dte, projectItem, codeClassElement)
{
- this.typeReference = typeReference;
+ _typeReference = typeReference;
}
public override string Name
{
- get { return typeReference.BaseType; }
- set { typeReference.BaseType = value; }
+ get { return _typeReference.BaseType; }
+ set { _typeReference.BaseType = value; }
}
public override vsCMElement Kind
@@ -34,8 +39,7 @@
throw new NotImplementedException();
}
- CodeAttribute CodeClass.AddAttribute(string Name, string Value,
- object Position)
+ CodeAttribute CodeClass.AddAttribute(string Name, string Value, object Position)
{
throw new NotImplementedException();
}
@@ -50,50 +54,69 @@
throw new NotImplementedException();
}
- CodeInterface CodeClass.AddImplementedInterface(object Base,
- object Position)
+ CodeInterface CodeClass.AddImplementedInterface(object Base, object Position)
{
throw new NotImplementedException();
}
- CodeFunction CodeClass.AddFunction(string Name, vsCMFunction Kind,
- object Type, object Position, vsCMAccess Access, object Location)
+ CodeFunction CodeClass.AddFunction(
+ string Name,
+ vsCMFunction Kind,
+ object Type,
+ object Position,
+ vsCMAccess Access,
+ object Location)
{
throw new NotImplementedException();
}
- CodeVariable CodeClass.AddVariable(string Name, object Type,
- object Position, vsCMAccess Access, object Location)
+ CodeVariable CodeClass.AddVariable(
+ string Name,
+ object Type,
+ object Position,
+ vsCMAccess Access,
+ object Location)
{
throw new NotImplementedException();
}
- CodeProperty CodeClass.AddProperty(string GetterName, string PutterName,
- object Type, object Position, vsCMAccess Access, object Location)
+ CodeProperty CodeClass.AddProperty(
+ string GetterName,
+ string PutterName,
+ object Type,
+ object Position,
+ vsCMAccess Access,
+ object Location)
{
throw new NotImplementedException();
}
- CodeClass CodeClass.AddClass(string Name, object Position, object Bases,
- object ImplementedInterfaces, vsCMAccess Access)
+ CodeClass CodeClass.AddClass(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeStruct CodeClass.AddStruct(string Name, object Position, object Bases,
- object ImplementedInterfaces, vsCMAccess Access)
+ CodeStruct CodeClass.AddStruct(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeEnum CodeClass.AddEnum(string Name, object Position, object Bases,
- vsCMAccess Access)
+ CodeEnum CodeClass.AddEnum(string Name, object Position, object Bases, vsCMAccess Access)
{
throw new NotImplementedException();
}
- CodeDelegate CodeClass.AddDelegate(string Name, object Type,
- object Position, vsCMAccess Access)
+ CodeDelegate CodeClass.AddDelegate(string Name, object Type, object Position, vsCMAccess Access)
{
throw new NotImplementedException();
}
@@ -109,20 +132,10 @@
}
object CodeClass.Parent { get { throw new NotImplementedException(); } }
-
- CodeNamespace CodeClass.Namespace
- {
- get { throw new NotImplementedException(); }
- }
- CodeElements CodeClass.Bases
- {
- get { throw new NotImplementedException(); }
- }
-
- CodeElements CodeClass.Members
- {
- get { throw new NotImplementedException(); }
- }
+ CodeNamespace CodeClass.Namespace { get { throw new NotImplementedException(); } }
+ CodeElements CodeClass.Bases { get { throw new NotImplementedException(); } }
+ CodeElements CodeClass.Members { get { throw new NotImplementedException(); } }
+ CodeElements CodeClass.Attributes { get { throw new NotImplementedException(); } }
vsCMAccess CodeClass.Access
{
@@ -130,11 +143,6 @@
set { throw new NotImplementedException(); }
}
- CodeElements CodeClass.Attributes
- {
- get { throw new NotImplementedException(); }
- }
-
string CodeClass.DocComment
{
get { throw new NotImplementedException(); }
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleCodeElements.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleCodeElements.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleCodeElements.cs Sun Sep 24 22:57:34 2006
@@ -1,9 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
+
using EnvDTE;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal class NemerleCodeElements : CodeElements
{
@@ -12,8 +13,8 @@
private readonly ProjectItem _projectItem;
private List<CodeElement> _elements = new List<CodeElement>();
- public NemerleCodeElements(DTE dte, ProjectItem projectItem, object parent,
- params CodeElement[] elements)
+ public NemerleCodeElements(
+ DTE dte, ProjectItem projectItem, object parent, params CodeElement[] elements)
{
_parent = parent;
_dte = dte;
@@ -23,18 +24,9 @@
_elements.AddRange(elements);
}
- public DTE DTE
- {
- get { return _dte; }
- }
- public object Parent
- {
- get { return _parent; }
- }
- public int Count
- {
- get { return _elements.Count; }
- }
+ public DTE DTE { get { return _dte; } }
+ public object Parent { get { return _parent; } }
+ public int Count { get { return _elements.Count; } }
IEnumerator CodeElements.GetEnumerator()
{
@@ -48,10 +40,7 @@
public CodeElement Item(object index)
{
- if (index is int)
- return _elements[(int)index];
- else
- return null;
+ return index is int? _elements[(int)index]: null;
}
public void Reserved1(object Element)
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleFileCodeModel.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleFileCodeModel.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NemerleFileCodeModel.cs Sun Sep 24 22:57:34 2006
@@ -2,58 +2,57 @@
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
+
using EnvDTE;
-using Microsoft.Samples.VisualStudio.LanguageService;
-using Nemerle.VsIntegration.Project;
+
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.Package.Automation;
+
using Nemerle.Compiler.Utils;
-using CodeNamespace=System.CodeDom.CodeNamespace;
-using Nemerle.VisualStudio.Package.Automation;
+using Nemerle.VisualStudio.Project;
+
+using CodeNamespace = System.CodeDom.CodeNamespace;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
- internal class NemerleFileCodeModel : FileCodeModel
+ internal class NemerleFileCodeModel : EnvDTE.FileCodeModel
{
readonly FileNode _node;
readonly OAProject _project;
NemerleOAFileItem _projectItem;
- DTE dte;
+ DTE _dte;
- public NemerleFileCodeModel(DTE dte, NemerleOAFileItem projectItem,
- FileNode node, OAProject project)
+ public NemerleFileCodeModel(DTE dte, NemerleOAFileItem projectItem, FileNode node, OAProject project)
{
_node = node;
_project = project;
_projectItem = projectItem;
- this.dte = dte;
+ _dte = dte;
}
- public DTE DTE { get { return dte; } }
+ public DTE DTE { get { return _dte; } }
public ProjectItem Parent { get { return _projectItem; } }
- public string Language
- {
- get { return GlobalConstants.LanguageServiceGuidString; }
- }
+ public string Language { get { return NemerleConstants.LanguageServiceGuidString; } }
public CodeElements CodeElements { get { return LoadCodeElements(); } }
CodeElements LoadCodeElements()
{
NemerleCodeDomProvider provider = new NemerleCodeDomProvider();
+
using (StreamReader reader = new StreamReader(_node.Url))
{
CodeCompileUnit compileUnit = provider.Parse(reader);
- List<CodeElement> elements =
- new List<CodeElement>(compileUnit.Namespaces.Count);
+ List<CodeElement> elements = new List<CodeElement>(compileUnit.Namespaces.Count);
+
foreach (CodeNamespace ns in compileUnit.Namespaces)
if (ns.UserData["default"] == null)
- elements.Add(new CodeNamespaceElement(dte, _projectItem, ns));
+ elements.Add(new CodeNamespaceElement(_dte, _projectItem, ns));
else
foreach (CodeTypeDeclaration codeType in ns.Types)
- elements.Add(CodeTypeElement.Create(
- dte, _projectItem, codeType, null));
+ elements.Add(CodeTypeElement.Create(_dte, _projectItem, codeType, null));
- return
- new NemerleCodeElements(dte, _projectItem, null, elements.ToArray());
+ return new NemerleCodeElements(_dte, _projectItem, null, elements.ToArray());
}
}
@@ -67,50 +66,57 @@
throw new NotImplementedException();
}
- public CodeClass AddClass(string Name, object Position, object Bases,
- object ImplementedInterfaces, vsCMAccess Access)
+ public CodeClass AddClass(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- public CodeInterface AddInterface(string Name, object Position,
- object Bases, vsCMAccess Access)
+ public CodeInterface AddInterface(string Name, object Position, object Bases, vsCMAccess Access)
{
throw new NotImplementedException();
}
- public CodeFunction AddFunction(string Name, vsCMFunction Kind,
- object Type, object Position, vsCMAccess Access)
+ public CodeFunction AddFunction(
+ string Name,
+ vsCMFunction Kind,
+ object Type,
+ object Position,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- public CodeVariable AddVariable(string Name, object Type, object Position,
- vsCMAccess Access)
+ public CodeVariable AddVariable(string Name, object Type, object Position, vsCMAccess Access)
{
throw new NotImplementedException();
}
- public CodeAttribute AddAttribute(string Name, string Value,
- object Position)
+ public CodeAttribute AddAttribute(string Name, string Value, object Position)
{
throw new NotImplementedException();
}
- public CodeStruct AddStruct(string Name, object Position, object Bases,
- object ImplementedInterfaces, vsCMAccess Access)
+ public CodeStruct AddStruct(
+ string Name,
+ object Position,
+ object Bases,
+ object ImplementedInterfaces,
+ vsCMAccess Access)
{
throw new NotImplementedException();
}
- public CodeEnum AddEnum(string Name, object Position, object Bases,
- vsCMAccess Access)
+ public CodeEnum AddEnum(string Name, object Position, object Bases, vsCMAccess Access)
{
throw new NotImplementedException();
}
- public CodeDelegate AddDelegate(string Name, object Type, object Position,
- vsCMAccess Access)
+ public CodeDelegate AddDelegate(string Name, object Type, object Position, vsCMAccess Access)
{
throw new NotImplementedException();
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NullTextPoint.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NullTextPoint.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/NullTextPoint.cs Sun Sep 24 22:57:34 2006
@@ -1,6 +1,8 @@
+using System;
+
using EnvDTE;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal class NullTextPoint : TextPoint
{
Modified: vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/VoidCodeTypeRef.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/VoidCodeTypeRef.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/FileCodeModel/VoidCodeTypeRef.cs Sun Sep 24 22:57:34 2006
@@ -2,7 +2,7 @@
using EnvDTE;
-namespace Microsoft.VisualStudio.Package.Automation
+namespace Nemerle.VisualStudio.FileCodeModel
{
internal class VoidCodeTypeRef : CodeTypeRef
{
@@ -15,36 +15,24 @@
throw new NotImplementedException();
}
- public DTE DTE
- {
- get { throw new NotImplementedException(); }
- }
- public object Parent
- {
- get { throw new NotImplementedException(); }
- }
- public vsCMTypeRef TypeKind
- {
- get { return vsCMTypeRef.vsCMTypeRefVoid; }
- }
+ public DTE DTE { get { throw new NotImplementedException(); } }
+ public object Parent { get { throw new NotImplementedException(); } }
+ public vsCMTypeRef TypeKind { get { return vsCMTypeRef.vsCMTypeRefVoid; } }
+ public string AsString { get { return String.Empty; ; } }
+ public string AsFullName { get { return String.Empty; } }
+
public CodeType CodeType
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
+
public CodeTypeRef ElementType
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
- public string AsString
- {
- get { return String.Empty; ; }
- }
- public string AsFullName
- {
- get { return String.Empty; }
- }
+
public int Rank
{
get { throw new NotImplementedException(); }
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 22:57:34 2006
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
@@ -16,21 +15,14 @@
using Nemerle.Compiler;
using Nemerle.Completion2;
-using Nemerle.Core;
-using Nemerle.Utility;
-using Nemerle.Compiler.Utils;
-using Nemerle.VsIntegration;
-using Nemerle.VisualStudio;
-using Nemerle.VisualStudio.Package;
using Nemerle.VisualStudio.Project;
-using Microsoft.Samples.VisualStudio.LanguageService;
using VsShell = Microsoft.VisualStudio.Shell.VsShellUtilities;
namespace Nemerle.VisualStudio.LanguageService
{
- [Guid(GlobalConstants.LanguageServiceGuidString)]
+ [Guid(NemerleConstants.LanguageServiceGuidString)]
public class NemerleLanguageService : Microsoft.VisualStudio.Package.LanguageService
{
public NemerleLanguageService()
@@ -391,8 +383,7 @@
return base.GetImageList();
}
- public override int ValidateBreakpointLocation(
- IVsTextBuffer buffer, int line, int col, TextSpan[] pCodeSpan)
+ public override int ValidateBreakpointLocation(IVsTextBuffer buffer, int line, int col, TextSpan[] pCodeSpan)
{
if (pCodeSpan != null)
{
@@ -400,13 +391,17 @@
pCodeSpan[0].iStartIndex = col;
pCodeSpan[0].iEndLine = line;
pCodeSpan[0].iEndIndex = col;
+
if (buffer != null)
{
int length;
+
buffer.GetLengthOfLine(line, out length);
+
pCodeSpan[0].iStartIndex = 0;
pCodeSpan[0].iEndIndex = length;
}
+
return VSConstants.S_OK;
}
else
@@ -418,10 +413,10 @@
public override void OnIdle(bool periodic)
{
Source src = GetSource(LastActiveTextView);
+
if (src != null && src.LastParseTime == Int32.MaxValue)
- {
src.LastParseTime = 0;
- }
+
base.OnIdle(periodic);
}
@@ -430,8 +425,8 @@
return Resources.NemerleFormatFilter;
}
- // Implementation of IVsProvideColorableItems
-
+ // Implementation of IVsProvideColorableItems.
+ //
public override int GetItemCount(out int count)
{
count = _colorableItems.Length;
@@ -441,24 +436,25 @@
public override int GetColorableItem(int index, out IVsColorableItem item)
{
if (index < 1)
- {
throw new ArgumentOutOfRangeException("index");
- }
+
item = _colorableItems[index - 1];
+
return VSConstants.S_OK;
}
private int classNameCounter = 0;
- public override ExpansionFunction CreateExpansionFunction(
- ExpansionProvider provider, string functionName)
+ public override ExpansionFunction CreateExpansionFunction(ExpansionProvider provider, string functionName)
{
ExpansionFunction function = null;
+
if (functionName == "GetName")
{
++classNameCounter;
function = new NemerleGetNameExpansionFunction(provider, classNameCounter);
}
+
return function;
}
@@ -467,19 +463,16 @@
public override void OnParseComplete(ParseRequest req)
{
if (expansionsList == null)
- {
GetSnippets();
}
- }
// Disable the "DoNotPassTypesByReference" warning.
- [SuppressMessage("Microsoft.Design", "CA1045")]
+ //
public void AddSnippets(ref NemerleDeclarations declarations)
{
if (null == expansionsList)
- {
return;
- }
+
foreach (VsExpansion expansionInfo in expansionsList)
{
//declarations.AddDeclaration(new Declaration(expansionInfo));
@@ -487,7 +480,6 @@
}
}
- //[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
private void GetSnippets()
{
if (null == expansionsList)
@@ -496,6 +488,7 @@
expansionsList.Clear();
IVsTextManager2 textManager = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsTextManager)) as IVsTextManager2;
+
if (textManager == null)
return;
@@ -508,8 +501,8 @@
public override ViewFilter CreateViewFilter(CodeWindowManager mgr, IVsTextView newView)
{
- // This call makes sure debugging events can be received
- // by our view filter.
+ // This call makes sure debugging events can be received by our view filter.
+ //
GetIVsDebugger();
return new NemerleViewFilter(mgr, newView);
}
Added: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleMethods.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleMethods.cs Sun Sep 24 22:57:34 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.LanguageService
+{
+ 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; } }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,59 @@
+using System;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Nemerle.VisualStudio.LanguageService
+{
+ 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/LanguageService/SnippetsEnumerator.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/SnippetsEnumerator.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,143 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Nemerle.VisualStudio.LanguageService
+{
+ internal class SnippetsEnumerator : IEnumerable<VsExpansion>
+ {
+ /// <summary>
+ /// This structure is used to facilitate the interop calls to the method
+ /// exposed by IVsExpansionEnumeration.
+ /// </summary>
+ [StructLayout(LayoutKind.Sequential)]
+ struct ExpansionBuffer
+ {
+ public IntPtr _pathPtr;
+ public IntPtr _titlePtr;
+ public IntPtr _shortcutPtr;
+ public IntPtr _descriptionPtr;
+ }
+
+ IVsTextManager2 _textManager;
+ Guid _languageGuid;
+ bool _shortcutOnly;
+
+ public SnippetsEnumerator(IVsTextManager2 textManager, Guid languageGuid)
+ {
+ if (null == textManager)
+ throw new ArgumentNullException("textManager");
+
+ _textManager = textManager;
+ _languageGuid = languageGuid;
+ }
+
+ public bool ShortcutOnly
+ {
+ get { return _shortcutOnly; }
+ set { _shortcutOnly = value; }
+ }
+
+ #region IEnumerable<VsExpansion> Members
+
+ public IEnumerator<VsExpansion> GetEnumerator()
+ {
+ IVsExpansionManager expansionManager;
+
+ ErrorHandler.ThrowOnFailure(_textManager.GetExpansionManager(out expansionManager));
+
+ IVsExpansionEnumeration enumerator;
+ int onlyShortcut = ShortcutOnly ? 1 : 0;
+
+ ErrorHandler.ThrowOnFailure(
+ expansionManager.EnumerateExpansions(_languageGuid, onlyShortcut, null, 0, 0, 0, out enumerator));
+
+ ExpansionBuffer buffer = new ExpansionBuffer();
+ GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
+
+ try
+ {
+ uint fetched;
+ int hr;
+
+ while ((hr = enumerator.Next(1, new IntPtr[] { handle.AddrOfPinnedObject() }, out fetched)) == VSConstants.S_OK)
+ {
+ buffer = (ExpansionBuffer)handle.Target;
+
+ try
+ {
+ handle.Free();
+
+ if (IntPtr.Zero != buffer._shortcutPtr)
+ {
+ VsExpansion expansion = new VsExpansion();
+
+ expansion.shortcut = Marshal.PtrToStringBSTR(buffer._shortcutPtr);
+
+ if (IntPtr.Zero != buffer._descriptionPtr)
+ expansion.description = Marshal.PtrToStringBSTR(buffer._descriptionPtr);
+
+ if (IntPtr.Zero != buffer._pathPtr)
+ expansion.path = Marshal.PtrToStringBSTR(buffer._pathPtr);
+
+ if (IntPtr.Zero != buffer._titlePtr)
+ expansion.title = Marshal.PtrToStringBSTR(buffer._titlePtr);
+
+ yield return expansion;
+
+ handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
+ }
+ }
+ finally
+ {
+ if (IntPtr.Zero != buffer._descriptionPtr)
+ {
+ Marshal.FreeBSTR(buffer._descriptionPtr);
+ buffer._descriptionPtr = IntPtr.Zero;
+ }
+
+ if (IntPtr.Zero != buffer._pathPtr)
+ {
+ Marshal.FreeBSTR(buffer._pathPtr);
+ buffer._pathPtr = IntPtr.Zero;
+ }
+
+ if (IntPtr.Zero != buffer._shortcutPtr)
+ {
+ Marshal.FreeBSTR(buffer._shortcutPtr);
+ buffer._shortcutPtr = IntPtr.Zero;
+ }
+
+ if (IntPtr.Zero != buffer._titlePtr)
+ {
+ Marshal.FreeBSTR(buffer._titlePtr);
+ buffer._titlePtr = IntPtr.Zero;
+ }
+ }
+ }
+
+ ErrorHandler.ThrowOnFailure(hr);
+ }
+ finally
+ {
+ if (handle.IsAllocated)
+ handle.Free();
+ }
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ throw new NotImplementedException("The method or operation is not implemented.");
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
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 22:57:34 2006
@@ -3,7 +3,7 @@
<Nemerle Condition=" '$(Nemerle)' == '' ">$(ProgramFiles)\Nemerle</Nemerle>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>nemerle.snk</AssemblyOriginatorKeyFile>
- <RootNamespace>Nemerle.VsIntegration</RootNamespace>
+ <RootNamespace>Nemerle.VisualStudio</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -69,21 +69,21 @@
<Reference Include="..\Nemerle.Compiler.Utils\bin\$(Configuration)\Nemerle.Compiler.Utils.dll" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Engine\ScopeNode.cs" />
- <Compile Include="HierarchyListener.cs" />
+ <Compile Include="Project\ScopeNode.cs" />
+ <Compile Include="Project\HierarchyListener.cs" />
<Compile Include="NemerleConstants.cs" />
<Compile Include="LanguageService\NemerleDeclarations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Package\NemerleMethods.cs" />
- <Compile Include="Package\NemerleViewFilter.cs" />
+ <Compile Include="LanguageService\NemerleMethods.cs" />
+ <Compile Include="LanguageService\NemerleViewFilter.cs" />
<Compile Include="RegisterSnippetsAttribute.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
- <Compile Include="SnippetsEnumerator.cs" />
- <Compile Include="TextLineEventListener.cs" />
+ <Compile Include="LanguageService\SnippetsEnumerator.cs" />
+ <Compile Include="Project\TextLineEventListener.cs" />
<Compile Include="ErrorHelper.cs">
<SubType>Code</SubType>
</Compile>
@@ -110,9 +110,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
- <ItemGroup>
- <None Include="Engine\TraceWriter.cs" />
- </ItemGroup>
<PropertyGroup>
<CommonRegAttributes>$(VisualStudioIntegration)\Common\Source\CSharp\RegistrationAttributes</CommonRegAttributes>
</PropertyGroup>
@@ -130,7 +127,8 @@
<Compile Include="LanguageService\NemerleScanner.cs" />
<Compile Include="LanguageService\NemerleSource.cs" />
<Compile Include="NemerlePackage.cs" />
- <Compile Include="Package\Automation\NemerleOAFileItem.cs" />
+ <Compile Include="Project\NemerleOAFileItem.cs" />
+ <Compile Include="Project\HierarchyEventArgs.cs" />
<Compile Include="Project\INemerleLibraryManager.cs" />
<Compile Include="Project\Library.cs" />
<Compile Include="Project\LibraryNode.cs" />
@@ -141,8 +139,8 @@
<Compile Include="Project\NemerleProjectNodeProperties.cs" />
<Compile Include="Project\ProjectInfo.cs" />
<Compile Include="Utils.cs" />
- <Compile Include="ConfigurationPropertyPages.cs" />
- <Compile Include="Package\NemerleEditorFactory.cs" />
+ <Compile Include="Project\ConfigurationPropertyPages.cs" />
+ <Compile Include="Project\NemerleEditorFactory.cs" />
<Compile Include="FileCodeModel\CodeClassElement.cs" />
<Compile Include="FileCodeModel\CodeDomUtils.cs" />
<Compile Include="FileCodeModel\CodeElementBase.cs" />
@@ -154,17 +152,17 @@
<Compile Include="FileCodeModel\NemerleCodeElements.cs" />
<Compile Include="FileCodeModel\NullTextPoint.cs" />
<Compile Include="FileCodeModel\VoidCodeTypeRef.cs" />
- <Compile Include="ObjectModelExtenders\ReferenceContainerNodeEx.cs" />
- <Compile Include="ObjectModelExtenders\TokenProcessorEx.cs" />
+ <Compile Include="Project\NemerleReferenceContainerNode.cs" />
+ <Compile Include="Project\NemerleTokenProcessor.cs" />
<Compile Include="FileCodeModel\NemerleFileCodeModel.cs" />
- <Compile Include="PropertyPages.cs" />
- <Compile Include="Package\NemerleConfigProvider.cs" />
+ <Compile Include="Project\PropertyPages.cs" />
+ <Compile Include="Project\NemerleConfigProvider.cs" />
<Compile Include="Project\NemerleFileNode.cs" />
<Compile Include="Project\NemerleFileNodeProperties.cs" />
- <Compile Include="NemerleMenus.cs" />
+ <Compile Include="Project\NemerleMenus.cs" />
<Compile Include="Resources.cs" />
- <Compile Include="Package\SelectionElementValueChangedListener.cs" />
- <Compile Include="VSMDNemerleProvider.cs" />
+ <Compile Include="Project\SelectionElementValueChangedListener.cs" />
+ <Compile Include="Project\NemerleVSMDCodeDomProvider.cs" />
<Compile Include="$(CommonRegAttributes)\SingleFileGeneratorSupportRegistrationAttribute.cs">
<Link>RegistrationAttributes\SingleFileGeneratorSupportRegistrationAttribute.cs</Link>
<Visible>true</Visible>
@@ -245,7 +243,6 @@
<ZipProject Include="Templates\Projects\WindowsApplication\Program.n" />
</ItemGroup>
<ItemGroup>
- <Content Include="ObjectModelExtenders\!Info.txt" />
<None Include="Resources\Nemerle.ico" />
<EmbeddedResource Include="Resources\NemerleImageList.bmp" />
<ZipProject Include="Templates\Projects\WindowsApplication\NemerleMacroLibrary.vstemplate" />
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerleConstants.cs Sun Sep 24 22:57:34 2006
@@ -1,7 +1,8 @@
-namespace Microsoft.Samples.VisualStudio.LanguageService
-{
+using System;
- public static class GlobalConstants
+namespace Nemerle.VisualStudio
+{
+ public static class NemerleConstants
{
// See else:
// Nemerle.VsIntegration\CtcComponents\Guids.h
@@ -13,13 +14,14 @@
public const string FileExtension = ".n";
public const string ProjectExtension = "nproj";
- // used by registration and about box/splash screen
+ // Used by registration and about box/splash screen.
+ //
public const string ProductDetails = "Nemerle VS Integration";
public const string ProductID = "1.0";
- // Âíčěŕíčĺ, GUID LanguageServiceGuidString íóćíî čçěĺíčňü ĺůĺ č çäĺńü:
+ // Attention, GUID LanguageServiceGuidString also has to be changed there:
// Nemerle.VsIntegration\CodeSnippets\SnippetsIndex.xml
-
+ //
public const string LanguageServiceGuidString = "EDCC3B79-0BAD-11DB-BC1A-00112FDE8B61";
public const string LibraryManagerGuidString = "EDCC3B7A-0BAD-11DB-BC1A-00112FDE8B61";
public const string LibraryManagerServiceGuidString = "EDCC3B7B-0BAD-11DB-BC1A-00112FDE8B61";
@@ -42,7 +44,8 @@
/// <summary>
/// Indexes to the embedded NemerleImageList.bmp image list.
/// </summary>
- public enum ImageListIndex : int {
+ public enum ImageListIndex
+ {
NemerleSource = 0,
NemerleProject = 1,
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/NemerlePackage.cs Sun Sep 24 22:57:34 2006
@@ -11,11 +11,6 @@
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;
@@ -39,20 +34,20 @@
// 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,
+ NemerleConstants.LanguageName,
+ NemerleConstants.LanguageName + " Project Project Files (*." +
+ NemerleConstants.ProjectExtension + ");*." + NemerleConstants.ProjectExtension,
+ NemerleConstants.ProjectExtension,
+ NemerleConstants.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)]
+ LanguageVsTemplate = NemerleConstants.LanguageName)]
[ProvideMenuResource (1000, 1)]
[ProvideObject (typeof(GeneralPropertyPage))]
[ProvideObject (typeof(NemerleBuildPropertyPage))]
[ProvideEditorExtension (typeof(NemerlEditorFactory), ".n", 32)]
- [ProvideEditorLogicalView(typeof(NemerlEditorFactory), GlobalConstants.EditorLogicalViewGuidString)]
+ [ProvideEditorLogicalView(typeof(NemerlEditorFactory), NemerleConstants.EditorLogicalViewGuidString)]
//LOGVIEWID_Designer
//[ProvideEditorLogicalView(typeof(NP.EditorFactory),
// "{7651a701-06e5-11d1-8ebd-00a0c90f26ea}")
@@ -62,29 +57,29 @@
// 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,
+ NemerleConstants.LanguageName,
+ NemerleConstants.ProductDetails,
+ NemerleConstants.ProductID,
IconResourceID=300)]
- [ProvideLoadKey("standard", GlobalConstants.ProductID, GlobalConstants.ProductDetails, "", 104)]
- [ProvideService(typeof(NemerleLanguageService), ServiceName = GlobalConstants.LanguageName)]
+ [ProvideLoadKey("standard", NemerleConstants.ProductID, NemerleConstants.ProductDetails, "", 104)]
+ [ProvideService(typeof(NemerleLanguageService), ServiceName = NemerleConstants.LanguageName)]
[ProvideService(typeof(INemerleLibraryManager))]
[ProvideLanguageService(
typeof(NemerleLanguageService),
- GlobalConstants.LanguageName,
+ NemerleConstants.LanguageName,
100,
CodeSense = true,
EnableCommenting = true,
MatchBraces = true,
ShowCompletion = true,
ShowMatchingBrace = true)]
- [ProvideLanguageExtension(typeof(NemerleLanguageService), GlobalConstants.FileExtension)]
- [Guid(GlobalConstants.PackageGuidString)]
+ [ProvideLanguageExtension(typeof(NemerleLanguageService), NemerleConstants.FileExtension)]
+ [Guid(NemerleConstants.PackageGuidString)]
[RegisterSnippets(
- GlobalConstants.LanguageServiceGuidString,
+ NemerleConstants.LanguageServiceGuidString,
false,
100,
- GlobalConstants.LanguageName,
+ NemerleConstants.LanguageName,
@"CodeSnippets\SnippetsIndex.xml",
@"CodeSnippets\Snippets\",
@"CodeSnippets\Snippets\")
@@ -320,7 +315,7 @@
/// <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;
+ pbstrName = NemerleConstants.LanguageName;
return VSConstants.S_OK;
}
@@ -330,7 +325,7 @@
/// <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;
+ pbstrProductDetails = NemerleConstants.ProductDetails;
return VSConstants.S_OK;
}
@@ -340,7 +335,7 @@
/// <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;
+ pbstrPID = NemerleConstants.ProductID;
return VSConstants.S_OK;
}
#endregion
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/ConfigurationPropertyPages.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ConfigurationPropertyPages.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,13 @@
+using System;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio.Package;
+
+namespace Nemerle.VisualStudio.Project
+{
+ [ComVisible(true)]
+ [Guid(NemerleConstants.BuildPropertyPageGuidString)]
+ public class NemerleBuildPropertyPage : BuildPropertyPage
+ {
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/HierarchyEventArgs.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/HierarchyEventArgs.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,50 @@
+using System;
+using System.Diagnostics;
+
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Nemerle.VisualStudio.Project
+{
+ [DebuggerStepThrough]
+ internal class HierarchyEventArgs : EventArgs
+ {
+ uint _itemId;
+ string _fileName;
+ IVsTextLines _buffer;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HierarchyEventArgs"/> class.
+ /// </summary>
+ /// <param name="itemId">The item id.</param>
+ /// <param name="fileName">Name of the file.</param>
+ public HierarchyEventArgs(uint itemId, string fileName)
+ {
+ ErrorHelper.ThrowIsNullOrEmpty(fileName, "fileName");
+
+ _itemId = itemId;
+ _fileName = fileName;
+ }
+
+ /// <summary>
+ /// Gets the name of the file.
+ /// </summary>
+ /// <value>The name of the file.</value>
+ public string FileName { get { return _fileName; } }
+
+ /// <summary>
+ /// Gets the item ID.
+ /// </summary>
+ /// <value>The item ID.</value>
+ public uint ItemID { get { return _itemId; } }
+
+ /// <summary>
+ /// Gets or sets the text buffer.
+ /// </summary>
+ /// <value>The text buffer.</value>
+ public IVsTextLines TextBuffer
+ {
+ get { return _buffer; }
+ set { _buffer = value; }
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/HierarchyListener.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/HierarchyListener.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,271 @@
+using System;
+using System.Diagnostics;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell.Interop;
+
+namespace Nemerle.VisualStudio.Project
+{
+ class HierarchyListener : IVsHierarchyEvents, IDisposable
+ {
+ IVsHierarchy _hierarchy;
+ uint _cookie;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HierarchyListener"/> class.
+ /// </summary>
+ /// <param name="hierarchy">The hierarchy.</param>
+ public HierarchyListener(IVsHierarchy hierarchy)
+ {
+ ErrorHelper.ThrowIsNull(hierarchy, "hierarchy");
+ _hierarchy = hierarchy;
+ }
+
+ #region Public Methods
+
+ /// <summary>
+ /// Gets a value indicating whether this instance is listening.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this instance is listening; otherwise, <c>false</c>.
+ /// </value>
+ public bool IsListening
+ {
+ get { return (_cookie != 0); }
+ }
+
+ /// <summary>
+ /// Starts the listening.
+ /// </summary>
+ /// <param name="doInitialScan">if set to <c>true</c> [do initial scan].</param>
+ public void StartListening(bool doInitialScan)
+ {
+ if (0 == _cookie)
+ {
+ ErrorHandler.ThrowOnFailure(
+ _hierarchy.AdviseHierarchyEvents(this, out _cookie));
+ if (doInitialScan)
+ InternalScanHierarchy(VSConstants.VSITEMID_ROOT);
+ }
+ }
+
+ /// <summary>
+ /// Stops the listening.
+ /// </summary>
+ public void StopListening()
+ {
+ InternalStopListening(true);
+ }
+
+ #endregion
+
+ #region IDisposable Members
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ public void Dispose()
+ {
+ InternalStopListening(false);
+
+ _cookie = 0;
+ _hierarchy = null;
+ }
+
+ #endregion
+
+ #region Public Events
+
+ public event EventHandler<HierarchyEventArgs> ItemAdded;
+ public event EventHandler<HierarchyEventArgs> ItemDeleted;
+
+ #endregion
+
+ #region IVsHierarchyEvents Members
+
+ public int OnInvalidateIcon(IntPtr hicon)
+ {
+ // Do Nothing.
+ //
+ return VSConstants.S_OK;
+ }
+
+ public int OnInvalidateItems(uint itemidParent)
+ {
+ // TODO: Find out if this event is needed.
+ //
+ Debug.WriteLine("\n\tOnInvalidateItems\n");
+ return VSConstants.S_OK;
+ }
+
+ public int OnItemAdded(uint itemidParent, uint itemidSiblingPrev, uint itemidAdded)
+ {
+ // Check if the item is a nemerle file.
+ //
+ Debug.WriteLine("\n\tOnItemAdded\n");
+
+ string name;
+
+ if (!IsNemerleFile(itemidAdded, out name))
+ return VSConstants.S_OK;
+
+ // This item is a nemerle file, so we can notify that it is added to the hierarchy.
+ //
+ if (ItemAdded != null)
+ {
+ HierarchyEventArgs args = new HierarchyEventArgs(itemidAdded, name);
+ ItemAdded(_hierarchy, args);
+ }
+
+ return VSConstants.S_OK;
+ }
+
+ public int OnItemDeleted(uint itemid)
+ {
+ Debug.WriteLine("\n\tOnItemDeleted\n");
+
+ // Notify that the item is deleted only if it is a nemerle file.
+ //
+ string name;
+
+ if (!IsNemerleFile(itemid, out name))
+ return VSConstants.S_OK;
+
+ if (ItemDeleted != null)
+ {
+ HierarchyEventArgs args = new HierarchyEventArgs(itemid, name);
+ ItemDeleted(_hierarchy, args);
+ }
+
+ return VSConstants.S_OK;
+ }
+
+ public int OnItemsAppended(uint itemidParent)
+ {
+ // TODO: Find out what this event is about.
+ //
+ Debug.WriteLine("\n\tOnItemsAppended\n");
+ return VSConstants.S_OK;
+ }
+
+ public int OnPropertyChanged(uint itemid, int propid, uint flags)
+ {
+ // Do Nothing.
+ //
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ bool InternalStopListening(bool throwOnError)
+ {
+ if ((null != _hierarchy) || (0 == _cookie))
+ return false;
+
+ int hr = _hierarchy.UnadviseHierarchyEvents(_cookie);
+
+ if (throwOnError)
+ ErrorHandler.ThrowOnFailure(hr);
+
+ _cookie = 0;
+
+ return ErrorHandler.Succeeded(hr);
+ }
+
+ bool IsNemerleFile(uint itemId, out string canonicalName)
+ {
+ canonicalName = null;
+
+ // Find out if this item is a physical file.
+ //
+ Guid typeGuid;
+ int hr = _hierarchy.GetGuidProperty(itemId, (int)__VSHPROPID.VSHPROPID_TypeGuid, out typeGuid);
+
+ if (ErrorHandler.Failed(hr) || VSConstants.GUID_ItemType_PhysicalFile != typeGuid)
+ // It is not a file, we can exit now.
+ return false;
+
+ // This item is a file; find if it is a pyhon file.
+ //
+ hr = _hierarchy.GetCanonicalName(itemId, out canonicalName);
+
+ if (ErrorHandler.Failed(hr))
+ return false;
+
+ return Utils.IsNemerleFileExtension(canonicalName);
+ }
+
+ /// <summary>
+ /// Do a recursive walk on the hierarchy to find all the nemerle files in
+ /// it. It will generate an event for every file found.
+ /// </summary>
+ void InternalScanHierarchy(uint itemId)
+ {
+ uint currentItem = itemId;
+
+ while (VSConstants.VSITEMID_NIL != currentItem)
+ {
+ // If this item is a nemerle file, then send the add item event.
+ string itemName;
+
+ if (ItemAdded != null && IsNemerleFile(currentItem, out itemName))
+ {
+ HierarchyEventArgs args = new HierarchyEventArgs(currentItem, itemName);
+ ItemAdded(_hierarchy, args);
+ }
+
+ // NOTE: At the moment we skip the nested hierarchies, so here we
+ // look for the children of this node. Before looking at the children
+ // we have to make sure that the enumeration has not side effects to
+ // avoid unexpected behavior.
+ //
+ object propertyValue;
+ bool canScanSubitems = true;
+ int hr = _hierarchy.GetProperty(
+ currentItem, (int)__VSHPROPID.VSHPROPID_HasEnumerationSideEffects, out propertyValue);
+
+ if ((VSConstants.S_OK == hr) && (propertyValue is bool))
+ canScanSubitems = !(bool)propertyValue;
+
+ // If it is allow to look at the sub-items of the current one, lets do it.
+ //
+ if (canScanSubitems)
+ {
+ object child;
+
+ hr = _hierarchy.GetProperty(currentItem, (int)__VSHPROPID.VSHPROPID_FirstChild, out child);
+
+ if (VSConstants.S_OK == hr)
+ // There is a sub-item, call this same function on it.
+ InternalScanHierarchy(GetItemId(child));
+ }
+
+ // Move the current item to its first visible sibling.
+ //
+ object sibling;
+
+ hr = _hierarchy.GetProperty(currentItem, (int)__VSHPROPID.VSHPROPID_NextSibling, out sibling);
+
+ currentItem = VSConstants.S_OK != hr? VSConstants.VSITEMID_NIL: GetItemId(sibling);
+ }
+ }
+
+ /// <summary>
+ /// Gets the item id.
+ /// </summary>
+ /// <param name="variantValue">VARIANT holding an itemid.</param>
+ /// <returns>Item Id of the concerned node</returns>
+ static uint GetItemId(object variantValue)
+ {
+ if (variantValue == null) return VSConstants.VSITEMID_NIL;
+
+ if (variantValue is int) return (uint)(int)variantValue;
+ if (variantValue is uint) return (uint)variantValue;
+ if (variantValue is short) return (uint)(short)variantValue;
+ if (variantValue is ushort) return (ushort)variantValue;
+ if (variantValue is long) return (uint)(long)variantValue;
+
+ return VSConstants.VSITEMID_NIL;
+ }
+ }
+}
\ No newline at end of file
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/INemerleLibraryManager.cs Sun Sep 24 22:57:34 2006
@@ -3,8 +3,6 @@
using Microsoft.VisualStudio.Shell.Interop;
-using Microsoft.Samples.VisualStudio.LanguageService;
-
namespace Nemerle.VisualStudio.Project
{
/// <summary>
@@ -12,7 +10,7 @@
/// a hierarchy and builds the informations to expose to the class view or
/// object browser.
/// </summary>
- [Guid(GlobalConstants.LibraryManagerServiceGuidString)]
+ [Guid(NemerleConstants.LibraryManagerServiceGuidString)]
public interface INemerleLibraryManager
{
void RegisterHierarchy (IVsHierarchy hierarchy);
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleConfigProvider.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleConfigProvider.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,50 @@
+using System;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Package;
+
+namespace Nemerle.VisualStudio.Project
+{
+ /// <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/Project/NemerleEditorFactory.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleEditorFactory.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,347 @@
+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 IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
+
+namespace Nemerle.VisualStudio.Project
+{
+ [Guid(NemerleConstants.EditorFactoryGuidString)]
+ public class NemerlEditorFactory : IVsEditorFactory
+ {
+ #region ctors
+
+ public NemerlEditorFactory(NemerlePackage package)
+ {
+ _package = package;
+ }
+
+ #endregion
+
+ #region Consts
+
+ internal static readonly Guid EditorFactoryGuid = new Guid(NemerleConstants.EditorFactoryGuidString);
+
+ #endregion
+
+ #region Fields
+
+ NemerlePackage _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
+ }
+}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNode.cs Sun Sep 24 22:57:34 2006
@@ -11,11 +11,6 @@
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;
@@ -110,9 +105,9 @@
//
public override object GetIconHandle(bool open)
{
- if (FileName.EndsWith(GlobalConstants.FileExtension, StringComparison.InvariantCultureIgnoreCase))
+ if (FileName.EndsWith(NemerleConstants.FileExtension, StringComparison.InvariantCultureIgnoreCase))
return PackageUtilities.GetIntPointerFromImage(
- NemerleProjectNode.NemerleImageList.Images[(int)GlobalConstants.ImageListIndex.NemerleSource]);
+ NemerleProjectNode.NemerleImageList.Images[(int)NemerleConstants.ImageListIndex.NemerleSource]);
return base.GetIconHandle(open);
}
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleFileNodeProperties.cs Sun Sep 24 22:57:34 2006
@@ -4,13 +4,11 @@
using Microsoft.VisualStudio.Package;
-using Microsoft.Samples.VisualStudio.LanguageService;
-
namespace Nemerle.VisualStudio.Project
{
[ComVisible(true)]
[CLSCompliant(false)]
- [Guid(GlobalConstants.FileNodePropertiesGuidString)]
+ [Guid(NemerleConstants.FileNodePropertiesGuidString)]
public class NemerleFileNodeProperties : FileNodeProperties
{
public NemerleFileNodeProperties(HierarchyNode node)
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryManager.cs Sun Sep 24 22:57:34 2006
@@ -5,13 +5,10 @@
using System.Runtime.InteropServices;
using System.Threading;
-using Microsoft.Samples.VisualStudio.NemerleInference;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TextManager.Interop;
-using Microsoft.Samples.VisualStudio.LanguageService;
-
namespace Nemerle.VisualStudio.Project
{
/// <summary>
@@ -19,7 +16,7 @@
/// navigation tools (class view or object browser) from the Nemerle files
/// inside a hierarchy.
/// </summary>
- [Guid(GlobalConstants.LibraryManagerGuidString)]
+ [Guid(NemerleConstants.LibraryManagerGuidString)]
internal class NemerleLibraryManager : INemerleLibraryManager, IVsRunningDocTableEvents, IDisposable
{
/// <summary>
@@ -132,7 +129,7 @@
_shutDownStarted = new ManualResetEvent(false);
_parseThread = new Thread(new ThreadStart(ParseThread));
- _library = new Library(new Guid(GlobalConstants.LibraryGuidString));
+ _library = new Library(new Guid(NemerleConstants.LibraryGuidString));
_library.LibraryCapabilities = (_LIB_FLAGS2)_LIB_FLAGS.LF_PROJECT;
_parseThread.Start();
@@ -608,7 +605,7 @@
//
string extension = Path.GetExtension(documentMoniker);
- if (string.Compare(extension, GlobalConstants.FileExtension, StringComparison.OrdinalIgnoreCase) != 0)
+ if (string.Compare(extension, NemerleConstants.FileExtension, StringComparison.OrdinalIgnoreCase) != 0)
return VSConstants.S_OK;
// Create the module id for this document.
Modified: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs (original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleLibraryNode.cs Sun Sep 24 22:57:34 2006
@@ -6,8 +6,6 @@
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TextManager.Interop;
-using Microsoft.Samples.VisualStudio.NemerleInference;
-
namespace Nemerle.VisualStudio.Project
{
/// <summary>
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleMenus.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleMenus.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,18 @@
+using System;
+using System.ComponentModel.Design;
+
+namespace Nemerle.VisualStudio.Project
+{
+ /// <summary>
+ /// CommandIDs matching the commands defined items from PkgCmdID.h and guids.h
+ /// </summary>
+ public sealed class NemerleMenus
+ {
+ internal static readonly Guid guidNemerleProjectCmdSet =
+ new Guid(NemerleConstants.ProjectCmdSetGuidString);
+
+ internal static readonly CommandID SetAsMain =
+ new CommandID(guidNemerleProjectCmdSet, 0x3001);
+ }
+}
+
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleOAFileItem.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleOAFileItem.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,46 @@
+using System;
+using System.Runtime.InteropServices;
+
+using EnvDTE;
+
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.Package.Automation;
+
+using Nemerle.VisualStudio.FileCodeModel;
+
+namespace Nemerle.VisualStudio.Project
+{
+ /// <summary>
+ /// Add support for automation on n files.
+ /// </summary>
+ [Guid(NemerleConstants.OAFileItemGuidString)]
+ public class NemerleOAFileItem : OAFileItem
+ {
+ public NemerleOAFileItem(OAProject project, FileNode node)
+ : base(project, node)
+ {
+ }
+
+ /// <summary>
+ /// Gets the FileCodeModel object for the project item.
+ /// </summary>
+ public override EnvDTE.FileCodeModel FileCodeModel
+ {
+ get { return new NemerleFileCodeModel(DTE, this, Node, Project); }
+ }
+
+ public override Window Open(string viewKind)
+ {
+ if (string.Compare(viewKind, Constants.vsViewKindPrimary) == 0)
+ {
+ // Get the subtype and decide the viewkind based on the result.
+ //
+ if (((NemerleFileNode)Node).IsFormSubType)
+ return base.Open(Constants.vsViewKindDesigner);
+ }
+
+ return base.Open(viewKind);
+ }
+ }
+
+}
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 22:57:34 2006
@@ -3,13 +3,11 @@
using Microsoft.VisualStudio.Package;
-using Microsoft.Samples.VisualStudio.LanguageService;
-
using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;
namespace Nemerle.VisualStudio.Project
{
- [Guid(GlobalConstants.ProjectFactoryViewGuidString)]
+ [Guid(NemerleConstants.ProjectFactoryViewGuidString)]
public class NemerleProjectFactory : ProjectFactory
{
public NemerleProjectFactory(NemerlePackage package)
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 22:57:34 2006
@@ -14,17 +14,11 @@
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
-using Microsoft.Samples.VisualStudio.LanguageService;
-
-using Nemerle.VsIntegration.Project;
-using Nemerle.VisualStudio.Package;
-using Nemerle.VisualStudio.Package.Automation;
-
using PkgUtils = Microsoft.VisualStudio.Package.Utilities;
namespace Nemerle.VisualStudio.Project
{
- [Guid(GlobalConstants.ProjectNodeGuidString)]
+ [Guid(NemerleConstants.ProjectNodeGuidString)]
public class NemerleProjectNode : ProjectNode, IVsProjectSpecificEditorMap2
{
NemerlePackage _package;
@@ -36,7 +30,7 @@
{
_package = pkg;
- FileTemplateProcessor = new Nemerle.VsIntegration.Project.TokenProcessorEx();
+ FileTemplateProcessor = new NemerleTokenProcessor();
CanFileNodesHaveChilds = true;
SupportsProjectDesigner = true;
@@ -52,7 +46,7 @@
//
Type type = typeof(NemerleProjectNode);
Assembly assembly = type.Assembly;
- string resourceName = Utils.GetModuleName(type) + "." + GlobalConstants.ProjectImageListName;
+ string resourceName = Utils.GetModuleName(type) + "." + NemerleConstants.ProjectImageListName;
Stream imageStream = assembly.GetManifestResourceStream(resourceName);
Trace.Assert(imageStream != null);
@@ -74,7 +68,7 @@
// The following are not specific to Nemerle and as such we need a separate GUID
// (we simply used guidgen.exe to create new guids)
//
- AddCATIDMapping(typeof(FolderNodeProperties), new Guid(GlobalConstants.FolderNodePropertiesGuidString));
+ AddCATIDMapping(typeof(FolderNodeProperties), new Guid(NemerleConstants.FolderNodePropertiesGuidString));
// This one we use the same as Nemerle file nodes since both refer to files
//
@@ -132,7 +126,7 @@
get
{
if (_codeDomProvider == null)
- _codeDomProvider = new VSMDNemerleProvider();
+ _codeDomProvider = new NemerleVSMDCodeDomProvider();
return _codeDomProvider;
}
}
@@ -187,12 +181,12 @@
// ProjectNode.ImageName.Application.
public override int ImageIndex { get { return HierarchyNode.NoImage; } }
public override Guid ProjectGuid { get { return typeof(NemerleProjectFactory).GUID; } }
- public override string ProjectType { get { return GlobalConstants.LanguageName; } }
+ public override string ProjectType { get { return NemerleConstants.LanguageName; } }
internal override object Object { get { return VSProject; } }
protected override ReferenceContainerNode CreateReferenceContainerNode()
{
- return new ReferenceContainerNodeEx(this);
+ return new NemerleReferenceContainerNode(this);
}
#endregion
@@ -203,7 +197,7 @@
public override object GetIconHandle(bool open)
{
return PackageUtilities.GetIntPointerFromImage(
- NemerleProjectNode.NemerleImageList.Images[(int)GlobalConstants.ImageListIndex.NemerleProject]);
+ NemerleProjectNode.NemerleImageList.Images[(int)NemerleConstants.ImageListIndex.NemerleProject]);
}
public override int Close()
@@ -329,7 +323,7 @@
return
string.Compare(
Path.GetExtension(strFileName),
- GlobalConstants.FileExtension,
+ NemerleConstants.FileExtension,
StringComparison.OrdinalIgnoreCase) == 0;
}
@@ -364,9 +358,7 @@
public override int GetFormatList(out string formatlist)
{
formatlist = string.Format(
- CultureInfo.CurrentCulture,
- Nemerle.VsIntegration.Project.SR.GetString(Nemerle.VsIntegration.Project.SR.ProjectFileExtensionFilter),
- "\0", "\0");
+ CultureInfo.CurrentCulture, SR.GetString(SR.ProjectFileExtensionFilter), "\0", "\0");
return VSConstants.S_OK;
}
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 22:57:34 2006
@@ -4,13 +4,11 @@
using Microsoft.VisualStudio.Package;
-using Microsoft.Samples.VisualStudio.LanguageService;
-
namespace Nemerle.VisualStudio.Project
{
[ComVisible(true)]
[CLSCompliant(false)]
- [Guid(GlobalConstants.ProjectNodePropertiesGuidString)]
+ [Guid(NemerleConstants.ProjectNodePropertiesGuidString)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class NemerleProjectNodeProperties : ProjectNodeProperties
{
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleReferenceContainerNode.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,76 @@
+using System.IO;
+using System.Reflection;
+
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.Package.Automation;
+
+namespace Nemerle.VisualStudio.Project
+{
+ class NemerleReferenceContainerNode : ReferenceContainerNode
+ {
+ #region ctor
+
+ public NemerleReferenceContainerNode(ProjectNode root) : base(root)
+ {
+ }
+
+ #endregion
+
+ protected override AssemblyReferenceNode CreateAssemblyReferenceNode(ProjectElement element)
+ {
+ // VladD2:
+ // ReferenceContainerNode does not support reference to files (instead of
+ // get assembly name from file it tries to use file name as assembly name
+ // (via System.Reflection.AssemblyName()).
+
+ string item = element.Item.FinalItemSpec;
+
+ if (File.Exists(item))
+ return base.CreateAssemblyReferenceNode(item);
+ else
+ return base.CreateAssemblyReferenceNode(element);
+ }
+
+ public override void AddChild(HierarchyNode node)
+ {
+ base.AddChild(node);
+
+ NemerleProjectNode project = ProjectMgr as NemerleProjectNode;
+
+ if (project != null)
+ {
+ if (node is ComReferenceNode || node is AssemblyReferenceNode)
+ {
+ AssemblyName assemblyName = AssemblyName.GetAssemblyName(node.Url);
+
+ project.ProjectInfo.AddAssembly(assemblyName);
+ }
+ else if (node is ProjectReferenceNode)
+ {
+ project.ProjectInfo.AddProject((ProjectReferenceNode)node);
+ }
+ }
+ }
+
+ public override void RemoveChild(HierarchyNode node)
+ {
+ base.RemoveChild(node);
+
+ NemerleProjectNode project = ProjectMgr as NemerleProjectNode;
+
+ if (project != null)
+ {
+ if (node is ComReferenceNode || node is AssemblyReferenceNode)
+ {
+ AssemblyName assemblyName = AssemblyName.GetAssemblyName(node.Url);
+
+ project.ProjectInfo.RemoveAssembly(assemblyName);
+ }
+ else if (node is ProjectReferenceNode)
+ {
+ project.ProjectInfo.RemoveProject((ProjectReferenceNode)node);
+ }
+ }
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleTokenProcessor.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleTokenProcessor.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,23 @@
+using System.IO;
+
+using Microsoft.VisualStudio.Package;
+
+namespace Nemerle.VisualStudio.Project
+{
+ class NemerleTokenProcessor : TokenProcessor
+ {
+ public override void UntokenFile(string source, string destination)
+ {
+ // VladD2:
+ // If file is located in subdirectory, we need to create this subdirectory.
+ // TokenProcessor does not take it in account.
+ //
+ string destDir = Path.GetDirectoryName(destination);
+
+ if (!Directory.Exists(destDir))
+ Directory.CreateDirectory(destDir);
+
+ base.UntokenFile(source, destination);
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleVSMDCodeDomProvider.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/NemerleVSMDCodeDomProvider.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,23 @@
+using System;
+
+using Microsoft.VisualStudio.Designer.Interfaces;
+
+using Nemerle.Compiler.Utils;
+
+namespace Nemerle.VisualStudio.Project
+{
+ internal class NemerleVSMDCodeDomProvider : IVSMDCodeDomProvider
+ {
+ private object _codeDomProvider;
+ public object CodeDomProvider
+ {
+ get
+ {
+ if (_codeDomProvider == null)
+ _codeDomProvider = new NemerleCodeDomProvider();
+
+ return _codeDomProvider;
+ }
+ }
+ }
+}
\ No newline at end of file
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 22:57:34 2006
@@ -13,11 +13,9 @@
using Nemerle.Compiler;
using Nemerle.Completion2;
-using Nemerle.VisualStudio.Package;
-using Microsoft.Samples.VisualStudio.LanguageService;
+using Nemerle.VisualStudio.LanguageService;
using MSBuild = Microsoft.Build.BuildEngine;
-using NCC = Nemerle.Compiler;
namespace Nemerle.VisualStudio.Project
{
@@ -289,7 +287,6 @@
{
if (_project == null)
_project = Engine.GetProject();
-
return _project;
}
}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/PropertyPages.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/PropertyPages.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,336 @@
+using System;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+
+using EnvDTE;
+using EnvDTE80;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell.Interop;
+
+using MSP = Microsoft.VisualStudio.Package;
+
+namespace Nemerle.VisualStudio.Project
+{
+ internal enum GeneralPropertyPageTag
+ {
+ AssemblyName,
+ OutputType,
+ RootNamespace,
+ StartupObject,
+ ApplicationIcon,
+ TargetPlatform,
+ TargetPlatformLocation
+ }
+
+ /// <include file='doc\PropertyPages.uex' path='docs/doc[@for="GeneralPropertyPage"]/*' />
+ [ComVisible(true)]
+ [Guid(NemerleConstants.GeneralPropertyPageGuidString)]
+ public class GeneralPropertyPage : MSP.SettingsPage, IInternalExtenderProvider
+ {
+ #region LocDisplayNameAttribute
+
+ [AttributeUsage(
+ AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field,
+ Inherited = false,
+ AllowMultiple = false)]
+ sealed class LocDisplayNameAttribute : DisplayNameAttribute
+ {
+ string name;
+
+ public LocDisplayNameAttribute(string name)
+ {
+ this.name = name;
+ }
+
+ public override string DisplayName
+ {
+ get
+ {
+ string result = SR.GetString(name);
+
+ if (result == null)
+ {
+ Debug.Assert(false, "String resource '" + name + "' is missing");
+ result = name;
+ }
+
+ return result;
+ }
+ }
+ }
+
+ #endregion
+
+ #region Fields
+
+ string _assemblyName;
+ MSP.OutputType _outputType;
+ string _defaultNamespace;
+ string _startupObject;
+ string _applicationIcon;
+ MSP.PlatformType _targetPlatform = MSP.PlatformType.v2;
+ string _targetPlatformLocation;
+
+ #endregion
+
+ #region ctor
+
+ public GeneralPropertyPage()
+ {
+ Name = SR.GetString(SR.GeneralCaption);
+ }
+
+ #endregion
+
+ #region Overriden Methods
+
+ public override string GetClassName()
+ {
+ return GetType().FullName;
+ }
+
+ protected override void BindProperties()
+ {
+ if (ProjectMgr == null)
+ {
+ Debug.Assert(false);
+ return;
+ }
+
+ _assemblyName = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.AssemblyName.ToString(), true);
+
+ string outputType = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.OutputType.ToString(), false);
+
+ if (outputType != null && outputType.Length > 0)
+ {
+ try
+ {
+ _outputType = (MSP.OutputType)Enum.Parse(typeof(MSP.OutputType), outputType);
+ }
+ catch //Should only fail if project file is corrupt
+ {
+ }
+ }
+
+ _defaultNamespace = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.RootNamespace.ToString(), false);
+ _startupObject = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.StartupObject.ToString(), false);
+ _applicationIcon = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.ApplicationIcon.ToString(), false);
+
+ string targetPlatform = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.TargetPlatform.ToString(), false);
+
+ if (targetPlatform != null && targetPlatform.Length > 0)
+ {
+ try
+ {
+ _targetPlatform =
+ (MSP.PlatformType)Enum.Parse(typeof(MSP.PlatformType), targetPlatform);
+ }
+ catch
+ {
+ }
+ }
+
+ _targetPlatformLocation = ProjectMgr.GetProjectProperty(GeneralPropertyPageTag.TargetPlatformLocation.ToString(), false);
+ }
+
+ protected override int ApplyChanges()
+ {
+ if (ProjectMgr == null)
+ {
+ Debug.Assert(false);
+ return VSConstants.E_INVALIDARG;
+ }
+
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.AssemblyName.ToString(), _assemblyName);
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.OutputType.ToString(), _outputType.ToString());
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.RootNamespace.ToString(), _defaultNamespace);
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.StartupObject.ToString(), _startupObject);
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.ApplicationIcon.ToString(), _applicationIcon);
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.TargetPlatform.ToString(), _targetPlatform.ToString());
+ ProjectMgr.SetProjectProperty(GeneralPropertyPageTag.TargetPlatformLocation.ToString(), _targetPlatformLocation);
+
+ IsDirty = false;
+
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ #region exposed properties
+
+ [SRCategoryAttribute(SR.Application)]
+ [LocDisplayName(SR.AssemblyName)]
+ [SRDescriptionAttribute(SR.AssemblyNameDescription)]
+ public string AssemblyName
+ {
+ get { return _assemblyName; }
+ set { _assemblyName = value; IsDirty = true; }
+ }
+
+ [SRCategoryAttribute(SR.Application)]
+ [LocDisplayName(SR.OutputType)]
+ [SRDescriptionAttribute(SR.OutputTypeDescription)]
+ public MSP.OutputType OutputType
+ {
+ get { return _outputType; }
+ set { _outputType = value; IsDirty = true; }
+ }
+
+ [SRCategoryAttribute(SR.Application)]
+ [LocDisplayName(SR.DefaultNamespace)]
+ [SRDescriptionAttribute(SR.DefaultNamespaceDescription)]
+ public string DefaultNamespace
+ {
+ get { return _defaultNamespace; }
+ set { _defaultNamespace = value; IsDirty = true; }
+ }
+
+ [SRCategoryAttribute(SR.Application)]
+ [LocDisplayName(SR.StartupObject)]
+ [SRDescriptionAttribute(SR.StartupObjectDescription)]
+ public string StartupObject
+ {
+ get { return _startupObject; }
+ set { _startupObject = value; IsDirty = true; }
+ }
+
+ [SRCategoryAttribute(SR.Application)]
+ [LocDisplayName(SR.ApplicationIcon)]
+ [SRDescriptionAttribute(SR.ApplicationIconDescription)]
+ public string ApplicationIcon
+ {
+ get { return _applicationIcon; }
+ set { _applicationIcon = value; IsDirty = true; }
+ }
+
+ [SRCategoryAttribute(SR.Project)]
+ [LocDisplayName(SR.ProjectFile)]
+ [SRDescriptionAttribute(SR.ProjectFileDescription)]
+ [MSP.AutomationBrowsable(false)]
+ public string ProjectFile
+ {
+ get { return Path.GetFileName(ProjectMgr.ProjectFile); }
+ }
+
+ [SRCategoryAttribute(SR.Project)]
+ [LocDisplayName(SR.ProjectFolder)]
+ [SRDescriptionAttribute(SR.ProjectFolderDescription)]
+ [MSP.AutomationBrowsable(false)]
+ public string ProjectFolder
+ {
+ get { return Path.GetDirectoryName(ProjectMgr.ProjectFolder); }
+ }
+
+ [SRCategoryAttribute(SR.Project)]
+ [LocDisplayName(SR.OutputFile)]
+ [SRDescriptionAttribute(SR.OutputFileDescription)]
+ [MSP.AutomationBrowsable(false)]
+ public string OutputFile
+ {
+ get { return _assemblyName + NemerleProjectNode.GetOuputExtension(_outputType); }
+ }
+
+ [SRCategoryAttribute(SR.Project)]
+ [LocDisplayName(SR.TargetPlatform)]
+ [SRDescriptionAttribute(SR.TargetPlatformDescription)]
+ [MSP.AutomationBrowsable(false)]
+ public MSP.PlatformType TargetPlatform
+ {
+ get { return _targetPlatform; }
+ set { _targetPlatform = value; IsDirty = true; }
+ }
+
+ [SRCategoryAttribute(SR.Project)]
+ [LocDisplayName(SR.TargetPlatformLocation)]
+ [SRDescriptionAttribute(SR.TargetPlatformLocationDescription)]
+ [MSP.AutomationBrowsable(false)]
+ public string TargetPlatformLocation
+ {
+ get { return _targetPlatformLocation; }
+ set { _targetPlatformLocation = value; IsDirty = true; }
+ }
+
+ #endregion
+
+ #region IInternalExtenderProvider Members
+
+ bool IInternalExtenderProvider.CanExtend(string extenderCATID, string extenderName, object extendeeObject)
+ {
+ IVsHierarchy outerHierarchy = MSP.HierarchyNode.GetOuterHierarchy(ProjectMgr);
+
+ if (outerHierarchy is IInternalExtenderProvider)
+ return ((IInternalExtenderProvider)outerHierarchy).CanExtend(
+ extenderCATID, extenderName, extendeeObject);
+
+ return false;
+ }
+
+ object IInternalExtenderProvider.GetExtender(
+ string extenderCATID,
+ string extenderName,
+ object extendeeObject,
+ IExtenderSite extenderSite,
+ int cookie)
+ {
+ IVsHierarchy outerHierarchy = MSP.HierarchyNode.GetOuterHierarchy(ProjectMgr);
+
+ if (outerHierarchy is IInternalExtenderProvider)
+ return ((IInternalExtenderProvider)outerHierarchy).GetExtender(
+ extenderCATID, extenderName, extendeeObject, extenderSite, cookie);
+
+ return null;
+ }
+
+ object IInternalExtenderProvider.GetExtenderNames(string extenderCATID,
+ object extendeeObject)
+ {
+ IVsHierarchy outerHierarchy = MSP.HierarchyNode.GetOuterHierarchy(ProjectMgr);
+
+ if (outerHierarchy is IInternalExtenderProvider)
+ return ((IInternalExtenderProvider)outerHierarchy).GetExtenderNames(extenderCATID, extendeeObject);
+
+ return null;
+ }
+
+ #endregion
+
+ #region ExtenderSupport
+
+ [Browsable(false)]
+ [MSP.AutomationBrowsable(false)]
+ public virtual string ExtenderCATID
+ {
+ get
+ {
+ Guid catid = ProjectMgr.ProjectMgr.GetCATIDForType(GetType());
+
+ if (Guid.Empty.CompareTo(catid) == 0)
+ throw new NotImplementedException();
+
+ return catid.ToString("B");
+ }
+ }
+
+ [Browsable(false)]
+ [MSP.AutomationBrowsable(false)]
+ public object ExtenderNames
+ {
+ get
+ {
+ ObjectExtenders extenderService = (ObjectExtenders)ProjectMgr.GetService(typeof (ObjectExtenders));
+ return extenderService.GetExtenderNames(ExtenderCATID, this);
+ }
+ }
+
+ public object get_Extender(string extenderName)
+ {
+ ObjectExtenders extenderService = (ObjectExtenders)ProjectMgr.GetService(typeof (ObjectExtenders));
+ return extenderService.GetExtender(ExtenderCATID, extenderName, this);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/ScopeNode.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/ScopeNode.cs Sun Sep 24 22:57:34 2006
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+
+namespace Nemerle.VisualStudio.Project
+{
+ public class ScopeNode
+ {
+ private List<ScopeNode> _nested;
+
+ public IList<ScopeNode> NestedScopes
+ {
+ get { return _nested; }
+ }
+
+ public virtual string Name
+ {
+ get { return ""; }
+ }
+
+ public virtual string Doc
+ {
+ get { return ""; }
+ }
+
+ //public virtual Location Start
+ //{
+ // get
+ // {
+ // return Location.None;
+ // }
+ //}
+ //public virtual Location End
+ //{
+ // get
+ // {
+ // return Location.None;
+ // }
+ //}
+
+ public void Add(ScopeNode node)
+ {
+ if (_nested == null)
+ _nested = new List<ScopeNode>();
+
+ _nested.Add(node);
+ }
+ }
+}
Added: vs-plugin/trunk/Nemerle.VsIntegration/Project/SelectionElementValueChangedListener.cs
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.VsIntegration/Project/SelectionElementValueChangedListener.cs Sun Sep 24 22:57:34 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.Project
+{
+ 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 = pWind