Skip to content

Commit fb3bdfc

Browse files
Added support for lsp version 3.14.0
1 parent f942d26 commit fb3bdfc

File tree

88 files changed

+1294
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1294
-212
lines changed

language-server-protocol.sha.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
-- This is the last commit we caught up with https://github.com/Microsoft/language-server-protocol/commits/gh-pages
2-
9e2713d5f1618b8d5e05a91a4e2c637aa51e1ee0
2+
lastSha: 1a69f1270d59cccd7b85e0697450950abd5a0221
3+
4+
https://github.com/Microsoft/language-server-protocol/compare/<lastSha>..<newSha>

src/Client/LspErrorCodes.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,10 @@ public static class LspErrorCodes
4444
/// Request was cancelled.
4545
/// </summary>
4646
public const int RequestCancelled = -32800;
47+
48+
/// <summary>
49+
/// Request was cancelled.
50+
/// </summary>
51+
public const int ContentModified = -32801;
4752
}
4853
}

src/JsonRpc/AsyncRequestHandler.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace OmniSharp.Extensions.Embedded.MediatR
5+
{
6+
/// <summary>
7+
/// Wrapper class for a handler that asynchronously handles a request and does not return a response
8+
/// </summary>
9+
/// <typeparam name="TRequest">The type of request being handled</typeparam>
10+
public abstract class AsyncRequestHandler<TRequest> : IRequestHandler<TRequest>
11+
where TRequest : IRequest
12+
{
13+
async Task<Unit> IRequestHandler<TRequest, Unit>.Handle(TRequest request, CancellationToken cancellationToken)
14+
{
15+
await Handle(request, cancellationToken).ConfigureAwait(false);
16+
return Unit.Value;
17+
}
18+
19+
/// <summary>
20+
/// Override in a derived class for the handler logic
21+
/// </summary>
22+
/// <param name="request">Request</param>
23+
/// <param name="cancellationToken"></param>
24+
/// <returns>Response</returns>
25+
protected abstract Task Handle(TRequest request, CancellationToken cancellationToken);
26+
}
27+
}

src/JsonRpc/IBaseRequest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace OmniSharp.Extensions.Embedded.MediatR
2+
{
3+
/// <summary>
4+
/// Allows for generic type constraints of objects implementing IRequest or IRequest{TResponse}
5+
/// </summary>
6+
public interface IBaseRequest { }
7+
}

src/JsonRpc/NotificationHandler.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace OmniSharp.Extensions.Embedded.MediatR
5+
{
6+
/// <summary>
7+
/// Wrapper class for a synchronous notification handler
8+
/// </summary>
9+
/// <typeparam name="TNotification">The notification type</typeparam>
10+
public abstract class NotificationHandler<TNotification> : INotificationHandler<TNotification>
11+
where TNotification : INotification
12+
{
13+
Task INotificationHandler<TNotification>.Handle(TNotification notification, CancellationToken cancellationToken)
14+
{
15+
Handle(notification);
16+
return Unit.Task;
17+
}
18+
19+
/// <summary>
20+
/// Override in a derived class for the handler logic
21+
/// </summary>
22+
/// <param name="notification">Notification</param>
23+
protected abstract void Handle(TNotification notification);
24+
}
25+
}

src/JsonRpc/RequestHandler.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace OmniSharp.Extensions.Embedded.MediatR
5+
{
6+
/// <summary>
7+
/// Wrapper class for a handler that synchronously handles a request and returns a response
8+
/// </summary>
9+
/// <typeparam name="TRequest">The type of request being handled</typeparam>
10+
/// <typeparam name="TResponse">The type of response from the handler</typeparam>
11+
public abstract class RequestHandler<TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
12+
where TRequest : IRequest<TResponse>
13+
{
14+
Task<TResponse> IRequestHandler<TRequest, TResponse>.Handle(TRequest request, CancellationToken cancellationToken)
15+
=> Task.FromResult(Handle(request));
16+
17+
/// <summary>
18+
/// Override in a derived class for the handler logic
19+
/// </summary>
20+
/// <param name="request">Request</param>
21+
/// <returns>Response</returns>
22+
protected abstract TResponse Handle(TRequest request);
23+
}
24+
}

src/JsonRpc/RequestHandlerDelegate.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Threading.Tasks;
2+
3+
namespace OmniSharp.Extensions.Embedded.MediatR
4+
{
5+
/// <summary>
6+
/// Represents an async continuation for the next task to execute in the pipeline
7+
/// </summary>
8+
/// <typeparam name="TResponse">Response type</typeparam>
9+
/// <returns>Awaitable task returning a <typeparamref name="TResponse"/></returns>
10+
public delegate Task<TResponse> RequestHandlerDelegate<TResponse>();
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
3+
namespace OmniSharp.Extensions.Embedded.MediatR
4+
{
5+
public static class ServiceFactoryExtensions
6+
{
7+
public static T GetInstance<T>(this ServiceFactory factory)
8+
=> (T) factory(typeof(T));
9+
10+
public static IEnumerable<T> GetInstances<T>(this ServiceFactory factory)
11+
=> (IEnumerable<T>) factory(typeof(IEnumerable<T>));
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
2+
3+
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
4+
{
5+
public class DeclarationCapability : LinkSupportCapability, ConnectedCapability<IDeclarationHandler> { }
6+
}

0 commit comments

Comments
 (0)