Skip to content

Commit a730b68

Browse files
Merge remote-tracking branch 'origin/master' into fix/text-options-defaults
2 parents 648581d + d997627 commit a730b68

File tree

370 files changed

+6810
-586
lines changed

Some content is hidden

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

370 files changed

+6810
-586
lines changed

.gitmodules

-6
This file was deleted.

Common.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<PackageTags>lsp;language server;language server protocol;language client;language server client</PackageTags>
1313
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\lsp.snk</AssemblyOriginatorKeyFile>
1414
<Logging_Extensions_Version>2.0.0</Logging_Extensions_Version>
15+
<MediatR_Version>7.0.0</MediatR_Version>
1516
</PropertyGroup>
1617
<PropertyGroup>
1718
<EmbedUntrackedSources>true</EmbedUntrackedSources>

Common.Build.targets

+2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
<PackageReference Update="XunitXml.TestLogger" Version="2.1.26" />
2323
<PackageReference Update="coverlet.msbuild" Version="2.5.1" />
2424
<PackageReference Update="System.Reactive" Version="4.1.2" />
25+
<PackageReference Update="MediatR" Version="$(MediatR_Version)" />
26+
<PackageReference Update="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatR_Version)" />
2527
</ItemGroup>
2628
</Project>

LSP.sln

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 16
33
VisualStudioVersion = 16.0.29025.244
44
MinimumVisualStudioVersion = 10.0.40219.1
@@ -50,6 +50,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
5050
cake.config = cake.config
5151
EndProjectSection
5252
EndProject
53+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dap.Protocol", "src\Dap.Protocol\Dap.Protocol.csproj", "{F2C9D555-118E-442B-A953-9A7B58A53F33}"
54+
EndProject
55+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dap.Server", "src\Dap.Server\Dap.Server.csproj", "{E1A9123B-A236-4240-8C82-A61BD85C3BF4}"
56+
EndProject
5357
Global
5458
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5559
Debug|Any CPU = Debug|Any CPU
@@ -156,6 +160,30 @@ Global
156160
{E540868F-438E-4F7F-BBB7-010D6CB18A57}.Release|x64.Build.0 = Release|Any CPU
157161
{E540868F-438E-4F7F-BBB7-010D6CB18A57}.Release|x86.ActiveCfg = Release|Any CPU
158162
{E540868F-438E-4F7F-BBB7-010D6CB18A57}.Release|x86.Build.0 = Release|Any CPU
163+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
164+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|Any CPU.Build.0 = Debug|Any CPU
165+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x64.ActiveCfg = Debug|Any CPU
166+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x64.Build.0 = Debug|Any CPU
167+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x86.ActiveCfg = Debug|Any CPU
168+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Debug|x86.Build.0 = Debug|Any CPU
169+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|Any CPU.ActiveCfg = Release|Any CPU
170+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|Any CPU.Build.0 = Release|Any CPU
171+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x64.ActiveCfg = Release|Any CPU
172+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x64.Build.0 = Release|Any CPU
173+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x86.ActiveCfg = Release|Any CPU
174+
{F2C9D555-118E-442B-A953-9A7B58A53F33}.Release|x86.Build.0 = Release|Any CPU
175+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
176+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
177+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x64.ActiveCfg = Debug|Any CPU
178+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x64.Build.0 = Debug|Any CPU
179+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x86.ActiveCfg = Debug|Any CPU
180+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Debug|x86.Build.0 = Debug|Any CPU
181+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
182+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|Any CPU.Build.0 = Release|Any CPU
183+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x64.ActiveCfg = Release|Any CPU
184+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x64.Build.0 = Release|Any CPU
185+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x86.ActiveCfg = Release|Any CPU
186+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4}.Release|x86.Build.0 = Release|Any CPU
159187
EndGlobalSection
160188
GlobalSection(SolutionProperties) = preSolution
161189
HideSolutionNode = FALSE
@@ -169,6 +197,8 @@ Global
169197
{97437BE1-2EC3-4F6B-AC75-C3E099040A07} = {2F323ED5-EBF8-45E1-B9D3-C014561B3DDA}
170198
{92B331E9-5225-428D-AE82-37F5F46156A3} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
171199
{E540868F-438E-4F7F-BBB7-010D6CB18A57} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
200+
{F2C9D555-118E-442B-A953-9A7B58A53F33} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
201+
{E1A9123B-A236-4240-8C82-A61BD85C3BF4} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
172202
EndGlobalSection
173203
GlobalSection(ExtensibilityGlobals) = postSolution
174204
SolutionGuid = {D38DD0EC-D095-4BCD-B8AF-2D788AF3B9AE}

