Skip to content

Commit

Permalink
feat(visual-studio): Add Visual Studio integration
Browse files Browse the repository at this point in the history
  • Loading branch information
FH-Inway authored and chrissimon-au committed Jul 25, 2024
1 parent 965cb30 commit b052a82
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ fable_modules
.vscode-test
.DS_Store
# Resharper
*.DotSettings.user
*.DotSettings.user
# Visual Studio
.vs
68 changes: 36 additions & 32 deletions src/Contextive.sln
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{9B2F48A4-8ED8-4E23-BEBF-09D6E817887C}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Contextive.Core", "core\Contextive.Core\Contextive.Core.fsproj", "{D4E10313-76AB-4900-AF30-6FD32ADC5EB3}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Contextive.Core", "core\Contextive.Core\Contextive.Core.fsproj", "{D4E10313-76AB-4900-AF30-6FD32ADC5EB3}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Contextive.Core.Tests", "core\Contextive.Core.Tests\Contextive.Core.Tests.fsproj", "{A1268C6B-B1EA-45F6-B243-12014D304C2D}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Contextive.Core.Tests", "core\Contextive.Core.Tests\Contextive.Core.Tests.fsproj", "{A1268C6B-B1EA-45F6-B243-12014D304C2D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguageServer", "LanguageServer", "{747C11A9-7FA8-45D9-BC07-EDC787C7032C}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Contextive.LanguageServer", "language-server\Contextive.LanguageServer\Contextive.LanguageServer.fsproj", "{C60440CF-3096-4A1D-9DA8-B175A03F43CE}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Contextive.LanguageServer", "language-server\Contextive.LanguageServer\Contextive.LanguageServer.fsproj", "{C60440CF-3096-4A1D-9DA8-B175A03F43CE}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Contextive.LanguageServer.Tests", "language-server\Contextive.LanguageServer.Tests\Contextive.LanguageServer.Tests.fsproj", "{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Contextive.LanguageServer.Tests", "language-server\Contextive.LanguageServer.Tests\Contextive.LanguageServer.Tests.fsproj", "{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VSCode", "VSCode", "{D4397B0F-EE1D-4BFD-8687-59E9F269A085}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Contextive.VsCodeExtension", "vscode\contextive\src\Contextive.VsCodeExtension.fsproj", "{7A19B8AD-9F80-42D2-8756-C561069F592B}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Contextive.VsCodeExtension", "vscode\contextive\src\Contextive.VsCodeExtension.fsproj", "{7A19B8AD-9F80-42D2-8756-C561069F592B}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Contextive.VsCodeExtension.Tests.E2e", "vscode\contextive\test\Contextive.VsCodeExtension.Tests.E2e.fsproj", "{87851465-027B-4D5E-9F48-1CBB70E31F69}"
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Contextive.VsCodeExtension.Tests.E2e", "vscode\contextive\test\Contextive.VsCodeExtension.Tests.E2e.fsproj", "{87851465-027B-4D5E-9F48-1CBB70E31F69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Release|Any CPU.Build.0 = Release|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Release|Any CPU.Build.0 = Release|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Release|Any CPU.Build.0 = Release|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Release|Any CPU.Build.0 = Release|Any CPU
{D4E10313-76AB-4900-AF30-6FD32ADC5EB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4E10313-76AB-4900-AF30-6FD32ADC5EB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4E10313-76AB-4900-AF30-6FD32ADC5EB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -53,13 +35,35 @@ Global
{A1268C6B-B1EA-45F6-B243-12014D304C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1268C6B-B1EA-45F6-B243-12014D304C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1268C6B-B1EA-45F6-B243-12014D304C2D}.Release|Any CPU.Build.0 = Release|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C60440CF-3096-4A1D-9DA8-B175A03F43CE}.Release|Any CPU.Build.0 = Release|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB}.Release|Any CPU.Build.0 = Release|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A19B8AD-9F80-42D2-8756-C561069F592B}.Release|Any CPU.Build.0 = Release|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87851465-027B-4D5E-9F48-1CBB70E31F69}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7A19B8AD-9F80-42D2-8756-C561069F592B} = {D4397B0F-EE1D-4BFD-8687-59E9F269A085}
{87851465-027B-4D5E-9F48-1CBB70E31F69} = {D4397B0F-EE1D-4BFD-8687-59E9F269A085}
{C60440CF-3096-4A1D-9DA8-B175A03F43CE} = {747C11A9-7FA8-45D9-BC07-EDC787C7032C}
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB} = {747C11A9-7FA8-45D9-BC07-EDC787C7032C}
{D4E10313-76AB-4900-AF30-6FD32ADC5EB3} = {9B2F48A4-8ED8-4E23-BEBF-09D6E817887C}
{A1268C6B-B1EA-45F6-B243-12014D304C2D} = {9B2F48A4-8ED8-4E23-BEBF-09D6E817887C}
{C60440CF-3096-4A1D-9DA8-B175A03F43CE} = {747C11A9-7FA8-45D9-BC07-EDC787C7032C}
{2892BFE0-BCB9-4030-BF6C-4CCADA301BFB} = {747C11A9-7FA8-45D9-BC07-EDC787C7032C}
{7A19B8AD-9F80-42D2-8756-C561069F592B} = {D4397B0F-EE1D-4BFD-8687-59E9F269A085}
{87851465-027B-4D5E-9F48-1CBB70E31F69} = {D4397B0F-EE1D-4BFD-8687-59E9F269A085}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2D6D446E-1A80-427C-9F41-0353B1700ED1}
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions src/visualstudio/contextive/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# VSEXTPREVIEW_LSP: Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
dotnet_diagnostic.VSEXTPREVIEW_LSP.severity = warning
30 changes: 30 additions & 0 deletions src/visualstudio/contextive/contextive.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "contextive", "contextive\contextive.csproj", "{28DE60F3-CA21-40D2-98FB-272DD1BF59B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CA664830-2F02-43A0-8508-221ED6966D6D}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{28DE60F3-CA21-40D2-98FB-272DD1BF59B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28DE60F3-CA21-40D2-98FB-272DD1BF59B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28DE60F3-CA21-40D2-98FB-272DD1BF59B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28DE60F3-CA21-40D2-98FB-272DD1BF59B7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BDC1E74-7EA6-434C-85E0-7552DA8F091E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contextive.LanguageServerProvider.DisplayName": "Contextive"
}
26 changes: 26 additions & 0 deletions src/visualstudio/contextive/contextive/ContextiveExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.Extensibility;

