-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add Copilot EA for language server #77047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
55cdd6f
Add Copilot EA for langauge server
genlu 03a8554
Merge remote-tracking branch 'dotnet/main' into CopilotExternalAccess
genlu b5ff756
Fix
genlu 1a0521e
fix
genlu c196fae
fix
genlu e71f60c
Address review comments
genlu afb8679
Merge remote-tracking branch 'dotnet/main' into CopilotExternalAccess
genlu f955c20
Add IVT
genlu b2654c8
Address review comments
genlu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
28 changes: 28 additions & 0 deletions
28
...eServer/ExternalAccess/Copilot/Handler/AbstractCopilotLspServiceDocumentRequestHandler.cs
This file contains hidden or 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,28 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.CodeAnalysis.LanguageServer.Handler; | ||
| using Microsoft.CommonLanguageServerProtocol.Framework; | ||
| using Roslyn.LanguageServer.Protocol; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot; | ||
|
|
||
| /// <inheritdoc cref="ILspServiceDocumentRequestHandler{TRequest, TResponse}"/> | ||
| internal abstract class AbstractCopilotLspServiceDocumentRequestHandler<TRequest, TResponse> : ILspServiceDocumentRequestHandler<TRequest, TResponse> | ||
| { | ||
| public abstract Task<TResponse> HandleRequestAsync(TRequest request, CopilotRequestContext context, CancellationToken cancellationToken); | ||
| public abstract Uri GetTextDocumentUri(TRequest request); | ||
|
|
||
| bool IMethodHandler.MutatesSolutionState => false; | ||
| bool ISolutionRequiredHandler.RequiresLSPSolution => true; | ||
|
|
||
| TextDocumentIdentifier ITextDocumentIdentifierHandler<TRequest, TextDocumentIdentifier>.GetTextDocumentIdentifier(TRequest request) | ||
| => new() { Uri = GetTextDocumentUri(request) }; | ||
|
|
||
| Task<TResponse> IRequestHandler<TRequest, TResponse, RequestContext>.HandleRequestAsync(TRequest request, RequestContext context, CancellationToken cancellationToken) | ||
| => HandleRequestAsync(request, new CopilotRequestContext(context), cancellationToken); | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
src/LanguageServer/ExternalAccess/Copilot/Handler/CopilotRequestContext.cs
This file contains hidden or 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,24 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using Microsoft.CodeAnalysis.LanguageServer.Handler; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot; | ||
|
|
||
| /// <summary> | ||
| /// Context for requests handled by <see cref="AbstractCopilotLspServiceDocumentRequestHandler{TRequest, TResponse}"/> | ||
| /// </summary> | ||
| internal readonly struct CopilotRequestContext(RequestContext context) | ||
| { | ||
| /// <summary> | ||
| /// The solution state that the request should operate on. | ||
| /// </summary> | ||
| public Solution Solution => context.Solution ?? throw new InvalidOperationException(); | ||
|
|
||
| /// <inheritdoc cref="RequestContext.Document"/> | ||
| public Document? Document => context.Document; | ||
|
|
||
| public T GetRequiredService<T>() where T : class => context.GetRequiredService<T>(); | ||
| } |
1 change: 1 addition & 0 deletions
1
src/LanguageServer/ExternalAccess/Copilot/InternalAPI.Shipped.txt
This file contains hidden or 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 @@ | ||
| #nullable enable |
20 changes: 20 additions & 0 deletions
20
src/LanguageServer/ExternalAccess/Copilot/InternalAPI.Unshipped.txt
This file contains hidden or 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,20 @@ | ||
| #nullable enable | ||
| abstract Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.AbstractCopilotLspServiceDocumentRequestHandler<TRequest, TResponse>.GetTextDocumentUri(TRequest request) -> System.Uri! | ||
| abstract Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.AbstractCopilotLspServiceDocumentRequestHandler<TRequest, TResponse>.HandleRequestAsync(TRequest request, Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext context, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<TResponse>! | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.AbstractCopilotLspServiceDocumentRequestHandler<TRequest, TResponse> | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.AbstractCopilotLspServiceDocumentRequestHandler<TRequest, TResponse>.AbstractCopilotLspServiceDocumentRequestHandler() -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotLspServices | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotLspServices.CopilotLspServices() -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotLspServices.CopilotLspServices(Microsoft.CodeAnalysis.LanguageServer.LspServices! lspServices) -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotLspServices.GetService<T>() -> T? | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotMethodAttribute | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotMethodAttribute.CopilotMethodAttribute(string! method) -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext.CopilotRequestContext() -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext.CopilotRequestContext(Microsoft.CodeAnalysis.LanguageServer.Handler.RequestContext context) -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext.Document.get -> Microsoft.CodeAnalysis.Document? | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext.GetRequiredService<T>() -> T! | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.CopilotRequestContext.Solution.get -> Microsoft.CodeAnalysis.Solution! | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.ExportCopilotStatelessLspServiceAttribute | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.ExportCopilotStatelessLspServiceAttribute.ExportCopilotStatelessLspServiceAttribute(System.Type! type) -> void | ||
| Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.ICopilotLspService |
11 changes: 11 additions & 0 deletions
11
src/LanguageServer/ExternalAccess/Copilot/LspServices/CopilotLspServices.cs
This file contains hidden or 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,11 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot; | ||
|
|
||
| internal readonly struct CopilotLspServices(LspServices lspServices) | ||
| { | ||
| public T? GetService<T>() where T : notnull | ||
| => lspServices.GetService<T>(); | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/LanguageServer/ExternalAccess/Copilot/LspServices/CopilotMethodAttribute.cs
This file contains hidden or 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,13 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Microsoft.CodeAnalysis.LanguageServer.Handler; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot; | ||
|
|
||
| /// <summary> | ||
| /// An attribute which identifies the method which a Copilot request handler like | ||
| /// <see cref="AbstractCopilotLspServiceDocumentRequestHandler{TRequest, TResponse}"/> implements. | ||
| /// </summary> | ||
| internal sealed class CopilotMethodAttribute(string method) : MethodAttribute(method); |
12 changes: 12 additions & 0 deletions
12
...ageServer/ExternalAccess/Copilot/LspServices/ExportCopilotStatelessLspServiceAttribute.cs
This file contains hidden or 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,12 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using Microsoft.CodeAnalysis.LanguageServer.Handler; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot; | ||
|
|
||
| /// <inheritdoc cref="ExportStatelessLspServiceAttribute"/> | ||
| internal sealed class ExportCopilotStatelessLspServiceAttribute(Type type) : | ||
| ExportCSharpVisualBasicStatelessLspServiceAttribute(type, WellKnownLspServerKinds.Any); |
12 changes: 12 additions & 0 deletions
12
src/LanguageServer/ExternalAccess/Copilot/LspServices/ICopilotLspService.cs
This file contains hidden or 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,12 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot; | ||
|
|
||
| /// <summary> | ||
| /// Interface to mark a Copilot LSP service. | ||
| /// </summary> | ||
| internal interface ICopilotLspService : ILspService | ||
| { | ||
| } |
34 changes: 34 additions & 0 deletions
34
...xternalAccess/Copilot/Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.csproj
This file contains hidden or 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,34 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Library</OutputType> | ||
| <RootNamespace>Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot</RootNamespace> | ||
| <TargetFramework>netstandard2.0</TargetFramework> | ||
|
|
||
| <IsPackable>true</IsPackable> | ||
| <PackageId>Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot</PackageId> | ||
| <PackageDescription> | ||
| A supporting package for the GitHub Copilot in Visual Studio Code. | ||
| </PackageDescription> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <!-- | ||
| ⚠ ONLY COPILOT ASSEMBLIES MAY BE ADDED HERE ⚠ | ||
| --> | ||
| <InternalsVisibleTo Include="Microsoft.VisualStudio.Copilot.Roslyn.LanguageServer" Key="$(CopilotKey)" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj" PrivateAssets="all" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PublicAPI Include="PublicAPI.Shipped.txt" /> | ||
| <PublicAPI Include="PublicAPI.Unshipped.txt" /> | ||
| <PublicAPI Include="InternalAPI.Shipped.txt" /> | ||
| <PublicAPI Include="InternalAPI.Unshipped.txt" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
Empty file.
1 change: 1 addition & 0 deletions
1
src/LanguageServer/ExternalAccess/Copilot/PublicAPI.Unshipped.txt
This file contains hidden or 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 @@ | ||
|
|
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.