build.cake

-22
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
#load "nuget:?package=Rocket.Surgery.Cake.Library&version=0.9.3";
22

3-
Task("Submodules")
4-
.Does(() => {
5-
StartProcess("git", "submodule update --init --recursive");
6-
});
7-
8-
Task("Embed MediatR")
9-
.Does(() => {
10-
foreach (var file in GetFiles("submodules/**/*.cs"))
11-
{
12-
var content = System.IO.File.ReadAllText(file.FullPath);
13-
if (content.IndexOf("namespace MediatR") > -1 || content.IndexOf("using MediatR") > -1)
14-
{
15-
System.IO.File.WriteAllText(file.FullPath, content
16-
.Replace("namespace MediatR", "namespace OmniSharp.Extensions.Embedded.MediatR")
17-
.Replace("using MediatR", "using OmniShqarp.Extensions.Embedded.MediatR")
18-
);
19-
}
20-
}
21-
});
22-
233
Task("Default")
24-
.IsDependentOn("Submodules")
25-
.IsDependentOn("Embed MediatR")
264
.IsDependentOn("dotnetcore");
275

286
RunTarget(Target);

sample/SampleServer/Program.cs

+41-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
22
using System.Diagnostics;
33
using System.Threading.Tasks;
4+
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Logging;
56
using OmniSharp.Extensions.LanguageServer;
67
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
78
using OmniSharp.Extensions.LanguageServer.Server;
9+
using Serilog;
810

911
namespace SampleServer
1012
{
@@ -22,19 +24,56 @@ static async Task MainAsync(string[] args)
2224
// await Task.Delay(100);
2325
// }
2426

27+
Log.Logger = new LoggerConfiguration()
28+
.Enrich.FromLogContext()
29+
.WriteTo.File("log.txt", rollingInterval: RollingInterval.Day)
30+
.CreateLogger();
31+
32+
Log.Logger.Information("This only goes file...");
33+
2534
var server = await LanguageServer.From(options =>
2635
options
2736
.WithInput(Console.OpenStandardInput())
2837
.WithOutput(Console.OpenStandardOutput())
29-
.WithLoggerFactory(new LoggerFactory())
38+
.ConfigureLogging(x => x.AddSerilog())
3039
.AddDefaultLoggingProvider()
31-
.WithMinimumLogLevel(LogLevel.Trace)
3240
.WithHandler<TextDocumentHandler>()
3341
.WithHandler<DidChangeWatchedFilesHandler>()
3442
.WithHandler<FoldingRangeHandler>()
43+
.WithServices(services => {
44+
services.AddSingleton<Foo>(provider => {
45+
var loggerFactory = provider.GetService<ILoggerFactory>();
46+
var logger = loggerFactory.CreateLogger<Foo>();
47+
48+
logger.LogInformation("Configuring");
49+
50+
return new Foo(logger);
51+
});
52+
}).OnInitialize((s, request) => {
53+
var serviceProvider = s.Services;
54+
var foo = serviceProvider.GetService<Foo>();
55+
56+
return Task.CompletedTask;
57+
})
3558
);
3659

3760
await server.WaitForExit;
3861
}
3962
}
63+
64+
internal class Foo
65+
{
66+
private readonly ILogger<Foo> _logger;
67+
68+
public Foo(ILogger<Foo> logger)
69+
{
70+
logger.LogInformation("inside ctor");
71+
_logger = logger;
72+
}
73+
74+
public void SayFoo()
75+
{
76+
_logger.LogInformation("Fooooo!");
77+
}
78+
}
4079
}

