-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(visual-studio): Add Visual Studio integration
- Loading branch information
1 parent
965cb30
commit b052a82
Showing
8 changed files
with
208 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,6 @@ fable_modules | |
.vscode-test | ||
.DS_Store | ||
# Resharper | ||
*.DotSettings.user | ||
*.DotSettings.user | ||
# Visual Studio | ||
.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
3 changes: 3 additions & 0 deletions
3
src/visualstudio/contextive/contextive/.vsextension/string-resources.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"contextive.LanguageServerProvider.DisplayName": "Contextive" | ||
} |
26 changes: 26 additions & 0 deletions
26
src/visualstudio/contextive/contextive/ContextiveExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/visualstudio/contextive/contextive/ContextiveLanguageServerProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |