Skip to content

Commit

Permalink
Added Direction method attribute, updated all methods and handlers to…
Browse files Browse the repository at this point in the history
… have delegates (#247)
  • Loading branch information
david-driscoll authored May 22, 2020
1 parent 878897c commit bdec4c7
Show file tree
Hide file tree
Showing 847 changed files with 10,941 additions and 7,076 deletions.
3 changes: 2 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
<PackageReference Update="XunitXml.TestLogger" Version="2.1.26"/>
<PackageReference Update="coverlet.collector" Version="1.2.0"/>
<PackageReference Update="coverlet.msbuild" Version="2.8.0"/>
<PackageReference Update="System.Reactive" Version="4.3.2"/>
<PackageReference Update="System.Reactive" Version="4.4.1"/>
<PackageReference Update="Microsoft.Reactive.Testing" Version="4.3.2"/>
<PackageReference Update="MediatR" Version="8.0.1"/>
<PackageReference Update="MediatR.Extensions.Microsoft.DependencyInjection" Version="8.0.0"/>
<PackageReference Update="Bogus" Version="29.0.1"/>
<PackageReference Update="Snapper" Version="2.2.4"/>
<PackageReference Update="Xunit.SkippableFact" Version="1.4.8" />
<PackageReference Update="DynamicData" Version="6.14.18" />
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions LSP.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ".build", ".build\.build.csp
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".build", ".build", "{26522B49-0743-4CBE-BA67-6D17FF65CAB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dap.Tests", "test\Dap.Tests\Dap.Tests.csproj", "{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -193,6 +195,18 @@ Global
{28B13787-A442-4D28-BF9A-3D65BF13AAEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28B13787-A442-4D28-BF9A-3D65BF13AAEC}.Release|x64.ActiveCfg = Release|Any CPU
{28B13787-A442-4D28-BF9A-3D65BF13AAEC}.Release|x86.ActiveCfg = Release|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Debug|x64.ActiveCfg = Debug|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Debug|x64.Build.0 = Debug|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Debug|x86.ActiveCfg = Debug|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Debug|x86.Build.0 = Debug|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Release|Any CPU.Build.0 = Release|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Release|x64.ActiveCfg = Release|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Release|x64.Build.0 = Release|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Release|x86.ActiveCfg = Release|Any CPU
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -209,6 +223,7 @@ Global
{F2C9D555-118E-442B-A953-9A7B58A53F33} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
{E1A9123B-A236-4240-8C82-A61BD85C3BF4} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
{28B13787-A442-4D28-BF9A-3D65BF13AAEC} = {26522B49-0743-4CBE-BA67-6D17FF65CAB9}
{F3DF7917-6AD3-4EAA-A549-555032DDC4F8} = {2F323ED5-EBF8-45E1-B9D3-C014561B3DDA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D38DD0EC-D095-4BCD-B8AF-2D788AF3B9AE}
Expand Down
2 changes: 1 addition & 1 deletion sample/SampleServer/DidChangeWatchedFilesHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using MediatR;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;

namespace SampleServer
{
Expand Down
2 changes: 1 addition & 1 deletion sample/SampleServer/FoldingRangeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Server;

namespace SampleServer
{
Expand Down
6 changes: 3 additions & 3 deletions sample/SampleServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void Main(string[] args)
static async Task MainAsync(string[] args)
{
// Debugger.Launch();
// while (!System.Diagnostics.Debugger.IsAttached)
// while (!Debugger.IsAttached)
// {
// await Task.Delay(100);
// }
Expand Down Expand Up @@ -66,7 +66,7 @@ static async Task MainAsync(string[] args)
});
})
.OnInitialize(async (server, request, token) => {
var manager = server.ProgressManager.WorkDone(request, new WorkDoneProgressBegin() {
var manager = server.WorkDoneManager.For(request, new WorkDoneProgressBegin() {
Title = "Server is starting...",
Percentage = 10,
});
Expand Down Expand Up @@ -94,7 +94,7 @@ static async Task MainAsync(string[] args)
workDone.OnCompleted();
})
.OnStarted(async (languageServer, result, token) => {
using var manager = languageServer.ProgressManager.Create(new WorkDoneProgressBegin() { Title = "Doing some work..." });
using var manager = await languageServer.WorkDoneManager.Create(new WorkDoneProgressBegin() { Title = "Doing some work..." });

manager.OnNext(new WorkDoneProgressReport() { Message = "doing things..." });
await Task.Delay(10000);
Expand Down
2 changes: 1 addition & 1 deletion sample/SampleServer/SemanticTokens.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Document.Server.Proposals;
using OmniSharp.Extensions.LanguageServer.Protocol.Document.Proposals;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals;

Expand Down
27 changes: 17 additions & 10 deletions sample/SampleServer/TextDocumentHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
Expand All @@ -7,10 +6,13 @@
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Progress;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
using OmniSharp.Extensions.LanguageServer.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.WorkDone;
using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;

namespace SampleServer
{
Expand Down Expand Up @@ -104,11 +106,11 @@ public TextDocumentAttributes GetTextDocumentAttributes(DocumentUri uri)
}
}

class MyDocumentSymbolHandler : OmniSharp.Extensions.LanguageServer.Protocol.Server.DocumentSymbolHandler
class MyDocumentSymbolHandler : DocumentSymbolHandler
{
public MyDocumentSymbolHandler(ProgressManager progressManager) : base(new DocumentSymbolRegistrationOptions() {
public MyDocumentSymbolHandler() : base(new DocumentSymbolRegistrationOptions() {
DocumentSelector = DocumentSelector.ForLanguage("csharp")
}, progressManager)
})
{
}

Expand Down Expand Up @@ -155,26 +157,31 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
}
}

class MyWorkspaceSymbolsHandler : OmniSharp.Extensions.LanguageServer.Protocol.Server.WorkspaceSymbolsHandler
class MyWorkspaceSymbolsHandler : WorkspaceSymbolsHandler
{
private readonly IServerWorkDoneManager _manager;
private readonly IServerWorkDoneManager _serverWorkDoneManager;
private readonly IProgressManager _progressManager;
private readonly ILogger<MyWorkspaceSymbolsHandler> logger;

public MyWorkspaceSymbolsHandler(ProgressManager progressManager, ILogger<MyWorkspaceSymbolsHandler> logger) :
base(new WorkspaceSymbolRegistrationOptions() { }, progressManager)
public MyWorkspaceSymbolsHandler(IServerWorkDoneManager serverWorkDoneManager, IProgressManager progressManager, ILogger<MyWorkspaceSymbolsHandler> logger) :
base(new WorkspaceSymbolRegistrationOptions() { })
{
_serverWorkDoneManager = serverWorkDoneManager;
_progressManager = progressManager;
this.logger = logger;
}

public override async Task<Container<SymbolInformation>> Handle(WorkspaceSymbolParams request,
CancellationToken cancellationToken)
{
using var reporter = ProgressManager.WorkDone(request, new WorkDoneProgressBegin() {
using var reporter = _serverWorkDoneManager.For(request, new WorkDoneProgressBegin() {
Cancellable = true,
Message = "This might take a while...",
Title = "Some long task....",
Percentage = 0
});
using var partialResults = ProgressManager.For(request, cancellationToken);
using var partialResults = _progressManager.For(request, cancellationToken);
if (partialResults != null)
{
await Task.Delay(2000, cancellationToken);
Expand Down
4 changes: 1 addition & 3 deletions src/Client/Clients/TextDocumentClient.Completions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -32,7 +30,7 @@ public partial class TextDocumentClient
/// </returns>
public Task<CompletionList> Completions(DocumentUri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
{
return PositionalRequest<CompletionList>(DocumentNames.Completion, documentUri, line, column, cancellationToken);
return PositionalRequest<CompletionList>(TextDocumentNames.Completion, documentUri, line, column, cancellationToken);
}
}
}
4 changes: 1 addition & 3 deletions src/Client/Clients/TextDocumentClient.Definition.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -32,7 +30,7 @@ public partial class TextDocumentClient
/// </returns>
public Task<LocationOrLocationLinks> Definition(DocumentUri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
{
return PositionalRequest<LocationOrLocationLinks>(DocumentNames.Definition, documentUri, line, column, cancellationToken);
return PositionalRequest<LocationOrLocationLinks>(TextDocumentNames.Definition, documentUri, line, column, cancellationToken);
}
}
}
2 changes: 1 addition & 1 deletion src/Client/Clients/TextDocumentClient.Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public IDisposable OnPublishDiagnostics(PublishDiagnosticsHandler handler)
if (handler == null)
throw new ArgumentNullException(nameof(handler));

return Client.HandleNotification<PublishDiagnosticsParams>(DocumentNames.PublishDiagnostics, notification =>
return Client.HandleNotification<PublishDiagnosticsParams>(TextDocumentNames.PublishDiagnostics, notification =>
{
if (notification.Diagnostics == null)
if (notification.Diagnostics == null)
Expand Down
4 changes: 1 addition & 3 deletions src/Client/Clients/TextDocumentClient.DocumentHighlights.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -32,7 +30,7 @@ public partial class TextDocumentClient
/// </returns>
public Task<DocumentHighlightContainer> DocumentHighlights(DocumentUri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
{
return PositionalRequest<DocumentHighlightContainer>(DocumentNames.DocumentHighlight, documentUri, line, column, cancellationToken);
return PositionalRequest<DocumentHighlightContainer>(TextDocumentNames.DocumentHighlight, documentUri, line, column, cancellationToken);
}
}
}
4 changes: 1 addition & 3 deletions src/Client/Clients/TextDocumentClient.FoldingRanges.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -38,7 +36,7 @@ public partial class TextDocumentClient
}
};

return await Client.SendRequest<Container<FoldingRange>>(DocumentNames.FoldingRange, request, cancellationToken).ConfigureAwait(false);
return await Client.SendRequest<Container<FoldingRange>>(TextDocumentNames.FoldingRange, request, cancellationToken).ConfigureAwait(false);
}
}
}
3 changes: 1 addition & 2 deletions src/Client/Clients/TextDocumentClient.Hover.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -58,7 +57,7 @@ public partial class TextDocumentClient
/// </returns>
public Task<Hover> Hover(DocumentUri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
{
return PositionalRequest<Hover>(DocumentNames.Hover, documentUri, line, column, cancellationToken);
return PositionalRequest<Hover>(TextDocumentNames.Hover, documentUri, line, column, cancellationToken);
}
}
}
4 changes: 1 addition & 3 deletions src/Client/Clients/TextDocumentClient.SignatureHelp.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -32,7 +30,7 @@ public partial class TextDocumentClient
/// </returns>
public Task<SignatureHelp> SignatureHelp(DocumentUri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
{
return PositionalRequest<SignatureHelp>(DocumentNames.SignatureHelp, documentUri, line, column, cancellationToken);
return PositionalRequest<SignatureHelp>(TextDocumentNames.SignatureHelp, documentUri, line, column, cancellationToken);
}
}
}
9 changes: 4 additions & 5 deletions src/Client/Clients/TextDocumentClient.Sync.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