sample/SampleServer/SampleServer.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<IsPackable>false</IsPackable>
6-
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
<TargetFramework>netcoreapp2.1</TargetFramework>
77
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<ProjectReference Include="../../src/Server/Server.csproj" />
1212
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
13+
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
14+
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0-dev-00850" />
1315
</ItemGroup>
1416

1517
</Project>

sample/SampleServer/TextDocumentHandler.cs

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using OmniSharp.Extensions.Embedded.MediatR;
4+
using MediatR;
5+
using Microsoft.Extensions.Logging;
56
using OmniSharp.Extensions.LanguageServer;
67
using OmniSharp.Extensions.LanguageServer.Protocol;
78
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
@@ -15,7 +16,7 @@ namespace SampleServer
1516
{
1617
class TextDocumentHandler : ITextDocumentSyncHandler
1718
{
18-
private readonly OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer _router;
19+
private readonly ILogger<TextDocumentHandler> _logger;
1920

2021
private readonly DocumentSelector _documentSelector = new DocumentSelector(
2122
new DocumentFilter() {
@@ -25,19 +26,17 @@ class TextDocumentHandler : ITextDocumentSyncHandler
2526

2627
private SynchronizationCapability _capability;
2728

28-
public TextDocumentHandler(OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer router)
29+
public TextDocumentHandler(ILogger<TextDocumentHandler> logger, Foo foo)
2930
{
30-
_router = router;
31+
_logger = logger;
32+
foo.SayFoo();
3133
}
3234

3335
public TextDocumentSyncKind Change { get; } = TextDocumentSyncKind.Full;
3436

3537
public Task<Unit> Handle(DidChangeTextDocumentParams notification, CancellationToken token)
3638
{
37-
_router.Window.LogMessage(new LogMessageParams() {
38-
Type = MessageType.Log,
39-
Message = "Hello World!!!!"
40-
});
39+
_logger.LogInformation("Hello world!");
4140
return Unit.Task;
4241
}
4342

@@ -57,10 +56,7 @@ public void SetCapability(SynchronizationCapability capability)
5756
public async Task<Unit> Handle(DidOpenTextDocumentParams notification, CancellationToken token)
5857
{
5958
await Task.Yield();
60-
_router.Window.LogMessage(new LogMessageParams() {
61-
Type = MessageType.Log,
62-
Message = "Hello World!!!!"
63-
});
59+
_logger.LogInformation("Hello world!");
6460
return Unit.Value;
6561
}
6662

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using OmniSharp.Extensions.LanguageServer.Client.Utilities;
5+
using OmniSharp.Extensions.LanguageServer.Protocol;
6+
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
7+
8+
namespace OmniSharp.Extensions.LanguageServer.Client.Clients
9+
{
10+
/// <summary>
11+
/// Client for the LSP Text Document API.
12+
/// </summary>
13+
public partial class TextDocumentClient
14+
{
15+
/// <summary>
16+
/// Request signature help at the specified document position.
17+
/// </summary>
18+
/// <param name="filePath">
19+
/// The full file-system path of the text document.
20+
/// </param>
21+
/// <param name="line">
22+
/// The target line (0-based).
23+
/// </param>
24+
/// <param name="column">
25+
/// The target column (0-based).
26+
/// </param>
27+
/// <param name="cancellationToken">
28+
/// An optional <see cref="CancellationToken"/> that can be used to cancel the request.
29+
/// </param>
30+
/// <returns>
31+
/// A <see cref="Task{TResult}"/> that resolves to the completions or <c>null</c> if no completions are available at the specified position.
32+
/// </returns>
33+
public Task<SignatureHelp> SignatureHelp(string filePath, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
34+
{
35+
if (string.IsNullOrWhiteSpace(filePath))
36+
throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(filePath)}.", nameof(filePath));
37+
38+
var documentUri = DocumentUri.FromFileSystemPath(filePath);
39+
40+
return SignatureHelp(documentUri, line, column, cancellationToken);
41+
}
42+
43+
/// <summary>
44+
/// Request signature help at the specified document position.
45+
/// </summary>
46+
/// <param name="documentUri">
47+
/// The document URI.
48+
/// </param>
49+
/// <param name="line">
50+
/// The target line (0-based).
51+
/// </param>
52+
/// <param name="column">
53+
/// The target column (0-based).
54+
/// </param>
55+
/// <param name="cancellationToken">
56+
/// An optional <see cref="CancellationToken"/> that can be used to cancel the request.
57+
/// </param>
58+
/// <returns>
59+
/// A <see cref="Task{TResult}"/> that resolves to the completions or <c>null</c> if no completions are available at the specified position.
60+
/// </returns>
61+
public Task<SignatureHelp> SignatureHelp(Uri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
62+
{
63+
return PositionalRequest<SignatureHelp>(DocumentNames.SignatureHelp, documentUri, line, column, cancellationToken);
64+
}
65+
}
66+
}

src/Client/Handlers/JsonRpcNotificationHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Threading;
33
using System.Threading.Tasks;
4-
using OmniSharp.Extensions.Embedded.MediatR;
4+
using MediatR;
55
using Newtonsoft.Json.Linq;
66
using OmniSharp.Extensions.JsonRpc;
77
using OmniSharp.Extensions.LanguageServer.Protocol;

src/Client/LanguageRegistration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using OmniSharp.Extensions.Embedded.MediatR;
2+
using MediatR;
33
using OmniSharp.Extensions.JsonRpc;
44
using OmniSharp.Extensions.LanguageServer.Client.Handlers;
55

src/Dap.Protocol/Dap.Protocol.csproj

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
5+
<PlatformTarget>AnyCPU</PlatformTarget>
6+
<AssemblyName>OmniSharp.Extensions.DebugAdapter</AssemblyName>
7+
<RootNamespace>OmniSharp.Extensions.DebugAdapter.Protocol</RootNamespace>
8+
<PackageDescription>Debug Adapter Protocol models, classes, interfaces and helper methods</PackageDescription>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\JsonRpc\JsonRpc.csproj" />
13+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
14+
<_Parameter1>OmniSharp.Extensions.LanguageServer, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f</_Parameter1>
15+
</AssemblyAttribute>
16+
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
17+
<_Parameter1>OmniSharp.Extensions.LanguageClient, PublicKey=0024000004800000940000000602000000240000525341310004000001000100391db875e68eb4bfef49ce14313b9e13f2cd3cc89eb273bbe6c11a55044c7d4f566cf092e1c77ef9e7c75b1496ae7f95d925938f5a01793dd8d9f99ae0a7595779b71b971287d7d7b5960d052078d14f5ce1a85ea5c9fb2f59ac735ff7bc215cab469b7c3486006860bad6f4c3b5204ea2f28dd4e1d05e2cca462cfd593b9f9f</_Parameter1>
18+
</AssemblyAttribute>
19+
</ItemGroup>
20+
21+
</Project>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using OmniSharp.Extensions.DebugAdapter.Protocol.Models;
2+
using MediatR;
3+
4+
namespace OmniSharp.Extensions.DebugAdapter.Protocol.Events
5+
{
6+
public class BreakpointEvent : IRequest
7+
{
8+
/// <summary>
9+
/// The reason for the event.
10+
/// Values: 'changed', 'new', 'removed', etc.
11+
/// </summary>
12+
public string Reason { get; set; }
13+
14+
/// <summary>
15+
/// The 'id' attribute is used to find the target breakpoint and the other attributes are used as the new values.
16+
/// </summary>
17+
public Breakpoint Breakpoint { get; set; }
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using OmniSharp.Extensions.DebugAdapter.Protocol.Requests;
5+
using MediatR;
6+
using OmniSharp.Extensions.JsonRpc;
7+
8+
namespace OmniSharp.Extensions.DebugAdapter.Protocol.Events
9+
{
10+
public static class BreakpointExtensions
11+
{
12+
public static void SendBreakpoint(this IDebugClient mediator, BreakpointEvent @event)
13+
{
14+
mediator.SendNotification(EventNames.Breakpoint, @event);
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)