namespace contextive
{
[VisualStudioContribution]
internal class ContextiveExtension : Extension
{
/// <inheritdoc/>
public override ExtensionConfiguration ExtensionConfiguration => new()
{
Metadata = new(
id: "contextive.f050f6e5-c51b-4c33-9a59-ba9945a00259",
version: this.ExtensionAssemblyVersion,
publisherName: "Dev Cycles",
displayName: "Contextive",
description: "Supports developers where a complex domain or project specific language is in use by surfacing definitions everywhere specific words are used - code, comments, config or documentation."),
};

/// <inheritdoc />
protected override void InitializeServices(IServiceCollection serviceCollection)
{
base.InitializeServices(serviceCollection);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using Microsoft.VisualStudio.Extensibility;
using Microsoft.VisualStudio.Extensibility.Editor;
using Microsoft.VisualStudio.Extensibility.LanguageServer;
using Microsoft.VisualStudio.RpcContracts.LanguageServerProvider;
using Nerdbank.Streams;
using System.Diagnostics;
using System.IO.Pipelines;
using System.Reflection;

namespace contextive;

[VisualStudioContribution]
public class ContextiveLanguageServerProvider : LanguageServerProvider
{
public ContextiveLanguageServerProvider(
ExtensionCore container,
VisualStudioExtensibility extensibilityObject,
TraceSource traceSource) : base(container, extensibilityObject)
{

}

public IEnumerable<string> ConfigurationSections
{
get
{
yield return "contextive";
}
}

[VisualStudioContribution]
public static DocumentTypeConfiguration AnyDocumentType => new("any")
{
FileExtensions = new[] { ".*" },
BaseDocumentType = LanguageServerBaseDocumentType,
};

public override LanguageServerProviderConfiguration LanguageServerProviderConfiguration =>
new("%contextive.LanguageServerProvider.DisplayName%",
new[]
{
DocumentFilter.FromDocumentType(AnyDocumentType),
});

public override Task<IDuplexPipe?> CreateServerConnectionAsync(CancellationToken cancellationToken)
{
string workingDirectory = Path.Combine(
Path.GetTempPath(),
"contextive",
Guid.NewGuid().ToString());
Directory.CreateDirectory(workingDirectory);

ProcessStartInfo info = new()
{
FileName = Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!,
@"Contextive.LanguageServer.exe"),
RedirectStandardInput = true,
RedirectStandardOutput = true,
UseShellExecute = false, // needs to be false so that IO streams can be redirected
CreateNoWindow = true,
WorkingDirectory = workingDirectory
};

Process process = new Process();
process.StartInfo = info;

if (process.Start())
{
return Task.FromResult<IDuplexPipe?>(new DuplexPipe(
PipeReader.Create(process.StandardOutput.BaseStream),
PipeWriter.Create(process.StandardInput.BaseStream)));
}

return Task.FromResult<IDuplexPipe?>(null);
}

public override Task OnServerInitializationResultAsync(
ServerInitializationResult serverInitializationResult,
LanguageServerInitializationFailureInfo? initializationFailureInfo,
CancellationToken cancellationToken)
{
if (serverInitializationResult == ServerInitializationResult.Failed)
{
this.Enabled = false;
}
return base.OnServerInitializationResultAsync(
serverInitializationResult, initializationFailureInfo, cancellationToken);
}
}
16 changes: 16 additions & 0 deletions src/visualstudio/contextive/contextive/contextive.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="Contextive.LanguageServer.exe" />
<None Remove="contextive.pkgdef" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.9.2092" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.9.2092" />
</ItemGroup>
</Project>

0 comments on commit b052a82

Please sign in to comment.