Expand Down Expand Up @@ -86,7 +85,7 @@ public void DidOpen(DocumentUri documentUri, string languageId, string text, int
if (documentUri == null)
throw new ArgumentNullException(nameof(documentUri));

Client.SendNotification(DocumentNames.DidOpen, new DidOpenTextDocumentParams
Client.SendNotification(TextDocumentNames.DidOpen, new DidOpenTextDocumentParams
{
TextDocument = new TextDocumentItem
{
Expand Down Expand Up @@ -181,7 +180,7 @@ public void DidChange(DocumentUri documentUri, string languageId, string text, i
if (documentUri == null)
throw new ArgumentNullException(nameof(documentUri));

Client.SendNotification(DocumentNames.DidChange, new DidChangeTextDocumentParams
Client.SendNotification(TextDocumentNames.DidChange, new DidChangeTextDocumentParams
{
TextDocument = new VersionedTextDocumentIdentifier
{
Expand Down Expand Up @@ -225,7 +224,7 @@ public void DidClose(DocumentUri documentUri)
if (documentUri == null)
throw new ArgumentNullException(nameof(documentUri));

Client.SendNotification(DocumentNames.DidClose, new DidCloseTextDocumentParams
Client.SendNotification(TextDocumentNames.DidClose, new DidCloseTextDocumentParams
{
TextDocument = new TextDocumentItem
{
Expand Down Expand Up @@ -261,7 +260,7 @@ public void DidSave(DocumentUri documentUri)
if (documentUri == null)
throw new ArgumentNullException(nameof(documentUri));

Client.SendNotification(DocumentNames.DidSave, new DidSaveTextDocumentParams
Client.SendNotification(TextDocumentNames.DidSave, new DidSaveTextDocumentParams
{
TextDocument = new TextDocumentItem
{
Expand Down
3 changes: 0 additions & 3 deletions src/Client/Handlers/DelegateNotificationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
{
Expand Down
3 changes: 0 additions & 3 deletions src/Client/Handlers/DelegateRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
{
Expand Down
3 changes: 0 additions & 3 deletions src/Client/Handlers/DelegateRequestResponseHandler.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
{
Expand Down
1 change: 0 additions & 1 deletion src/Client/Handlers/DynamicRegistrationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
Expand Down
1 change: 0 additions & 1 deletion src/Client/Handlers/IInvokeNotificationHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
{
Expand Down
1 change: 0 additions & 1 deletion src/Client/Handlers/IInvokeRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
{
Expand Down
2 changes: 0 additions & 2 deletions src/Client/Handlers/JsonRpcNotificationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using MediatR;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

namespace OmniSharp.Extensions.LanguageServer.Client.Handlers
{
Expand Down
Loading

0 comments on commit bdec4c7

Please sign in to comment.