[svn] r6374: vs-plugin/branches/andreif: CodeEngineering
CodeEngineering/AstManager.cs CodeEngineering/Cod...
andreif
svnadmin at nemerle.org
Tue Jun 6 18:34:51 CEST 2006
Log:
Author: andreif
Date: Tue Jun 6 18:22:26 2006
New Revision: 6374
Added:
vs-plugin/branches/andreif/CodeEngineering/
vs-plugin/branches/andreif/CodeEngineering/AstManager.cs
vs-plugin/branches/andreif/CodeEngineering/CodeEngine.cs
vs-plugin/branches/andreif/CodeEngineering/CodeEngineering.csproj
vs-plugin/branches/andreif/CodeEngineering/CodeEngineering.csproj.vspscc
vs-plugin/branches/andreif/CodeEngineering/CompilerWrapper.cs
vs-plugin/branches/andreif/CodeEngineering/CompletionSet.cs
vs-plugin/branches/andreif/CodeEngineering/Properties/
vs-plugin/branches/andreif/CodeEngineering/Properties/AssemblyInfo.cs
vs-plugin/branches/andreif/CodeEngineering/SourceDom/
vs-plugin/branches/andreif/CodeEngineering/SourceDom/CodeFile.cs
vs-plugin/branches/andreif/CodeEngineering/SourceDom/Project.cs
vs-plugin/branches/andreif/CodeEngineering/SourceDom/ProjectGroup.cs
vs-plugin/branches/andreif/CodeEngineering/TextLocation.cs
vs-plugin/branches/andreif/CodeEngineering/Util/
vs-plugin/branches/andreif/CodeEngineering/Util/DomainWrapper.cs
vs-plugin/branches/andreif/CodeEngineering/Util/Path.cs
vs-plugin/branches/andreif/CodeEngineering/Util/Util.cs
vs-plugin/branches/andreif/CodeEngineering/_README.txt
vs-plugin/branches/andreif/Common/
vs-plugin/branches/andreif/Common/Common.csproj
vs-plugin/branches/andreif/Common/Common.csproj.vspscc
vs-plugin/branches/andreif/Common/Const.cs
vs-plugin/branches/andreif/Common/Properties/
vs-plugin/branches/andreif/Common/Properties/AssemblyInfo.cs
vs-plugin/branches/andreif/Common/Settings.cs
vs-plugin/branches/andreif/NemerleLanguageService/
vs-plugin/branches/andreif/NemerleLanguageService/ColorableItem.cs
vs-plugin/branches/andreif/NemerleLanguageService/EventManager.cs
vs-plugin/branches/andreif/NemerleLanguageService/HierarchyScanner.cs
vs-plugin/branches/andreif/NemerleLanguageService/KeyboardInputFilter.cs
vs-plugin/branches/andreif/NemerleLanguageService/Msg.Designer.cs
vs-plugin/branches/andreif/NemerleLanguageService/Msg.resx
vs-plugin/branches/andreif/NemerleLanguageService/NemerleAuthoringScope.cs
vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguage.cs
vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguagePackage.cs
vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguageService.csproj
vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguageService.csproj.vspscc
vs-plugin/branches/andreif/NemerleLanguageService/NemerleSource.cs
vs-plugin/branches/andreif/NemerleLanguageService/NemerleTokenizer.cs
vs-plugin/branches/andreif/NemerleLanguageService/ProjectContentManager.cs
vs-plugin/branches/andreif/NemerleLanguageService/Properties/
vs-plugin/branches/andreif/NemerleLanguageService/Properties/AssemblyInfo.cs
vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/
vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsCodeFile.cs
vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsProject.cs
vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsProjectGroup.cs
vs-plugin/branches/andreif/NemerleLanguageService/VsCompletionVariants.cs
vs-plugin/branches/andreif/NemerleLanguageService/VsHostServices.cs
vs-plugin/branches/andreif/NemerleVsip.sln
vs-plugin/branches/andreif/Project/
vs-plugin/branches/andreif/Project/Automation.cs
vs-plugin/branches/andreif/Project/ConfigurationPropertyPages.cs
vs-plugin/branches/andreif/Project/Msg.Designer.cs
vs-plugin/branches/andreif/Project/Msg.resx
vs-plugin/branches/andreif/Project/NemerleConfigProvider.cs
vs-plugin/branches/andreif/Project/NemerleEditorFactory.cs
vs-plugin/branches/andreif/Project/NemerleFileNode.cs
vs-plugin/branches/andreif/Project/NemerleFileNodeProperties.cs
vs-plugin/branches/andreif/Project/NemerleMenus.cs
vs-plugin/branches/andreif/Project/NemerleProjectNode.cs
vs-plugin/branches/andreif/Project/NemerleProjectNodeProperties.cs
vs-plugin/branches/andreif/Project/NemerleProjectPackage.cs
vs-plugin/branches/andreif/Project/Project.csproj
vs-plugin/branches/andreif/Project/Project.csproj.user
vs-plugin/branches/andreif/Project/ProjectFactory.cs
vs-plugin/branches/andreif/Project/Properties/
vs-plugin/branches/andreif/Project/Properties/AssemblyInfo.cs
vs-plugin/branches/andreif/Project/PropertyPages.cs
vs-plugin/branches/andreif/Project/Resources/
vs-plugin/branches/andreif/Project/Resources/File.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Resources/Package.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Resources/Project.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Resources/Project_small.ico (contents, props changed)
vs-plugin/branches/andreif/Project/SR.cs
vs-plugin/branches/andreif/Project/Templates/
vs-plugin/branches/andreif/Project/Templates/ProjectItems/
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Class/
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Class/Class.n
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Class/Class.vstemplate
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Class/TemplateIcon.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Macro/
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Macro/Macro.n
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Macro/Macro.vstemplate
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Macro/TemplateIcon.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Text/
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Text/Text.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Text/TextFile.txt
vs-plugin/branches/andreif/Project/Templates/ProjectItems/Text/TextFile.vstemplate
vs-plugin/branches/andreif/Project/Templates/Projects/
vs-plugin/branches/andreif/Project/Templates/Projects/ClassLibrary/
vs-plugin/branches/andreif/Project/Templates/Projects/ClassLibrary/Class.n
vs-plugin/branches/andreif/Project/Templates/Projects/ClassLibrary/ClassLibrary.nproj
vs-plugin/branches/andreif/Project/Templates/Projects/ClassLibrary/ClassLibrary.vstemplate
vs-plugin/branches/andreif/Project/Templates/Projects/ClassLibrary/TemplateIcon.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/ConsoleApplication.nproj
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/ConsoleApplication.vstemplate
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/Program.n
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/TemplateIcon.ico (contents, props changed)
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/bin/
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/bin/Debug/
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/obj/
vs-plugin/branches/andreif/Project/Templates/Projects/ConsoleApplication/obj/Debug/
vs-plugin/branches/andreif/Project/Templates/Projects/MacroLibrary/
vs-plugin/branches/andreif/Project/Templates/Projects/MacroLibrary/Macro.n
vs-plugin/branches/andreif/Project/Templates/Projects/MacroLibrary/MacroLibrary.nproj
vs-plugin/branches/andreif/Project/Templates/Projects/MacroLibrary/MacroLibrary.vstemplate
vs-plugin/branches/andreif/Project/Templates/Projects/MacroLibrary/TemplateIcon.ico (contents, props changed)
vs-plugin/branches/andreif/ProjectBase/
vs-plugin/branches/andreif/ProjectBase/AggregatableProjectInterops.cs
vs-plugin/branches/andreif/ProjectBase/AssemblyReferenceNode.cs
vs-plugin/branches/andreif/ProjectBase/Attributes.cs
vs-plugin/branches/andreif/ProjectBase/Automation/
vs-plugin/branches/andreif/ProjectBase/Automation/OAFileItem.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAFolderItem.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OANavigableProjectItems.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OANestedProjectItem.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OANullProperty.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAProject.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAProjectItem.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAProjectItems.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAProperties.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAProperty.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OAReferenceFolderItem.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OARreferenceItem.cs
vs-plugin/branches/andreif/ProjectBase/Automation/OASolutionFolder.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAAssemblyReference.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OABuildManager.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAComReference.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAProjectReference.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAReferenceBase.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAReferences.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAVSProject.cs
vs-plugin/branches/andreif/ProjectBase/Automation/VSProject/OAVSProjectItem.cs
vs-plugin/branches/andreif/ProjectBase/BuildDependency.cs
vs-plugin/branches/andreif/ProjectBase/BuildPropertyPage.cs
vs-plugin/branches/andreif/ProjectBase/ComReferenceNode.cs
vs-plugin/branches/andreif/ProjectBase/ConfigProvider.cs
vs-plugin/branches/andreif/ProjectBase/ConfigurationProperties.cs
vs-plugin/branches/andreif/ProjectBase/DataObject.cs
vs-plugin/branches/andreif/ProjectBase/DesignPropertyDescriptor.cs
vs-plugin/branches/andreif/ProjectBase/Diagrams/
vs-plugin/branches/andreif/ProjectBase/Diagrams/AutomationClasses.cd
vs-plugin/branches/andreif/ProjectBase/Diagrams/ConfigurationClasses.cd
vs-plugin/branches/andreif/ProjectBase/Diagrams/DocumentManagerClasses.cd
vs-plugin/branches/andreif/ProjectBase/Diagrams/HierarchyClasses.cd
vs-plugin/branches/andreif/ProjectBase/Diagrams/PropertiesClasses.cd
vs-plugin/branches/andreif/ProjectBase/Diagrams/ReferenceClasses.cd
vs-plugin/branches/andreif/ProjectBase/DocumentManager.cs
vs-plugin/branches/andreif/ProjectBase/EnumDependencies.cs
vs-plugin/branches/andreif/ProjectBase/FileDocumentManager.cs
vs-plugin/branches/andreif/ProjectBase/FileNode.cs
vs-plugin/branches/andreif/ProjectBase/FlavoredProjectBase.cs
vs-plugin/branches/andreif/ProjectBase/FlavoredProjectFactoryBase.cs
vs-plugin/branches/andreif/ProjectBase/FolderNode.cs
vs-plugin/branches/andreif/ProjectBase/HierarchyNode.cs
vs-plugin/branches/andreif/ProjectBase/IDEBuildLogger.cs
vs-plugin/branches/andreif/ProjectBase/Interfaces.cs
vs-plugin/branches/andreif/ProjectBase/LocalizableProperties.cs
vs-plugin/branches/andreif/ProjectBase/Microsoft.VisualStudio.Package.Project.cs
vs-plugin/branches/andreif/ProjectBase/Microsoft.VisualStudio.Package.Project.resx
vs-plugin/branches/andreif/ProjectBase/Misc/
vs-plugin/branches/andreif/ProjectBase/Misc/ConnectionPointContainer.cs
vs-plugin/branches/andreif/ProjectBase/Misc/ExternDll.cs
vs-plugin/branches/andreif/ProjectBase/Misc/HelpService.cs
vs-plugin/branches/andreif/ProjectBase/Misc/NativeMethods.cs
vs-plugin/branches/andreif/ProjectBase/Misc/SafeNativeMethods.cs
vs-plugin/branches/andreif/ProjectBase/Misc/UnsafeNativeMethods.cs
vs-plugin/branches/andreif/ProjectBase/NestedProjectBuildDependency.cs
vs-plugin/branches/andreif/ProjectBase/NestedProjectNode.cs
vs-plugin/branches/andreif/ProjectBase/NodeProperties.cs
vs-plugin/branches/andreif/ProjectBase/OleServiceProvider.cs
vs-plugin/branches/andreif/ProjectBase/Output.cs
vs-plugin/branches/andreif/ProjectBase/OutputGroup.cs
vs-plugin/branches/andreif/ProjectBase/ProjectAggregator2Interops.cs
vs-plugin/branches/andreif/ProjectBase/ProjectBase.csproj
vs-plugin/branches/andreif/ProjectBase/ProjectBase.files
vs-plugin/branches/andreif/ProjectBase/ProjectConfig.cs
vs-plugin/branches/andreif/ProjectBase/ProjectContainerNode.cs
vs-plugin/branches/andreif/ProjectBase/ProjectDesignerDocumentManager.cs
vs-plugin/branches/andreif/ProjectBase/ProjectElement.cs
vs-plugin/branches/andreif/ProjectBase/ProjectFactory.cs
vs-plugin/branches/andreif/ProjectBase/ProjectFileConstants.cs
vs-plugin/branches/andreif/ProjectBase/ProjectNode.cs
vs-plugin/branches/andreif/ProjectBase/ProjectOptions.cs
vs-plugin/branches/andreif/ProjectBase/ProjectPackage.cs
vs-plugin/branches/andreif/ProjectBase/ProjectReferenceNode.cs
vs-plugin/branches/andreif/ProjectBase/Properties/
vs-plugin/branches/andreif/ProjectBase/Properties/AssemblyInfo.cs
vs-plugin/branches/andreif/ProjectBase/ReferenceContainerNode.cs
vs-plugin/branches/andreif/ProjectBase/ReferenceNode.cs
vs-plugin/branches/andreif/ProjectBase/RegisteredProjectType.cs
vs-plugin/branches/andreif/ProjectBase/Resources/
vs-plugin/branches/andreif/ProjectBase/Resources/imagelis.bmp (contents, props changed)
vs-plugin/branches/andreif/ProjectBase/SettingsPage.cs
vs-plugin/branches/andreif/ProjectBase/SolutionListener.cs
vs-plugin/branches/andreif/ProjectBase/SolutionListenerForBuildDependencyUpdate.cs
vs-plugin/branches/andreif/ProjectBase/SolutionListenerForProjectOpen.cs
vs-plugin/branches/andreif/ProjectBase/SolutionListenerForProjectReferenceUpdate.cs
vs-plugin/branches/andreif/ProjectBase/StructuresEnums.cs
vs-plugin/branches/andreif/ProjectBase/SuspendFileChanges.cs
vs-plugin/branches/andreif/ProjectBase/TokenProcessor.cs
vs-plugin/branches/andreif/ProjectBase/Tracing.cs
vs-plugin/branches/andreif/ProjectBase/TrackDocumentsHelper.cs
vs-plugin/branches/andreif/ProjectBase/TypeConverters.cs
vs-plugin/branches/andreif/ProjectBase/Url.cs
vs-plugin/branches/andreif/ProjectBase/Utilities.cs
vs-plugin/branches/andreif/ProjectBase/VSMDCodeDomProvider.cs
vs-plugin/branches/andreif/ProjectBase/VSShellUtilities.cs
vs-plugin/branches/andreif/ProjectBase/VsCommands.cs
vs-plugin/branches/andreif/VsipSetup/
vs-plugin/branches/andreif/VsipSetup/Final/
vs-plugin/branches/andreif/VsipSetup/VsipSetup.vdproj
vs-plugin/branches/andreif/done.txt
Added: vs-plugin/branches/andreif/CodeEngineering/AstManager.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/AstManager.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using Nemerle.Vsip.CodeEngineering.Util;
+using Nemerle.Completion;
+
+namespace Nemerle.Vsip.CodeEngineering
+{
+ class AstManager : IDisposable
+ {
+ public AstManager(string projectCaption)
+ {
+ _domain = new DomainWrapper("Parsing_" + projectCaption);
+ _compiler = _domain.CreateInstanceInDomain<CompilerWrapper>();
+ _compiler.Init();
+ }
+
+ public void LoadFile(CodeFile file)
+ {
+ AddFile(file);
+ }
+
+ public void AddFile(CodeFile file)
+ {
+ if (file.IsSourceFile)
+ _compiler.AddSource(file.FullName, file.GetContent());
+ if (file.IsAssembly)
+ _compiler.AddReference(file.Name, file.FullName);
+ }
+
+ public void RemoveFile(CodeFile file)
+ {
+ if (file.IsSourceFile)
+ _compiler.RemoveSource(file.FullName);
+ if (file.IsAssembly)
+ _compiler.RemoveReference(file.Name);
+ }
+
+ CompilerWrapper _compiler;
+ DomainWrapper _domain;
+
+ public TypeTree GetTypeTree()
+ {
+ return _compiler.GetTypeTree();
+ }
+
+ public CompletionInfo GetCompletion(TextLocation loc, string contents)
+ {
+ return _compiler.GetCompletion(FindMember(loc), contents);
+ }
+
+ NemerleMemberInfo FindMember(TextLocation loc)
+ {
+ DeclaredTypeInfo type = FindType(loc);
+ return null;
+ }
+
+ DeclaredTypeInfo FindType(DeclaredTypeInfo[] types, TextLocation loc)
+ {
+ foreach (DeclaredTypeInfo type in types)
+ {
+ if (type.Location.Line < loc.Line && type.Location.EndLine > loc.Line
+ && type.Location.Column < loc.Column && type.Location.EndColumn > loc.Column)
+ {
+ if (type.NestedTypes.Length == 0)
+ return type;
+ else
+ return FindType(type.NestedTypes, loc);
+ }
+ }
+ throw new KeyNotFoundException();
+ }
+
+ DeclaredTypeInfo FindType(TextLocation loc)
+ {
+ TypeTree tree = GetTypeTree();
+ return FindType(tree.Types, loc);
+ }
+
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ _domain.Dispose();
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/CodeEngine.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/CodeEngine.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using Nemerle.Compiler;
+using Nemerle.Vsip.CodeEngineering.Util;
+using Nemerle.Completion;
+
+namespace Nemerle.Vsip.CodeEngineering
+{
+ /// <summary>
+ /// Root class for all code engineering functionality
+ /// </summary>
+ public class CodeEngine
+ {
+ public CodeEngine()
+ {
+ }
+
+ CompletionSet _keywords = new CompletionSet(LexerBase.BaseKeywords);
+
+ /// <summary>
+ /// Gets last word from the end of the line
+ /// </summary>
+ /// <param name="str"></param>
+ /// <param name="location"></param>
+ /// <returns></returns>
+ static string GetWordForCompletion(string str, TextLocation location)
+ {
+ int startPos = str.Length;
+ for (int i = str.Length - 1; i >= 0; i--)
+ {
+ if (!Char.IsLetterOrDigit(str[i]) && str[i] != '_')
+ {
+ startPos = i + 1;
+ break;
+ }
+ }
+ return str.Substring(startPos, str.Length - startPos);
+ }
+
+ public IList<string> CompleteSentence(CodeFile file, TextLocation location)
+ {
+ string text = file.GetLines(location.Line, location.Line);
+ text = text.Substring(0, location.Column);
+ string word = GetWordForCompletion(text, location);
+ if (String.IsNullOrEmpty(word))
+ return new List<string>();
+ CompletionInfo info = file.Project.Dom.GetCompletion(location, word);
+ return _keywords.FindCompletions(word);
+ }
+
+ public void ShutDown()
+ {
+ }
+
+ public void MasterInit()
+ {
+ }
+
+ IProjectGroup _projectGroup;
+
+ public IProjectGroup ProjectGroup
+ {
+ get { return _projectGroup; }
+ }
+
+ public void InitProjectGroup(IProjectGroup projectGroup)
+ {
+ _projectGroup = projectGroup;
+ _projectGroup.InitDom();
+ }
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/CodeEngineering.csproj
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/CodeEngineering.csproj Tue Jun 6 18:22:26 2006
@@ -0,0 +1,74 @@
+ďťż<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{974E1CBE-EB8D-420F-A94C-A0ACBA311B18}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Nemerle.Vsip.CodeEngineering</RootNamespace>
+ <AssemblyName>Nemerle.Vsip.CodeEngineering</AssemblyName>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Nemerle, Version=0.9.1.0, Culture=neutral, PublicKeyToken=e080a9c724e2bfcd, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ <Reference Include="Nemerle.Compiler, Version=0.9.1.0, Culture=neutral, PublicKeyToken=5291d186334f6101, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CodeEngine.cs" />
+ <Compile Include="CompletionSet.cs" />
+ <Compile Include="AstManager.cs" />
+ <Compile Include="SourceDom\CodeFile.cs" />
+ <Compile Include="SourceDom\Project.cs" />
+ <Compile Include="SourceDom\ProjectGroup.cs" />
+ <Compile Include="CompilerWrapper.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TextLocation.cs" />
+ <Compile Include="Util\DomainWrapper.cs" />
+ <Compile Include="Util\Path.cs" />
+ <Compile Include="Util\Util.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="_README.txt" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: vs-plugin/branches/andreif/CodeEngineering/CodeEngineering.csproj.vspscc
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/CodeEngineering.csproj.vspscc Tue Jun 6 18:22:26 2006
@@ -0,0 +1,10 @@
+ďťż""
+{
+"FILE_VERSION" = "9237"
+"ENLISTMENT_CHOICE" = "NEVER"
+"PROJECT_FILE_RELATIVE_PATH" = "relative:CodeEngineering"
+"NUMBER_OF_EXCLUDED_FILES" = "0"
+"ORIGINAL_PROJECT_FILE_PATH" = ""
+"NUMBER_OF_NESTED_PROJECTS" = "0"
+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
+}
Added: vs-plugin/branches/andreif/CodeEngineering/CompilerWrapper.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/CompilerWrapper.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+
+using Nemerle.Compiler;
+using Nemerle.Completion;
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using System.IO;
+
+namespace Nemerle.Vsip.CodeEngineering
+{
+ class CompilerWrapper : MarshalByRefObject
+ {
+ public CompilerWrapper()
+ {
+ }
+
+ public void Init()
+ {
+ Engine.Init();
+ Assembly asm = Assembly.Load("mscorlib");
+ Engine.References.Add(asm.GetName().Name, asm);
+ }
+
+ public void AddReference(string key, string name)
+ {
+ Assembly asm = Assembly.LoadFile(name);
+ Engine.References.Add(key, asm);
+ }
+
+ public void RemoveReference(string key)
+ {
+ Engine.References.Remove(key);
+ }
+
+ public void AddSource(string fileName, string content)
+ {
+ Engine.Sources.Add(fileName, content);
+ }
+
+ public void RemoveSource(string fileName)
+ {
+ Engine.Sources.Remove(fileName);
+ }
+
+ public TypeTree GetTypeTree()
+ {
+ return Engine.GetTypeTree();
+ }
+
+ public CompletionInfo GetCompletion(NemerleMemberInfo memberInfo, string contents)
+ {
+ return Engine.RunCompletionEngine(memberInfo, contents);
+ }
+ }
+}
+
+ //public override bool IsGacAssembly
+ //{
+ // get
+ // {
+ // if (!IsAssembly)
+ // return false;
+ // return RuntimeEnvironment.FromGlobalAccessCache(_asm);
+ // }
+ //}
Added: vs-plugin/branches/andreif/CodeEngineering/CompletionSet.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/CompletionSet.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,93 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Nemerle.Vsip.CodeEngineering
+{
+ internal class CompletionSet : ICollection<string>
+ {
+ public CompletionSet(IEnumerable<string> vals)
+ {
+ _vals = new List<string>(vals);
+ }
+
+ List<string> _vals;
+
+ /// <summary>
+ /// Currently, this method returns all words, which have at least one common letter in the beginning.
+ /// Later it will be necessary to rank these words by amount of common part; to handle cases,
+ /// when user types in wrong case, when he wrote come chars in wrong order, etc
+ /// </summary>
+ /// <param name="item"></param>
+ /// <returns></returns>
+ public IList<string> FindCompletions(string item)
+ {
+ if (String.IsNullOrEmpty(item))
+ throw new ArgumentException();
+ List<string> res = new List<string>();
+ foreach (string cur in _vals)
+ {
+ int len = GetLengthOfEqualParts(cur, item);
+ if (len > 0 && cur.Length > item.Length)
+ res.Add(cur);
+ }
+ return res;
+ }
+
+ static int GetLengthOfEqualParts(string str, string pattern)
+ {
+ for (int i = 0; i < pattern.Length; i++)
+ {
+ if (str[i] != pattern[i] || i >= str.Length)
+ return i;
+ }
+ return Math.Min(str.Length, pattern.Length);
+ }
+
+ public void Add(string item)
+ {
+ _vals.Add(item);
+ }
+
+ public void Clear()
+ {
+ _vals.Clear();
+ }
+
+ public bool Contains(string item)
+ {
+ return _vals.Contains(item);
+ }
+
+ public void CopyTo(string[] array, int arrayIndex)
+ {
+ _vals.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return _vals.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public bool Remove(string item)
+ {
+ return _vals.Remove(item);
+ }
+
+ public IEnumerator<string> GetEnumerator()
+ {
+ return _vals.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return this.GetEnumerator();
+ }
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/Properties/AssemblyInfo.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,35 @@
+ďťżusing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("CompletionEngine")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CompletionEngine")]
+[assembly: AssemblyCopyright("Copyright Š 2006")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("484cb031-a197-45c2-8327-48ebe1ffdc57")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: vs-plugin/branches/andreif/CodeEngineering/SourceDom/CodeFile.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/SourceDom/CodeFile.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Nemerle.Vsip.CodeEngineering.SourceDom
+{
+ /// <summary>
+ /// Represents a physical file containing type definitions;
+ /// it may be a source file, or a compiled assembly file
+ /// </summary>
+ public abstract class CodeFile : IDisposable
+ {
+ public CodeFile(Project owner)
+ {
+ _project = owner;
+ }
+
+ /// <summary>
+ /// Short name - necessary for assemblies
+ /// </summary>
+ public abstract string Name { get; }
+
+ /// <summary>
+ /// Name of the file, including path
+ /// </summary>
+ public abstract string FullName { get; }
+
+ /// <summary>
+ /// Text of the file (get it from the disc, or from the editor - if the file was modified and not saved
+ /// </summary>
+ /// <returns></returns>
+ public abstract string GetContent();
+ public abstract string GetLines(int start, int end);
+
+ public abstract DateTime LastModified { get; }
+ public abstract int Size { get; }
+ public abstract bool IsSourceFile { get; }
+ public abstract bool IsAssembly { get; }
+ public abstract bool IsInEditMode { get; }
+ public abstract bool IsSaved { get; }
+
+ Project _project;
+
+ public Project Project
+ {
+ get { return _project; }
+ }
+
+ public bool IsContentEqual(CodeFile that)
+ {
+ if (!this.IsSaved || !that.IsSaved)
+ {
+ throw new NotImplementedException();
+ }
+ return (this.Size == that.Size) && (this.LastModified == that.LastModified);
+ }
+
+ public override bool Equals(object obj)
+ {
+ CodeFile that = obj as CodeFile;
+ if (that == null)
+ return false;
+ return (this.FullName == that.FullName);
+ }
+
+ public override int GetHashCode()
+ {
+ return FullName.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return FullName;
+ }
+
+ public virtual void OnChange(TextLocation loc)
+ {
+ }
+
+ #region IDisposable Members
+
+ public virtual void Dispose()
+ {
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/SourceDom/Project.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/SourceDom/Project.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,72 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+using Nemerle.Vsip.CodeEngineering.Util;
+
+namespace Nemerle.Vsip.CodeEngineering.SourceDom
+{
+ public abstract class Project : IDisposable
+ {
+ public Project(IProjectGroup owner)
+ {
+ _group = owner;
+ }
+
+ public void InitDom()
+ {
+ _dom = new AstManager(this.Caption);
+
+ foreach (CodeFile file in Files)
+ {
+ _dom.LoadFile(file);
+ }
+ }
+
+ public abstract CodeFile GetFile(string path);
+ public abstract string FullName { get; }
+ public abstract string Caption { get; }
+
+ public abstract IEnumerable<CodeFile> Files { get; }
+ public abstract IEnumerable<CodeFile> References { get; }
+ public abstract IEnumerable<CodeFile> SourceFiles { get; }
+
+ protected void OnAddFile(CodeFile file)
+ {
+ _dom.AddFile(file);
+ }
+
+ protected void OnRemoveFile(CodeFile file)
+ {
+ _dom.RemoveFile(file);
+ }
+
+ AstManager _dom;
+
+ internal AstManager Dom
+ {
+ get { return _dom; }
+ }
+
+ IProjectGroup _group;
+
+ public IProjectGroup ProjectGroup
+ {
+ get { return _group; }
+ }
+
+ #region IDisposable Members
+
+ public virtual void Dispose()
+ {
+ foreach (CodeFile file in Files)
+ {
+ file.Dispose();
+ }
+ _dom.Dispose();
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/SourceDom/ProjectGroup.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/SourceDom/ProjectGroup.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+using Nemerle.Vsip.CodeEngineering.Util;
+
+namespace Nemerle.Vsip.CodeEngineering.SourceDom
+{
+ public interface IProjectGroup : IDisposable
+ {
+ IList<Project> Projects
+ {
+ get;
+ }
+
+ void InitDom();
+ CodeFile GetOpenedFile(Path path);
+ }
+
+ public abstract class ProjectGroup<T_Project> : IProjectGroup
+ where T_Project : Project
+ {
+ List<T_Project> _projects = new List<T_Project>();
+
+ public void AddProject(T_Project p)
+ {
+ _projects.Add(p);
+ }
+
+ public void RemoveProject(T_Project p)
+ {
+ }
+
+ public IList<T_Project> Projects
+ {
+ [DebuggerStepThrough]
+ get { return _projects.AsReadOnly(); }
+ }
+
+ public void ClearProjects()
+ {
+ _projects.Clear();
+ }
+
+ IList<Project> IProjectGroup.Projects
+ {
+ get { return this._projects.ToArray(); }
+ }
+
+ public abstract CodeFile GetOpenedFile(Path path);
+
+ public void InitDom()
+ {
+ foreach (Project proj in Projects)
+ {
+ proj.InitDom();
+ }
+ }
+
+ #region IDisposable Members
+
+ public virtual void Dispose()
+ {
+ foreach (Project proj in Projects)
+ {
+ proj.Dispose();
+ }
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/TextLocation.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/TextLocation.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Nemerle.Vsip.CodeEngineering
+{
+ public struct TextLocation
+ {
+ public TextLocation(int line, int col)
+ {
+ _line = line;
+ _column = col;
+ }
+
+ int _line;
+
+ public int Line
+ {
+ get { return _line; }
+ set { _line = value; }
+ }
+
+ int _column;
+
+ public int Column
+ {
+ get { return _column; }
+ set { _column = value; }
+ }
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/Util/DomainWrapper.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/Util/DomainWrapper.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Security;
+using System.Security.Permissions;
+using System.Reflection;
+using System.Diagnostics;
+using System.Runtime.Remoting;
+
+namespace Nemerle.Vsip.CodeEngineering.Util
+{
+ class DomainWrapper : IDisposable
+ {
+ public DomainWrapper()
+ : this(Guid.NewGuid().ToString())
+ {
+ }
+
+ public DomainWrapper(string name)
+ {
+ AppDomainSetup setup = (AppDomainSetup)ObjectUtil.Clone(AppDomain.CurrentDomain.SetupInformation);
+ //setup.ShadowCopyFiles = "true";
+ setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
+ setup.PrivateBinPath =
+ System.IO.Path.GetDirectoryName(Assembly.GetCallingAssembly().CodeBase);
+ PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
+ _domain = AppDomain.CreateDomain(name, null, setup, permissions);
+ }
+
+ // HACK see http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=276520&SiteID=1
+ // damned Microsoft's idiots :(
+ static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
+ {
+ return Assembly.GetExecutingAssembly().FullName == args.Name ? Assembly.GetExecutingAssembly() : null;
+ }
+
+ public T CreateInstanceInDomain<T>()
+ where T : MarshalByRefObject
+ {
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
+
+ try
+ {
+ Type type = typeof(T);
+ string asmName = type.Assembly.Location;
+ ObjectHandle obj = _domain.CreateInstanceFrom(asmName, type.FullName);
+ MarshalByRefObject tmp = (MarshalByRefObject)obj.Unwrap();
+ return (T)tmp;
+ }
+ finally
+ {
+ AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(CurrentDomain_AssemblyResolve);
+ }
+ }
+
+ AppDomain _domain;
+
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ AppDomain.Unload(_domain);
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/Util/Path.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/Util/Path.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Nemerle.Vsip.CodeEngineering.Util
+{
+ public struct Path
+ {
+ public Path(string val)
+ {
+ _val = System.IO.Path.GetFullPath(val);
+ // this assumed to unify / and \ slashes, remove duplicate slashes
+ }
+
+ string _val;
+
+ public override string ToString()
+ {
+ return _val;
+ }
+
+ public override int GetHashCode()
+ {
+ return _val.ToLower().GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is Path))
+ return false;
+ Path that = (Path)obj;
+ return (this == that);
+ }
+
+ public static bool operator ==(Path left, Path right)
+ {
+ return (String.Compare(left._val, right._val, true) == 0);
+ }
+
+ public static bool operator !=(Path left, Path right)
+ {
+ return !(left == right);
+ }
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/Util/Util.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/Util/Util.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.IO;
+
+namespace Nemerle.Vsip.CodeEngineering.Util
+{
+ public static class ObjectUtil
+ {
+ public static object Clone(object val)
+ {
+ BinaryFormatter bf = new BinaryFormatter();
+ MemoryStream s = new MemoryStream();
+ bf.Serialize(s, val);
+ s.Position = 0;
+ object res = bf.Deserialize(s);
+ return res;
+ }
+ }
+}
Added: vs-plugin/branches/andreif/CodeEngineering/_README.txt
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/CodeEngineering/_README.txt Tue Jun 6 18:22:26 2006
@@ -0,0 +1,8 @@
+Provides IDE-independent functionality (or will provide it :) for the following:
+-Parsing source code of the projects and maintaining actual code model when code changes
+-Persistence of code model
+-Code completion
+-Code snippets
+-Navigation
+-Refactoring capabilities
+-Performing code metrics and audits
\ No newline at end of file
Added: vs-plugin/branches/andreif/Common/Common.csproj
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/Common/Common.csproj Tue Jun 6 18:22:26 2006
@@ -0,0 +1,56 @@
+ďťż<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9DBD6BDD-C115-4930-92B6-D30C30EB2F6A}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Nemerle.Vsip.Common</RootNamespace>
+ <AssemblyName>Nemerle.Vsip.Common</AssemblyName>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Const.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Settings.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: vs-plugin/branches/andreif/Common/Common.csproj.vspscc
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/Common/Common.csproj.vspscc Tue Jun 6 18:22:26 2006
@@ -0,0 +1,10 @@
+ďťż""
+{
+"FILE_VERSION" = "9237"
+"ENLISTMENT_CHOICE" = "NEVER"
+"PROJECT_FILE_RELATIVE_PATH" = "relative:Common"
+"NUMBER_OF_EXCLUDED_FILES" = "0"
+"ORIGINAL_PROJECT_FILE_PATH" = ""
+"NUMBER_OF_NESTED_PROJECTS" = "0"
+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
+}
Added: vs-plugin/branches/andreif/Common/Const.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/Common/Const.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace Nemerle.Vsip.Common
+{
+ public static class Const
+ {
+#if !DEBUG
+ public const string RegistryRoot = "Software\\Microsoft\\VisualStudio\\8.0";
+#else
+ public const string RegistryRoot = "Software\\Microsoft\\VisualStudio\\8.0Exp";
+#endif
+
+ public const string LanguageName = "Nemerle";
+
+ public const string MainFile = "MainFile";
+ public const string ProjectPackage = "090A3C1C-16B5-4190-A25B-DC274A1AE54F";
+ public const string ProjectFactory = "0C332D7E-629F-4a3b-9CF0-76E22A722F56";
+ public const string ProjectNode = "00E400C1-5FCE-4204-8B3E-273BDA845EB4";
+
+ public const string GuidEditorFactoryString = "d6479b0f-5a8b-411c-95eb-357044fc97bb";
+ public static readonly Guid GuidEditorFactory = new Guid(GuidEditorFactoryString);
+
+ public const string GuidCmdSetString = "9534fae2-57de-4470-8e4a-ff5504dd3cbc";
+ public static readonly Guid GuidCmdSet = new Guid(GuidCmdSetString);
+
+ public const string NemerleFileExtension = ".n";
+ public const string NemerleProjectFileExtension = ".nproj";
+
+ public const string LibraryManagerServiceGuidString = "72A40831-3790-4811-84AF-76523038320E";
+ public const string LibraryManagerGuidString = "311C6C38-90D2-453c-8755-CE431C8CCAE2";
+
+ public const string LanguagePackageGuidString = "3E2F8319-EC0D-438d-AA02-BDE4EB44AFC1";
+
+ public static class GuidString
+ {
+ public const string LanguageService = "0F15B13F-4C95-405f-97A5-7E0E341C4FD3";
+
+ public const string LOGVIEWID_Designer = "{7651a702-06e5-11d1-8ebd-00a0c90f26ea}";
+ public const string LOGVIEWID_Code = "{7651a701-06e5-11d1-8ebd-00a0c90f26ea}";
+ }
+
+ public static bool IsNemerleCodeFile(string name)
+ {
+ string extension = Path.GetExtension(name);
+ return (String.Compare(extension, NemerleFileExtension, true) == 0);
+ }
+
+ public static bool IsNemerleProjectFile(string name)
+ {
+ string extension = Path.GetExtension(name);
+ return (String.Compare(extension, NemerleProjectFileExtension, true) == 0);
+ }
+
+ public static bool IsClassLibraryFile(string name)
+ {
+ string extension = Path.GetExtension(name);
+ return (String.Compare(extension, ".dll", true) == 0);
+ }
+ }
+}
Added: vs-plugin/branches/andreif/Common/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/Common/Properties/AssemblyInfo.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,35 @@
+ďťżusing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Common")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Common")]
+[assembly: AssemblyCopyright("Copyright Š 2006")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("761d8d58-3225-456d-acc0-7b8f686092c6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: vs-plugin/branches/andreif/Common/Settings.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/Common/Settings.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Nemerle.Vsip.Common
+{
+ public class Settings
+ {
+ public Settings()
+ {
+ }
+
+ static Settings _instance;
+ static object _sync = new object();
+
+ public static Settings Instance
+ {
+ get
+ {
+ lock (_sync)
+ {
+ if (_instance == null)
+ _instance = new Settings();
+ return Settings._instance;
+ }
+ }
+ }
+
+ TimeSpan _autoCompleteDelay = new TimeSpan(1000000);
+
+ public TimeSpan AutoCompleteDelay
+ {
+ get { return _autoCompleteDelay; }
+ set { _autoCompleteDelay = value; }
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/ColorableItem.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/ColorableItem.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,61 @@
+using System;
+
+using Microsoft.VisualStudio.TextManager.Interop;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ public class ColorableItem : IVsColorableItem
+ {
+ private string _displayName;
+ private COLORINDEX _background;
+ private COLORINDEX _foreground;
+
+ public ColorableItem(string displayName, COLORINDEX foreground, COLORINDEX background)
+ {
+ this._displayName = displayName;
+ this._background = background;
+ this._foreground = foreground;
+ }
+
+ #region IVsColorableItem Members
+
+ public int GetDefaultColors(COLORINDEX[] foreground, COLORINDEX[] background)
+ {
+ if (null == foreground)
+ {
+ throw new ArgumentNullException("invalid foreground");
+ }
+ if (0 == foreground.Length)
+ {
+ throw new ArgumentOutOfRangeException("invalid foreground");
+ }
+ foreground[0] = _foreground;
+
+ if (null == background)
+ {
+ throw new ArgumentNullException("invalid background");
+ }
+ if (0 == background.Length)
+ {
+ throw new ArgumentOutOfRangeException("invalid background");
+ }
+ background[0] = _background;
+
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+
+ public int GetDefaultFontFlags(out uint pdwFontFlags)
+ {
+ pdwFontFlags = 0;
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+
+ public int GetDisplayName(out string pbstrName)
+ {
+ pbstrName = _displayName;
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/EventManager.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/EventManager.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.Shell.Interop;
+using VSConstants = Microsoft.VisualStudio.VSConstants;
+using IServiceProvider = System.IServiceProvider;
+using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio;
+
+using Nemerle.Vsip.NemerleLanguageService.SourceDom;
+using Nemerle.Vsip.Common;
+using Nemerle.Vsip.CodeEngineering;
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ /// <summary>
+ /// Gets IDE events
+ /// </summary>
+ [Guid(Const.LibraryManagerServiceGuidString)]
+ public interface INemerleSolutionEvents
+ {
+ void RegisterProject(IVsHierarchy hierarchy);
+ void UnregisterProject(IVsHierarchy hierarchy);
+ void AfterSolutionLoaded();
+ void BeforeSolutionClosing();
+ }
+
+ [Guid(Const.LibraryManagerGuidString)]
+ public class EventManager : INemerleSolutionEvents, IDisposable
+ {
+ private IServiceProvider _provider;
+
+ VsProjectGroup _solution;
+
+ public EventManager(IServiceProvider provider)
+ {
+ this._provider = provider;
+
+ try
+ {
+ _engine.MasterInit();
+ }
+ catch (Exception exc)
+ {
+ Trace.WriteLine(exc.ToString());
+ }
+ }
+
+ public void RegisterProject(IVsHierarchy hierarchy)
+ {
+ if (_solution == null)
+ _solution = new VsProjectGroup(_provider);
+ _solution.AddProject(new VsProject(_solution, hierarchy));
+ }
+
+ public void UnregisterProject(IVsHierarchy hierarchy)
+ {
+ VsProject project = _solution.GetProject(hierarchy);
+ _solution.RemoveProject(project);
+ }
+
+ public void AfterSolutionLoaded()
+ {
+ try
+ {
+ DateTime start = DateTime.Now;
+ _engine.InitProjectGroup(_solution);
+ Trace.WriteLine(String.Format(">>>Prepared DOM in {0} msecs", (DateTime.Now - start).Milliseconds));
+ }
+ catch (Exception exc)
+ {
+ Trace.WriteLine(exc.ToString());
+ }
+ }
+
+ public void BeforeSolutionClosing()
+ {
+ _solution.Dispose();
+ _solution = null;
+ }
+
+ static CodeEngine _engine = new CodeEngine();
+
+ public static CodeEngine Engine
+ {
+ get { return _engine; }
+ }
+
+ #region IDisposable Members
+
+ public void Dispose()
+ {
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/HierarchyScanner.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/HierarchyScanner.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ class HierarchyScanner
+ {
+ public HierarchyScanner(IVsHierarchy tree)
+ {
+ _tree = tree;
+ }
+
+ IVsHierarchy _tree;
+
+ public IEnumerable<uint> IterateHierarchy(uint itemId)
+ {
+ uint currentItem = itemId;
+ while (VSConstants.VSITEMID_NIL != currentItem)
+ {
+ yield return currentItem;
+
+ object propertyValue;
+ bool canScanSubitems = true;
+ int hr = _tree.GetProperty(currentItem, (int)__VSHPROPID.VSHPROPID_HasEnumerationSideEffects, out propertyValue);
+ if ((VSConstants.S_OK == hr) && (propertyValue is bool))
+ {
+ canScanSubitems = !(bool)propertyValue;
+ }
+ if (canScanSubitems)
+ {
+ object child;
+ hr = _tree.GetProperty(currentItem, (int)__VSHPROPID.VSHPROPID_FirstChild, out child);
+ if (VSConstants.S_OK == hr)
+ {
+ foreach (uint sub in IterateHierarchy(GetItemId(child)))
+ yield return sub;
+ }
+ }
+
+ object sibling;
+ hr = _tree.GetProperty(currentItem, (int)__VSHPROPID.VSHPROPID_NextSibling, out sibling);
+ if (VSConstants.S_OK != hr)
+ {
+ currentItem = VSConstants.VSITEMID_NIL;
+ }
+ else
+ {
+ currentItem = GetItemId(sibling);
+ }
+ }
+ }
+
+ private 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 (uint)(ushort)variantValue;
+ if (variantValue is long) return (uint)(long)variantValue;
+ return VSConstants.VSITEMID_NIL;
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/KeyboardInputFilter.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/KeyboardInputFilter.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Design;
+using System.Text;
+
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ class KeyboardInputFilter : IDisposable, IVsTextViewFilter, IOleCommandTarget
+ {
+ protected KeyboardInputFilter()
+ {
+ }
+
+ IVsTextView _textView;
+ IOleCommandTarget _originalFilter;
+
+ public static KeyboardInputFilter Intercept(IVsTextView textView, System.IServiceProvider provider)
+ {
+ KeyboardInputFilter res = new KeyboardInputFilter();
+ res.InterceptInternal(textView, provider);
+ return res;
+ }
+
+ void InterceptInternal(IVsTextView textView, System.IServiceProvider provider)
+ {
+ _textView = textView;
+
+ ErrorHandler.ThrowOnFailure(
+ textView.AddCommandFilter(this, out _originalFilter));
+ }
+
+ public void Dispose()
+ {
+ if (null != _textView)
+ {
+ _textView.RemoveCommandFilter(this);
+ _textView = null;
+ }
+ }
+
+ void OnTypeChar()
+ {
+ }
+
+ #region IVsTextViewFilter Members
+
+ public int GetDataTipText(TextSpan[] pSpan, out string pbstrText)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public int GetPairExtents(int iLine, int iIndex, TextSpan[] pSpan)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public int GetWordExtent(int iLine, int iIndex, uint dwFlags, TextSpan[] pSpan)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ #endregion
+
+ #region IOleCommandTarget Members
+
+ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
+ {
+ VSConstants.VSStd2KCmdID cmdID = (VSConstants.VSStd2KCmdID)nCmdID;
+ switch (cmdID)
+ {
+ case VSConstants.VSStd2KCmdID.TYPECHAR:
+ OnTypeChar();
+ break;
+ }
+ return _originalFilter.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
+ }
+
+ public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
+ {
+ return _originalFilter.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText);
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/Msg.Designer.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/Msg.Designer.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,73 @@
+ďťż//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.42
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Nemerle.Vsip.NemerleLanguageService {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Msg {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Msg() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Nemerle.Vsip.NemerleLanguageService.Msg", typeof(Msg).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Nemerle Files (*.n)
+ ///*.n.
+ /// </summary>
+ internal static string NemerleFormatFilter {
+ get {
+ return ResourceManager.GetString("NemerleFormatFilter", resourceCulture);
+ }
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/Msg.resx
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/Msg.resx Tue Jun 6 18:22:26 2006
@@ -0,0 +1,105 @@
+ďťż<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 1.3
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">1.3</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1">this is my long string</data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ [base64 mime encoded serialized .NET Framework object]
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ [base64 mime encoded string representing a byte array form of the .NET Framework object]
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>1.3</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="NemerleFormatFilter" xml:space="preserve">
+ <value>Nemerle Files (*.n)
+*.n</value>
+ </data>
+</root>
\ No newline at end of file
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleAuthoringScope.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleAuthoringScope.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio;
+
+using Nemerle.Vsip.CodeEngineering;
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ public class NemerleAuthoringScope : AuthoringScope
+ {
+ public NemerleAuthoringScope(CodeFile file)
+ : base()
+ {
+ _file = file;
+ }
+
+ CodeFile _file;
+
+ public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView,
+ int line, int col, out TextSpan span)
+ {
+ span = new TextSpan();
+ return null;
+ }
+
+ public override string GetDataTipText(int line, int col, out TextSpan span)
+ {
+ span = new TextSpan();
+ return null;
+ }
+
+ public override Declarations GetDeclarations(IVsTextView view, int line, int col,
+ TokenInfo info, ParseReason reason)
+ {
+ if (reason == ParseReason.CompleteWord)
+ {
+ return new VsCompletionVariants(
+ EventManager.Engine.CompleteSentence(_file, new TextLocation(line, col)));
+ }
+ else
+ return null;
+ }
+
+ public override Methods GetMethods(int line, int col, string name)
+ {
+ return null;
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguage.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguage.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,175 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Nemerle.Compiler;
+using Nemerle.Vsip.Common;
+using Nemerle.Vsip.CodeEngineering;
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using Nemerle.Vsip.CodeEngineering.Util;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ [Guid(Const.GuidString.LanguageService)]
+ public class NemerleLanguage : LanguageService
+ {
+ public NemerleLanguage()
+ {
+ _specialSources = new Dictionary<IVsTextView, NemerleSource>();
+ _engine = EventManager.Engine;
+ }
+
+ LanguagePreferences preferences;
+ NemerleTokenizer scanner;
+ private Dictionary<IVsTextView, NemerleSource> _specialSources;
+
+ CodeEngine _engine;
+
+ // This array contains the definition of the colorable items provided by this
+ // language service.
+ // This specific language does not really need to provide colorable items because it
+ // does not define any item different from the default ones, but the base class has
+ // an empty implementation of IVsProvideColorableItems, so any language service that
+ // derives from it must implement the methods of this interface, otherwise there are
+ // errors when the shell loads an editor to show a file associated to this language.
+ private static ColorableItem[] colorableItems = {
+ // The first 6 items in this list MUST be these default items.
+ new ColorableItem("Keyword", COLORINDEX.CI_BLUE, COLORINDEX.CI_USERTEXT_BK),
+ new ColorableItem("Comment", COLORINDEX.CI_DARKGREEN, COLORINDEX.CI_USERTEXT_BK),
+ new ColorableItem("Identifier", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK),
+ new ColorableItem("String", COLORINDEX.CI_MAROON, COLORINDEX.CI_USERTEXT_BK),
+ new ColorableItem("Number", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK),
+ new ColorableItem("Text", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK)
+ };
+
+ public override void Dispose()
+ {
+ try
+ {
+ // Clear the special sources
+ foreach (NemerleSource source in _specialSources.Values)
+ {
+ source.Dispose();
+ }
+ _specialSources.Clear();
+
+ // Dispose the preferences.
+ if (null != preferences)
+ {
+ preferences.Dispose();
+ preferences = null;
+ }
+ }
+ finally
+ {
+ base.Dispose();
+ }
+ }
+
+ public void AddSpecialSource(NemerleSource source, IVsTextView view)
+ {
+ _specialSources.Add(view, source);
+ }
+
+ public override string Name
+ {
+ get
+ {
+ return Const.LanguageName;
+ }
+ }
+
+ public override Source CreateSource(IVsTextLines buffer)
+ {
+ return new NemerleSource(this, buffer, new Colorizer(this, buffer, GetScanner(buffer)));
+ }
+
+ public override LanguagePreferences GetLanguagePreferences()
+ {
+ if (preferences == null)
+ {
+ preferences = new LanguagePreferences(
+ this.Site, typeof(NemerleLanguage).GUID, this.Name
+ );
+ preferences.Init();
+ }
+ return preferences;
+ }
+
+ public override IScanner GetScanner(IVsTextLines buffer)
+ {
+ if (scanner == null)
+ {
+ scanner = new NemerleTokenizer();
+ }
+ return scanner;
+ }
+
+ public override AuthoringScope ParseSource(ParseRequest req)
+ {
+ if (null == req)
+ {
+ throw new ArgumentNullException("req");
+ }
+ Debug.Print("ParseSource at ({0}:{1}), reason {2}", req.Line, req.Col, req.Reason);
+ NemerleSource source = null;
+ if (_specialSources.TryGetValue(req.View, out source) && (null != source.ScopeCreator))
+ {
+ return source.ScopeCreator(req);
+ }
+
+ CodeFile file = EventManager.Engine.ProjectGroup.GetOpenedFile(new Path(req.FileName));
+ return new NemerleAuthoringScope(file);
+ }
+
+ public override int ValidateBreakpointLocation(IVsTextBuffer buffer, int line, int col, TextSpan[] pCodeSpan)
+ {
+ if (pCodeSpan != null)
+ {
+ pCodeSpan[0].iStartLine = line;
+ 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 Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+ else
+ {
+ return Microsoft.VisualStudio.VSConstants.S_FALSE;
+ }
+ }
+
+ public override string GetFormatFilterList()
+ {
+ return Msg.NemerleFormatFilter;
+ }
+
+ // Implementation of IVsProvideColorableItems
+
+ public override int GetItemCount(out int count)
+ {
+ count = colorableItems.Length;
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+
+ public override int GetColorableItem(int index, out IVsColorableItem item)
+ {
+ if (index < 1)
+ {
+ throw new ArgumentOutOfRangeException("index");
+ }
+ item = colorableItems[index - 1];
+ return Microsoft.VisualStudio.VSConstants.S_OK;
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguagePackage.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguagePackage.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,155 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+
+using System.ComponentModel.Design;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Nemerle.Vsip.Common;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ [PackageRegistration(UseManagedResourcesOnly = true)]
+ [ProvideService(typeof(NemerleLanguage), ServiceName = "Nemerle")]
+ [ProvideService(typeof(INemerleSolutionEvents))]
+ [ProvideLanguageService(typeof(NemerleLanguage), "Nemerle", 100,
+ CodeSense = true,
+ EnableCommenting = true,
+ MatchBraces = true,
+ ShowCompletion = true,
+ ShowMatchingBrace = true)]
+ [ProvideLanguageExtension(typeof(NemerleLanguage), Const.NemerleFileExtension)]
+ [Guid(Const.LanguagePackageGuidString)]
+ public class NemerleLanguagePackage : Package, IOleComponent
+ {
+ private uint _componentID;
+ private EventManager _libraryManager;
+
+ public NemerleLanguagePackage()
+ {
+ IServiceContainer container = this;
+ container.AddService(typeof(NemerleLanguage), CreateLanguageService, true);
+ container.AddService(typeof(INemerleSolutionEvents), CreateHierarchyService, true);
+ }
+
+ private object CreateLanguageService(IServiceContainer container, Type serviceType)
+ {
+ NemerleLanguage language = new NemerleLanguage();
+ language.SetSite(this);
+ //RegisterForIdleTime();
+ return language;
+ }
+
+ private object CreateHierarchyService(IServiceContainer container, Type serviceType)
+ {
+ _libraryManager = new EventManager(this);
+ return _libraryManager;
+ }
+
+ private void RegisterForIdleTime()
+ {
+ IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
+ if (_componentID == 0 && mgr != null)
+ {
+ OLECRINFO[] crinfo = new OLECRINFO[1];
+ crinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
+ crinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
+ (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
+ crinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
+ (uint)_OLECADVF.olecadvfRedrawOff |
+ (uint)_OLECADVF.olecadvfWarningsOff;
+ crinfo[0].uIdleTimeInterval = 1000;
+ int hr = mgr.FRegisterComponent(this, crinfo, out _componentID);
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ try
+ {
+ if (_componentID != 0)
+ {
+ IOleComponentManager mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;
+ if (mgr != null)
+ {
+ mgr.FRevokeComponent(_componentID);
+ }
+ _componentID = 0;
+ }
+ if (null != _libraryManager)
+ {
+ _libraryManager.Dispose();
+ _libraryManager = null;
+ }
+ }
+ finally
+ {
+ base.Dispose(disposing);
+ }
+ }
+
+ #region IOleComponent Members
+
+ public int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked)
+ {
+ return 1;
+ }
+
+ public int FDoIdle(uint grfidlef)
+ {
+ //NemerleLanguage pl = GetService(typeof(NemerleLanguage)) as NemerleLanguage;
+ //if (pl != null)
+ //{
+ // pl.OnIdle((grfidlef & (uint)_OLEIDLEF.oleidlefPeriodic) != 0);
+ //}
+ return 0;
+ }
+
+ public int FPreTranslateMessage(MSG[] pMsg)
+ {
+ return 0;
+ }
+
+ public int FQueryTerminate(int fPromptUser)
+ {
+ return 1;
+ }
+
+ public int FReserved1(uint dwReserved, uint message, IntPtr wParam, IntPtr lParam)
+ {
+ return 1;
+ }
+
+ public IntPtr HwndGetWindow(uint dwWhich, uint dwReserved)
+ {
+ return IntPtr.Zero;
+ }
+
+ public void OnActivationChange(IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved)
+ {
+ }
+
+ public void OnAppActivate(int fActive, uint dwOtherThreadID)
+ {
+ }
+
+ public void OnEnterState(uint uStateID, int fEnter)
+ {
+ }
+
+ public void OnLoseActivation()
+ {
+ }
+
+ public void Terminate()
+ {
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguageService.csproj
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguageService.csproj Tue Jun 6 18:22:26 2006
@@ -0,0 +1,105 @@
+ďťż<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{059001B4-2D1E-476E-AD45-0103EDA182A6}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Nemerle.Vsip.NemerleLanguageService</RootNamespace>
+ <AssemblyName>Nemerle.Vsip.NemerleLanguageService</AssemblyName>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Package.LanguageService, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Design" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Nemerle, Version=0.9.1.0, Culture=neutral, PublicKeyToken=e080a9c724e2bfcd, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ <Reference Include="Nemerle.Compiler, Version=0.9.1.0, Culture=neutral, PublicKeyToken=5291d186334f6101, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <Private>True</Private>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="HierarchyScanner.cs" />
+ <Compile Include="VsCompletionVariants.cs" />
+ <Compile Include="NemerleAuthoringScope.cs" />
+ <Compile Include="NemerleTokenizer.cs" />
+ <Compile Include="NemerleLanguage.cs" />
+ <Compile Include="SourceDom\VsCodeFile.cs" />
+ <Compile Include="SourceDom\VsProject.cs" />
+ <Compile Include="SourceDom\VsProjectGroup.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="EventManager.cs" />
+ <Compile Include="NemerleLanguagePackage.cs" />
+ <Compile Include="ColorableItem.cs" />
+ <Compile Include="NemerleSource.cs" />
+ <Compile Include="Msg.Designer.cs">
+ <DependentUpon>Msg.resx</DependentUpon>
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\CodeEngineering\CodeEngineering.csproj">
+ <Project>{974E1CBE-EB8D-420F-A94C-A0ACBA311B18}</Project>
+ <Name>CodeEngineering</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Common\Common.csproj">
+ <Project>{9DBD6BDD-C115-4930-92B6-D30C30EB2F6A}</Project>
+ <Name>Common</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Msg.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Msg.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <PropertyGroup>
+ <TargetRegistryRoot>Software\Microsoft\VisualStudio\8.0Exp</TargetRegistryRoot>
+ <TargetRegistryRoot Condition=" '$(Configuration)' == 'Release' ">Software\Microsoft\VisualStudio\8.0</TargetRegistryRoot>
+ <RegisterOutputPackage>true</RegisterOutputPackage>
+ <RegisterWithCodebase>true</RegisterWithCodebase>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(VS_SDK_ROOT)\VisualStudioIntegration\Tools\Build\Microsoft.VsSDK.targets" />
+</Project>
\ No newline at end of file
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguageService.csproj.vspscc
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleLanguageService.csproj.vspscc Tue Jun 6 18:22:26 2006
@@ -0,0 +1,10 @@
+ďťż""
+{
+"FILE_VERSION" = "9237"
+"ENLISTMENT_CHOICE" = "NEVER"
+"PROJECT_FILE_RELATIVE_PATH" = "relative:LanguageService"
+"NUMBER_OF_EXCLUDED_FILES" = "0"
+"ORIGINAL_PROJECT_FILE_PATH" = ""
+"NUMBER_OF_NESTED_PROJECTS" = "0"
+"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleSource.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleSource.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,69 @@
+using System;
+using System.Diagnostics;
+
+using Microsoft.VisualStudio.TextManager.Interop;
+using Microsoft.VisualStudio.Package;
+using Microsoft.VisualStudio;
+
+using Nemerle.Vsip.CodeEngineering;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ public delegate AuthoringScope ScopeCreatorCallback(ParseRequest request);
+
+ public class NemerleSource : Source
+ {
+ private ScopeCreatorCallback scopeCreator;
+
+ public NemerleSource(LanguageService service, IVsTextLines textLines, Colorizer colorizer)
+ : base(service, textLines, colorizer)
+ {
+ _engine = EventManager.Engine;
+ }
+
+ CodeEngine _engine;
+
+ public override CommentInfo GetCommentFormat()
+ {
+ CommentInfo ci = new CommentInfo();
+ ci.UseLineComments = true;
+ ci.LineStart = "//";
+ ci.BlockStart = "/*";
+ ci.BlockEnd = "*/";
+ return ci;
+ }
+
+ // used by the ConsoleWindow to use the ConsoleAuthoringScope
+ public ScopeCreatorCallback ScopeCreator
+ {
+ get { return scopeCreator; }
+ set { scopeCreator = value; }
+ }
+
+ void OnTypeChar(IVsTextView textView, char ch)
+ {
+ //string res = _engine.CompleteSentence();
+ //using (Completor c = new Completor(LanguageService, textView, "Word completion"))
+ //{
+ // c.TypeChars(res);
+ //}
+ }
+
+ public override void OnCommand(IVsTextView textView, VSConstants.VSStd2KCmdID command, char ch)
+ {
+ Trace.WriteLine(String.Format("NemerleSource.OnCommand {0}", command));
+
+ switch (command)
+ {
+ case VSConstants.VSStd2KCmdID.TYPECHAR:
+ OnTypeChar(textView, ch);
+ break;
+ case VSConstants.VSStd2KCmdID.COMPLETEWORD:
+ break;
+ default:
+ break;
+ }
+ base.OnCommand(textView, command, ch);
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/NemerleTokenizer.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/NemerleTokenizer.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,104 @@
+using System;
+using Microsoft.VisualStudio.Package;
+using Nemerle.Compiler;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ class NemerleTokenizer : IScanner
+ {
+ static NemerleTokenizer() {
+ //LibraryReferenceManager.LoadMacrosFrom(@"d:\program files\nemerle\Nemerle.Macros.dll");
+ GlobalEnv.Init();
+ }
+
+ public NemerleTokenizer() {
+ _lexer = new LexerColorizer("");
+ }
+
+ LexerColorizer _lexer;
+
+ // Its calling depends on IVsColorizer.GetStateMaintenanceFlag, which defaults to true.
+ public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state) {
+ LexerColorizer.SyntaxToken tok = _lexer.GetSyntaxToken(ref state);
+
+ // TokenInfo is only read in *.LanguageService.dll
+ tokenInfo.Trigger = TokenTriggers.None;
+ switch(tok.Token) {
+ case SyntaxType.EndOfFile:
+ return false;
+
+ case SyntaxType.Keyword:
+ tokenInfo.Color = TokenColor.Keyword;
+ tokenInfo.Type = TokenType.Keyword;
+ break;
+
+ case SyntaxType.Identifier:
+ tokenInfo.Color = TokenColor.Identifier;
+ tokenInfo.Type = TokenType.Identifier;
+ break;
+
+ case SyntaxType.OperatorDot:
+ case SyntaxType.OperatorBrace:
+ case SyntaxType.Operator:
+ tokenInfo.Color = TokenColor.Text;
+ tokenInfo.Type = TokenType.Operator;
+ switch(tok.Token) {
+ case SyntaxType.OperatorBrace:
+ tokenInfo.Trigger = TokenTriggers.MatchBraces;
+ break;
+ case SyntaxType.OperatorDot:
+ tokenInfo.Trigger = TokenTriggers.MemberSelect;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case SyntaxType.Comment:
+ tokenInfo.Color = TokenColor.Comment;
+ if(state == 0)
+ tokenInfo.Type = TokenType.LineComment;
+ else
+ tokenInfo.Type = TokenType.Comment;
+ break;
+
+ case SyntaxType.CharLiteral:
+ tokenInfo.Color = TokenColor.String;
+ tokenInfo.Type = TokenType.Literal;
+ break;
+
+ case SyntaxType.IntLiteral:
+ tokenInfo.Color = TokenColor.Number;
+ tokenInfo.Type = TokenType.Literal;
+ break;
+
+ case SyntaxType.StringLiteral:
+ tokenInfo.Color = TokenColor.String;
+ tokenInfo.Type = TokenType.String;
+ break;
+
+ default:
+ tokenInfo.Color = TokenColor.Text;
+ tokenInfo.Type = TokenType.Text;
+ break;
+ }
+
+ tokenInfo.StartIndex = tok.StartPos;
+ tokenInfo.EndIndex = tok.EndPos;
+
+ // Nemerle lexer count columns from 0, and the EndPos is inclusive. That is VS expects.
+ //System.Diagnostics.Trace.WriteLine(string.Format("{0},{1} : {2}", tok.StartPos, tok.EndPos, tok.Token.ToString()));
+
+ //TODO: it has to handle whitespace and # (pragma, region, etc)
+ // currently it handles } as a token starting from the beginning of line...
+
+ return true;
+ }
+
+ // The current implementation in *.LanguageService.dll always uses offset 0.
+ public void SetSource(string source, int offset) {
+ _lexer.SetString(source, offset);
+ //System.Diagnostics.Trace.WriteLine(source);
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/ProjectContentManager.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/ProjectContentManager.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,435 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+using Microsoft.VisualStudio.OLE.Interop;
+using Microsoft.VisualStudio.Shell.Interop;
+using VSConstants = Microsoft.VisualStudio.VSConstants;
+using IServiceProvider = System.IServiceProvider;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Nemerle.Vsip.NemerleLanguageService.ProjectDom;
+using Nemerle.Vsip.Common;
+using Nemerle.Vsip.CodeEngineering;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ /// <summary>
+ /// This interface defines the service that finds Nemerle files inside a hierarchy
+ /// and builds the DOM information
+ /// </summary>
+ [Guid(Const.LibraryManagerServiceGuidString)]
+ public interface IProjectContentManager
+ {
+ void RegisterHierarchy(IVsHierarchy hierarchy);
+ void UnregisterHierarchy(IVsHierarchy hierarchy);
+ }
+
+ /// <summary>
+ /// Inplementation of the service that build the information to expose to the symbols
+ /// navigation tools (class view or object browser) from the Nemerle files inside a
+ /// hierarchy.
+ /// </summary>
+ [Guid(Const.LibraryManagerGuidString)]
+ public class ProjectContentManager : IProjectContentManager, IVsRunningDocTableEvents, IDisposable
+ {
+ /// <summary>
+ /// Class used to identify a module. The module is identify using the hierarchy that
+ /// contains it and its item id inside the hierarchy.
+ /// </summary>
+ internal sealed class DocumentId
+ {
+ private IVsHierarchy ownerHierarchy;
+ private uint itemId;
+ public DocumentId(IVsHierarchy owner, uint id)
+ {
+ this.ownerHierarchy = owner;
+ this.itemId = id;
+ }
+ public IVsHierarchy Hierarchy
+ {
+ get { return ownerHierarchy; }
+ }
+ public uint ItemID
+ {
+ get { return itemId; }
+ }
+ public override int GetHashCode()
+ {
+ int hash = 0;
+ if (null != ownerHierarchy)
+ {
+ hash = ownerHierarchy.GetHashCode();
+ }
+ hash = hash ^ (int)itemId;
+ return hash;
+ }
+ public override bool Equals(object obj)
+ {
+ DocumentId other = obj as DocumentId;
+ if (null == obj)
+ {
+ return false;
+ }
+ if (!ownerHierarchy.Equals(other.ownerHierarchy))
+ {
+ return false;
+ }
+ return (itemId == other.itemId);
+ }
+ }
+
+ private IServiceProvider provider;
+ private uint objectManagerCookie;
+ private uint runningDocTableCookie;
+ private Dictionary<DocumentId, TextLineEventListener> _documents;
+ private Dictionary<IVsHierarchy, HierarchyListener> _hierarchies;
+ private Dictionary<DocumentId, FileNode> _files;
+ private ProjectNode _project;
+
+ private VsHostServices _hostServices;
+ private CodeEngine _engine;
+
+ public ProjectContentManager(IServiceProvider provider)
+ {
+ _documents = new Dictionary<DocumentId, TextLineEventListener>();
+ _hierarchies = new Dictionary<IVsHierarchy, HierarchyListener>();
+ _project = new ProjectNode(new Guid("0925166e-a743-49e2-9224-bbe206545104"));
+ _project.LibraryCapabilities = (_LIB_FLAGS2)_LIB_FLAGS.LF_PROJECT;
+ _files = new Dictionary<DocumentId, FileNode>();
+ this.provider = provider;
+ //RegisterForRDTEvents();
+
+ _hostServices = new VsHostServices();
+ _engine = new CodeEngine(_hostServices);
+ }
+
+ private void RegisterForRDTEvents()
+ {
+ if (0 != runningDocTableCookie)
+ {
+ return;
+ }
+ IVsRunningDocumentTable rdt = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+ if (null != rdt)
+ {
+ // Do not throw here in case of error, simply skip the registration.
+ rdt.AdviseRunningDocTableEvents(this, out runningDocTableCookie);
+ }
+ }
+ private void UnregisterRDTEvents()
+ {
+ if (0 == runningDocTableCookie)
+ {
+ return;
+ }
+ IVsRunningDocumentTable rdt = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+ if (null != rdt)
+ {
+ // Do not throw in case of error.
+ rdt.UnadviseRunningDocTableEvents(runningDocTableCookie);
+ }
+ runningDocTableCookie = 0;
+ }
+
+ #region IDisposable Members
+ public void Dispose()
+ {
+ _engine.ShutDown();
+
+ // Dispose all the listeners.
+ foreach (HierarchyListener listener in _hierarchies.Values)
+ {
+ listener.Dispose();
+ }
+ _hierarchies.Clear();
+
+ foreach (TextLineEventListener textListener in _documents.Values)
+ {
+ textListener.Dispose();
+ }
+ _documents.Clear();
+
+ // Remove this library from the object manager.
+ if (0 != objectManagerCookie)
+ {
+ IVsObjectManager2 mgr = provider.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;
+ if (null != mgr)
+ {
+ mgr.UnregisterLibrary(objectManagerCookie);
+ }
+ objectManagerCookie = 0;
+ }
+
+ // Unregister this object from the RDT events.
+ UnregisterRDTEvents();
+ }
+ #endregion
+
+ #region IProjectContentManager
+
+ public void RegisterHierarchy(IVsHierarchy hierarchy)
+ {
+ if ((null == hierarchy) || _hierarchies.ContainsKey(hierarchy))
+ {
+ return;
+ }
+ if (0 == objectManagerCookie)
+ {
+ IVsObjectManager2 objManager = provider.GetService(typeof(SVsObjectManager)) as IVsObjectManager2;
+ if (null == objManager)
+ {
+ return;
+ }
+ Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
+ objManager.RegisterSimpleLibrary(_project, out objectManagerCookie));
+ }
+ HierarchyListener listener = new HierarchyListener(hierarchy);
+ listener.OnAddItem += new EventHandler<HierarchyEventArgs>(OnNewFile);
+ listener.OnDeleteItem += new EventHandler<HierarchyEventArgs>(OnDeleteFile);
+ listener.StartListening(true);
+ _hierarchies.Add(hierarchy, listener);
+ RegisterForRDTEvents();
+ }
+
+ public void UnregisterHierarchy(IVsHierarchy hierarchy)
+ {
+ if ((null == hierarchy) || !_hierarchies.ContainsKey(hierarchy))
+ {
+ return;
+ }
+ HierarchyListener listener = _hierarchies[hierarchy];
+ if (null != listener)
+ {
+ listener.Dispose();
+ }
+ _hierarchies.Remove(hierarchy);
+ if (0 == _hierarchies.Count)
+ {
+ UnregisterRDTEvents();
+ }
+ lock (_files)
+ {
+ DocumentId[] keys = new DocumentId[_files.Keys.Count];
+ _files.Keys.CopyTo(keys, 0);
+ foreach (DocumentId id in keys)
+ {
+ if (hierarchy.Equals(id.Hierarchy))
+ {
+ _project.RemoveNode(_files[id]);
+ _files.Remove(id);
+ }
+ }
+ }
+ // Remove the document listeners.
+ DocumentId[] docKeys = new DocumentId[_documents.Keys.Count];
+ _documents.Keys.CopyTo(docKeys, 0);
+ foreach (DocumentId id in docKeys)
+ {
+ if (hierarchy.Equals(id.Hierarchy))
+ {
+ TextLineEventListener docListener = _documents[id];
+ _documents.Remove(id);
+ docListener.Dispose();
+ }
+ }
+ }
+ #endregion
+
+ #region Hierarchy Events
+ private void OnNewFile(object sender, HierarchyEventArgs args)
+ {
+ IVsHierarchy hierarchy = sender as IVsHierarchy;
+ if (null == hierarchy)
+ {
+ return;
+ }
+ string fileText = null;
+ if (null != args.TextBuffer)
+ {
+ int lastLine;
+ int lastIndex;
+ int hr = args.TextBuffer.GetLastLineIndex(out lastLine, out lastIndex);
+ if (Microsoft.VisualStudio.ErrorHandler.Failed(hr))
+ {
+ return;
+ }
+ hr = args.TextBuffer.GetLineText(0, 0, lastLine, lastIndex, out fileText);
+ if (Microsoft.VisualStudio.ErrorHandler.Failed(hr))
+ {
+ return;
+ }
+ }
+
+ // TODO
+ }
+
+ private void OnDeleteFile(object sender, HierarchyEventArgs args)
+ {
+ IVsHierarchy hierarchy = sender as IVsHierarchy;
+ if (null == hierarchy)
+ {
+ return;
+ }
+ DocumentId id = new DocumentId(hierarchy, args.ItemID);
+ FileNode node = null;
+ lock (_files)
+ {
+ if (_files.TryGetValue(id, out node))
+ {
+ _files.Remove(id);
+ }
+ }
+ if (null != node)
+ {
+ _project.RemoveNode(node);
+ }
+ }
+ #endregion
+
+ #region IVsRunningDocTableEvents Members
+
+ public int OnAfterAttributeChange(uint docCookie, uint grfAttribs)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterDocumentWindowHide(uint docCookie, IVsWindowFrame pFrame)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterFirstDocumentLock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterSave(uint docCookie)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
+ {
+ // Get the information about this document from the RDT.
+ IVsRunningDocumentTable rdt = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+ if (null != rdt)
+ {
+ // Note that here we don't want to throw in case of error.
+ uint flags;
+ uint readLocks;
+ uint writeLoks;
+ string documentMoniker;
+ IVsHierarchy hierarchy;
+ uint itemId;
+ IntPtr unkDocData;
+ int hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out writeLoks,
+ out documentMoniker, out hierarchy, out itemId, out unkDocData);
+ try
+ {
+ if (Microsoft.VisualStudio.ErrorHandler.Failed(hr) || (IntPtr.Zero == unkDocData))
+ {
+ return VSConstants.S_OK;
+ }
+ // Check if the herarchy is one of the hierarchies this service is monitoring.
+ if (!_hierarchies.ContainsKey(hierarchy))
+ {
+ // This hierarchy is not monitored, we can exit now.
+ return VSConstants.S_OK;
+ }
+ // We are monitoring this hierarchy; check if there is a listener
+ // for this document.
+ DocumentId docId = new DocumentId(hierarchy, itemId);
+ if (_documents.ContainsKey(docId))
+ {
+ // There is a listener for this document, so no action is needed.
+ return VSConstants.S_OK;
+ }
+
+ // Check the extension of the file to see if a listener is required.
+ string extension = System.IO.Path.GetExtension(documentMoniker);
+ if (0 != string.Compare(extension, Const.NemerleFileExtension, StringComparison.OrdinalIgnoreCase))
+ {
+ return VSConstants.S_OK;
+ }
+
+ // Try to get the text buffer.
+ IVsTextLines buffer = (IVsTextLines)Marshal.GetObjectForIUnknown(unkDocData);
+
+ // Create the listener.
+ TextLineEventListener listener = new TextLineEventListener(buffer, documentMoniker, docId);
+ // Set the event handler for the change event. Note that there is no difference
+ // between the AddFile and FileChanged operation, so we can use the same handler.
+ listener.OnFileChanged += new EventHandler<HierarchyEventArgs>(OnNewFile);
+ // Add the listener to the dictionary, so we will not create it anymore.
+ _documents.Add(docId, listener);
+ }
+ finally
+ {
+ if (IntPtr.Zero != unkDocData)
+ {
+ Marshal.Release(unkDocData);
+ }
+ }
+ }
+ // Always return success.
+ return VSConstants.S_OK;
+ }
+
+ public int OnBeforeLastDocumentUnlock(uint docCookie, uint dwRDTLockType, uint dwReadLocksRemaining, uint dwEditLocksRemaining)
+ {
+ if ((0 != dwEditLocksRemaining) || (0 != dwReadLocksRemaining))
+ {
+ return VSConstants.S_OK;
+ }
+ IVsRunningDocumentTable rdt = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
+ if (null == rdt)
+ {
+ return VSConstants.S_OK;
+ }
+ // Note that here we don't want to throw in case of error.
+ uint flags;
+ uint readLocks;
+ uint writeLoks;
+ string documentMoniker;
+ IVsHierarchy hierarchy;
+ uint itemId;
+ IntPtr unkDocData = IntPtr.Zero;
+ int hr = rdt.GetDocumentInfo(docCookie, out flags, out readLocks, out writeLoks,
+ out documentMoniker, out hierarchy, out itemId, out unkDocData);
+ try
+ {
+ if (Microsoft.VisualStudio.ErrorHandler.Failed(hr))
+ {
+ return VSConstants.S_OK;
+ }
+
+ DocumentId docId = new DocumentId(hierarchy, itemId);
+ TextLineEventListener listener;
+ if (!_documents.TryGetValue(docId, out listener))
+ {
+ return VSConstants.S_OK;
+ }
+ _documents.Remove(docId);
+ listener.Dispose();
+ // Now make sure that the information about this file are up to date (e.g. it is
+ // possible that Class View shows something strange if the file was closed without
+ // saving the changes).
+ HierarchyEventArgs args = new HierarchyEventArgs(itemId, documentMoniker);
+ OnNewFile(hierarchy, args);
+ }
+ finally
+ {
+ if (IntPtr.Zero != unkDocData)
+ {
+ Marshal.Release(unkDocData);
+ }
+ }
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/Properties/AssemblyInfo.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,35 @@
+ďťżusing System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("LanguageService")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LanguageService")]
+[assembly: AssemblyCopyright("Copyright Š 2006")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("d061a9e5-1903-4778-8c78-9fd65b121666")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("0.1.*")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsCodeFile.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsCodeFile.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,202 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Design;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.TextManager.Interop;
+
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using Nemerle.Vsip.Common;
+using Microsoft.VisualStudio.OLE.Interop;
+using System.Diagnostics;
+
+namespace Nemerle.Vsip.NemerleLanguageService.SourceDom
+{
+ internal class VsCodeFile : CodeFile, IVsTextLinesEvents
+ {
+ public VsCodeFile(VsProject owner, IVsHierarchy tree, uint itemID)
+ : base(owner)
+ {
+ _tree = tree;
+ _itemID = itemID;
+
+ if (IsAssembly)
+ {
+ _asm = Assembly.LoadFile(FullName);
+ }
+ }
+
+ IVsHierarchy _tree;
+ uint _itemID;
+
+ public uint ItemID
+ {
+ get { return _itemID; }
+ }
+
+ Assembly _asm;
+
+ public override string Name
+ {
+ get { return Path.GetFileName(FullName); }
+ }
+
+ public override string FullName
+ {
+ get
+ {
+ string canonicalName;
+ _tree.GetCanonicalName(_itemID, out canonicalName);
+ return canonicalName;
+ }
+ }
+
+ public override string GetContent()
+ {
+ string res = null;
+ if (!IsSourceFile)
+ throw new InvalidOperationException();
+ if (!IsInEditMode)
+ {
+ using (TextReader rd = new StreamReader(FullName))
+ {
+ res = rd.ReadToEnd();
+ }
+ }
+ else
+ {
+ int lastLine;
+ int lastIndex;
+ int hr = _textBuffer.GetLastLineIndex(out lastLine, out lastIndex);
+ ErrorHandler.ThrowOnFailure(hr);
+ res = GetLines(0, lastLine);
+ }
+ return res;
+ }
+
+ public override string GetLines(int start, int end)
+ {
+ if (IsInEditMode)
+ {
+ int lastIndex;
+ int hr = _textBuffer.GetLengthOfLine(end, out lastIndex);
+ ErrorHandler.ThrowOnFailure(hr);
+ string res;
+ hr = _textBuffer.GetLineText(end, 0, end, lastIndex, out res);
+ ErrorHandler.ThrowOnFailure(hr);
+ return res;
+ }
+ else
+ {
+ throw new InvalidOperationException();
+ }
+ }
+
+ public override DateTime LastModified
+ {
+ get { throw new Exception("The method or operation is not implemented."); }
+ }
+
+ public override int Size
+ {
+ get { throw new Exception("The method or operation is not implemented."); }
+ }
+
+ public override bool IsSourceFile
+ {
+ get { return Const.IsNemerleCodeFile(FullName); }
+ }
+
+ public override bool IsAssembly
+ {
+ get { return Const.IsClassLibraryFile(FullName); }
+ }
+
+ public override bool IsInEditMode
+ {
+ get { return (_textBuffer != null); }
+ }
+
+ bool _isSaved = true;
+
+ public override bool IsSaved
+ {
+ get { return _isSaved; }
+ }
+
+ IVsTextLines _textBuffer;
+
+ public IVsTextLines TextBuffer
+ {
+ get { return _textBuffer; }
+ }
+
+ public void AttachEditor(IVsTextLines buffer)
+ {
+ AdviseEditor(buffer);
+ _textBuffer = buffer;
+ }
+
+ public void DetachEditor()
+ {
+ UnadviseEditor();
+ _textBuffer = null;
+ }
+
+ #region Text editor events
+
+ private IConnectionPoint _connectionPoint;
+ private uint _connectionCookie;
+
+ void AdviseEditor(IVsTextLines buffer)
+ {
+ IConnectionPointContainer container = buffer as IConnectionPointContainer;
+ if (null != container)
+ {
+ Guid eventsGuid = typeof(IVsTextLinesEvents).GUID;
+ container.FindConnectionPoint(ref eventsGuid, out _connectionPoint);
+ _connectionPoint.Advise(this as IVsTextLinesEvents, out _connectionCookie);
+ }
+ }
+
+ void UnadviseEditor()
+ {
+ if ((null != _connectionPoint) && (0 != _connectionCookie))
+ {
+ _connectionPoint.Unadvise(_connectionCookie);
+ Debug.WriteLine("\n\tUnadvised from TextLinesEvents\n");
+ }
+ _connectionCookie = 0;
+ _connectionPoint = null;
+ }
+
+ #endregion
+
+ #region IVsTextLinesEvents Members
+
+ public void OnChangeLineAttributes(int iFirstLine, int iLastLine)
+ {
+ }
+
+ public void OnChangeLineText(TextLineChange[] pTextLineChange, int fLast)
+ {
+ _isSaved = false;
+ }
+
+ #endregion
+
+ #region IDisposable Members
+
+ public override void Dispose()
+ {
+ UnadviseEditor();
+ base.Dispose();
+ }
+
+ #endregion
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsProject.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsProject.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,168 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio;
+
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using System.Diagnostics;
+
+namespace Nemerle.Vsip.NemerleLanguageService.SourceDom
+{
+ internal class VsProject : Project, IVsHierarchyEvents
+ {
+ public VsProject(VsProjectGroup owner, IVsHierarchy tree)
+ : base(owner)
+ {
+ _hierarchy = tree;
+ InitHierarchy();
+ AdviseEvents();
+ }
+
+ void InitHierarchy()
+ {
+ _filesDictionary = new Dictionary<uint, CodeFile>();
+
+ HierarchyScanner s = new HierarchyScanner(_hierarchy);
+ foreach (uint itemID in s.IterateHierarchy(VSConstants.VSITEMID_ROOT))
+ {
+ if (itemID != VSConstants.VSITEMID_ROOT)
+ {
+ AddRegistration(new VsCodeFile(this, _hierarchy, itemID));
+ }
+ }
+ }
+
+ void AddRegistration(VsCodeFile file)
+ {
+ _filesDictionary.Add(file.ItemID, file);
+ }
+
+ void RemoveRegistration(VsCodeFile file)
+ {
+ _filesDictionary.Remove(file.ItemID);
+ }
+
+ void AdviseEvents()
+ {
+ ErrorHandler.ThrowOnFailure(
+ _hierarchy.AdviseHierarchyEvents(this, out _eventsCookie));
+ }
+
+ void UnadviseEvents()
+ {
+ if (_eventsCookie != 0)
+ _hierarchy.UnadviseHierarchyEvents(_eventsCookie);
+ }
+
+ IVsHierarchy _hierarchy;
+
+ internal IVsHierarchy Hierarchy
+ {
+ get { return _hierarchy; }
+ }
+
+ Dictionary<uint, CodeFile> _filesDictionary;
+
+ private uint _eventsCookie;
+
+ public override IEnumerable<CodeFile> References
+ {
+ get
+ {
+ foreach (CodeFile cur in Files)
+ {
+ if (cur.IsAssembly)
+ yield return cur;
+ }
+ }
+ }
+
+ public override IEnumerable<CodeFile> SourceFiles
+ {
+ get
+ {
+ foreach (CodeFile cur in Files)
+ {
+ if (cur.IsSourceFile)
+ yield return cur;
+ }
+ }
+ }
+
+ public override IEnumerable<CodeFile> Files
+ {
+ get { return _filesDictionary.Values; }
+ }
+
+ public override string Caption
+ {
+ get { return FullName; }
+ }
+
+ public override string FullName
+ {
+ get
+ {
+ string canonicalName;
+ _hierarchy.GetCanonicalName(VSConstants.VSITEMID_ROOT, out canonicalName);
+ return canonicalName;
+ }
+ }
+
+ public override CodeFile GetFile(string path)
+ {
+ uint itemID;
+ ErrorHandler.ThrowOnFailure(_hierarchy.ParseCanonicalName(path, out itemID));
+ CodeFile res = _filesDictionary[itemID];
+ return res;
+ }
+
+ #region IVsHierarchyEvents Members
+
+ public int OnInvalidateIcon(IntPtr hicon)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnInvalidateItems(uint itemidParent)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnItemAdded(uint itemidParent, uint itemidSiblingPrev, uint itemidAdded)
+ {
+ VsCodeFile file = new VsCodeFile(this, _hierarchy, itemidAdded);
+ AddRegistration(file);
+ OnAddFile(file);
+ return VSConstants.S_OK;
+ }
+
+ public int OnItemDeleted(uint itemid)
+ {
+ VsCodeFile file = (VsCodeFile)_filesDictionary[itemid];
+ RemoveRegistration(file);
+ OnRemoveFile(file);
+ return VSConstants.S_OK;
+ }
+
+ public int OnItemsAppended(uint itemidParent)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnPropertyChanged(uint itemid, int propid, uint flags)
+ {
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ public override void Dispose()
+ {
+ UnadviseEvents();
+ base.Dispose();
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsProjectGroup.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/SourceDom/VsProjectGroup.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,182 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.TextManager.Interop;
+using System.Runtime.InteropServices;
+
+using Nemerle.Vsip.CodeEngineering.SourceDom;
+using Nemerle.Vsip.Common;
+using Nemerle.Vsip.CodeEngineering.Util;
+using System.Diagnostics;
+
+namespace Nemerle.Vsip.NemerleLanguageService.SourceDom
+{
+ internal class VsProjectGroup : ProjectGroup<VsProject>, IVsRunningDocTableEvents
+ {
+ public VsProjectGroup(IServiceProvider provider)
+ {
+ _provider = provider;
+ RegisterForRDTEvents();
+ }
+
+ private uint _runningDocTableCookie;
+ private IServiceProvider _provider;
+ Dictionary<Path, CodeFile> _openedFiles = new Dictionary<Path,CodeFile>();
+
+ public VsProject GetProject(IVsHierarchy hierarchy)
+ {
+ foreach (VsProject proj in Projects)
+ {
+ if (Object.ReferenceEquals(proj.Hierarchy, hierarchy))
+ return proj;
+ }
+ throw new KeyNotFoundException();
+ }
+
+ #region RDT stuff
+
+ IVsRunningDocumentTable RDT
+ {
+ get
+ {
+ IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)_provider.GetService(
+ typeof(SVsRunningDocumentTable));
+ if (rdt == null)
+ throw new Exception("Couldn't obtain RDT");
+ return rdt;
+ }
+ }
+
+ private void RegisterForRDTEvents()
+ {
+ RDT.AdviseRunningDocTableEvents(this, out _runningDocTableCookie);
+ }
+
+ private void UnregisterRDTEvents()
+ {
+ RDT.UnadviseRunningDocTableEvents(_runningDocTableCookie);
+ _runningDocTableCookie = 0;
+ }
+
+ public int OnAfterAttributeChange(uint docCookie, uint grfAttribs)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterDocumentWindowHide(uint docCookie, IVsWindowFrame pFrame)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterFirstDocumentLock(uint docCookie, uint dwRDTLockType,
+ uint dwReadLocksRemaining, uint dwEditLocksRemaining)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnAfterSave(uint docCookie)
+ {
+ return VSConstants.S_OK;
+ }
+
+ public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowFrame pFrame)
+ {
+ uint flags;
+ uint readLocks;
+ uint writeLoks;
+ string filePath;
+ IVsHierarchy hierarchy;
+ uint itemId;
+ IntPtr unkDocData;
+ int hr = RDT.GetDocumentInfo(docCookie, out flags, out readLocks, out writeLoks,
+ out filePath, out hierarchy, out itemId, out unkDocData);
+ try
+ {
+ if (ErrorHandler.Failed(hr) || (IntPtr.Zero == unkDocData))
+ {
+ Trace.WriteLine("Failed to get doc info");
+ return VSConstants.S_OK;
+ }
+
+ if (!Const.IsNemerleCodeFile(filePath))
+ return VSConstants.S_OK;
+
+ VsProject project = GetProject(hierarchy);
+ VsCodeFile file = (VsCodeFile)project.GetFile(filePath);
+
+ // Try to get the text buffer.
+ IVsTextLines buffer = (IVsTextLines)Marshal.GetObjectForIUnknown(unkDocData);
+ file.AttachEditor(buffer);
+ _openedFiles.Add(new Path(filePath), file);
+ }
+ finally
+ {
+ if (IntPtr.Zero != unkDocData)
+ {
+ Marshal.Release(unkDocData);
+ }
+ }
+
+ return VSConstants.S_OK;
+ }
+
+ // in other words, this method is called before closing the document
+ public int OnBeforeLastDocumentUnlock(uint docCookie, uint dwRDTLockType,
+ uint dwReadLocksRemaining, uint dwEditLocksRemaining)
+ {
+ uint flags;
+ uint readLocks;
+ uint writeLoks;
+ string filePath;
+ IVsHierarchy hierarchy;
+ uint itemId;
+ IntPtr unkDocData;
+ int hr = RDT.GetDocumentInfo(docCookie, out flags, out readLocks, out writeLoks,
+ out filePath, out hierarchy, out itemId, out unkDocData);
+ try
+ {
+ if (ErrorHandler.Failed(hr) || (IntPtr.Zero == unkDocData))
+ {
+ Trace.WriteLine("Failed to get doc info");
+ return VSConstants.S_OK;
+ }
+
+ if (readLocks == 0 && writeLoks == 0 && Const.IsNemerleCodeFile(filePath))
+ {
+ Path path = new Path(filePath);
+ CodeFile file = null;
+ if (_openedFiles.TryGetValue(path, out file))
+ {
+ ((VsCodeFile)file).DetachEditor();
+ _openedFiles.Remove(path);
+ }
+ }
+ }
+ finally
+ {
+ if (IntPtr.Zero != unkDocData)
+ {
+ Marshal.Release(unkDocData);
+ }
+ }
+
+ return VSConstants.S_OK;
+ }
+
+ #endregion
+
+ public override CodeFile GetOpenedFile(Path path)
+ {
+ return _openedFiles[path];
+ }
+
+ public override void Dispose()
+ {
+ UnregisterRDTEvents();
+ base.Dispose();
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/VsCompletionVariants.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/VsCompletionVariants.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Microsoft.VisualStudio.Package;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ class VsCompletionVariants : Declarations
+ {
+ public VsCompletionVariants(IEnumerable<string> vals)
+ {
+ _vals = new List<string>(vals);
+ }
+
+ List<string> _vals;
+
+ public override int GetCount()
+ {
+ return _vals.Count;
+ }
+
+ public override string GetDescription(int index)
+ {
+ return _vals[index];
+ }
+
+ public override string GetDisplayText(int index)
+ {
+ return _vals[index];
+ }
+
+ public override int GetGlyph(int index)
+ {
+ return -1;
+ }
+
+ public override string GetName(int index)
+ {
+ return _vals[index];
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleLanguageService/VsHostServices.cs
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleLanguageService/VsHostServices.cs Tue Jun 6 18:22:26 2006
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using Nemerle.Vsip.CodeEngineering;
+
+namespace Nemerle.Vsip.NemerleLanguageService
+{
+ class VsHostServices : HostServices
+ {
+ public VsHostServices()
+ {
+ }
+
+ public override void ShowCompletionVariants(IEnumerable<CompletionVariant> values)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+
+ public override TextEditor GetEditor(CodeFile file)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
+ }
+}
Added: vs-plugin/branches/andreif/NemerleVsip.sln
==============================================================================
--- (empty file)
+++ vs-plugin/branches/andreif/NemerleVsip.sln Tue Jun 6 18:22:26 2006
@@ -0,0 +1,147 @@
+ďťż
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project", "Project\Project.csproj", "{87886EF2-1FD7-4C0D-8A76-04F77F136296}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectBase", "ProjectBase\ProjectBase.csproj", "{81DEB782-9FD3-4C2A-8931-E540AC5AB782}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NemerleLanguageService", "NemerleLanguageService\NemerleLanguageService.csproj", "{059001B4-2D1E-476E-AD45-0103EDA182A6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{9DBD6BDD-C115-4930-92B6-D30C30EB2F6A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeEngineering", "CodeEngineering\CodeEngineering.csproj", "{974E1CBE-EB8D-420F-A94C-A0ACBA311B18}"
+EndProject
+Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "VsipSetup", "VsipSetup\VsipSetup.vdproj", "{072DE409-5A89-48AD-8144-A566281E838B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|.NET = Debug|.NET
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|Win32 = Debug|Win32
+ Final|.NET = Final|.NET
+ Final|Any CPU = Final|Any CPU
+ Final|Mixed Platforms = Final|Mixed Platforms
+ Final|Win32 = Final|Win32
+ Release|.NET = Release|.NET
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Debug|.NET.ActiveCfg = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Final|.NET.ActiveCfg = Final|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Final|Any CPU.ActiveCfg = Final|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Final|Any CPU.Build.0 = Final|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Final|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Final|Mixed Platforms.Build.0 = Release|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Final|Win32.ActiveCfg = Final|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Release|.NET.ActiveCfg = Release|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Release|Any CPU.Build.0 = Release|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
+ {87886EF2-1FD7-4C0D-8A76-04F77F136296}.Release|Win32.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Debug|.NET.ActiveCfg = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Final|.NET.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Final|Any CPU.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Final|Any CPU.Build.0 = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Final|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Final|Mixed Platforms.Build.0 = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Final|Win32.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Release|.NET.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Release|Any CPU.Build.0 = Release|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {81DEB782-9FD3-4C2A-8931-E540AC5AB782}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
+