Skip to content

Commit 80dd054

Browse files
authored
Merge branch 'master' into fix/dap-473
2 parents 347480a + 25eb13f commit 80dd054

10 files changed

+71
-17
lines changed

Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313
<ItemGroup>
1414
<PackageReference Update="GitVersion.Tool" Version="5.5.1" />
15-
<PackageReference Update="JetBrains.ReSharper.CommandLineTools" Version="2020.2.4" />
15+
<PackageReference Update="JetBrains.ReSharper.CommandLineTools" Version="2020.3.0" />
1616
<PackageReference Update="ReportGenerator" Version="4.8.1" />
1717
<PackageReference Update="Rocket.Surgery.Nuke" Version="0.14.2" />
1818
</ItemGroup>

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"devDependencies": {
4-
"husky": "^4.3.5",
4+
"husky": "^4.3.6",
55
"lint-staged": "^10.5.3",
66
"prettier": "^2.2.1"
77
}

src/Client/LanguageClientServiceCollectionExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,18 @@ public static IServiceCollection AddLanguageClient(this IServiceCollection servi
113113
{
114114
services.RemoveAll<LanguageClient>();
115115
services.RemoveAll<ILanguageClient>();
116+
services.RemoveAll<ILanguageClientFacade>();
116117
services.AddSingleton<ILanguageClient>(
117118
_ =>
118-
throw new NotSupportedException("LanguageClient has been registered multiple times, you must use LanguageClient instead")
119+
throw new NotSupportedException("LanguageClient has been registered multiple times, you must use LanguageClientResolver instead")
120+
);
121+
services.AddSingleton<ILanguageClientFacade>(
122+
_ =>
123+
throw new NotSupportedException("LanguageClient has been registered multiple times, you must use LanguageClientResolver instead")
119124
);
120125
services.AddSingleton<LanguageClient>(
121126
_ =>
122-
throw new NotSupportedException("LanguageClient has been registered multiple times, you must use LanguageClient instead")
127+
throw new NotSupportedException("LanguageClient has been registered multiple times, you must use LanguageClientResolver instead")
123128
);
124129
}
125130

@@ -129,6 +134,7 @@ public static IServiceCollection AddLanguageClient(this IServiceCollection servi
129134
services.TryAddSingleton<LanguageClientResolver>();
130135
services.TryAddSingleton(_ => _.GetRequiredService<LanguageClientResolver>().Get(name));
131136
services.TryAddSingleton<ILanguageClient>(_ => _.GetRequiredService<LanguageClientResolver>().Get(name));
137+
services.TryAddSingleton<ILanguageClientFacade>(_ => _.GetRequiredService<LanguageClientResolver>().Get(name));
132138

133139
if (configureOptions != null)
134140
{

src/Dap.Client/DebugAdapterClientServiceCollectionExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,18 @@ public static IServiceCollection AddDebugAdapterClient(this IServiceCollection s
9797
{
9898
services.RemoveAll<DebugAdapterClient>();
9999
services.RemoveAll<IDebugAdapterClient>();
100+
services.RemoveAll<IDebugAdapterClientFacade>();
100101
services.AddSingleton<IDebugAdapterClient>(
101102
_ =>
102-
throw new NotSupportedException("DebugAdapterClient has been registered multiple times, you must use DebugAdapterClient instead")
103+
throw new NotSupportedException("DebugAdapterClient has been registered multiple times, you must use DebugAdapterClientResolver instead")
104+
);
105+
services.AddSingleton<IDebugAdapterClientFacade>(
106+
_ =>
107+
throw new NotSupportedException("DebugAdapterClient has been registered multiple times, you must use DebugAdapterClientResolver instead")
103108
);
104109
services.AddSingleton<DebugAdapterClient>(
105110
_ =>
106-
throw new NotSupportedException("DebugAdapterClient has been registered multiple times, you must use DebugAdapterClient instead")
111+
throw new NotSupportedException("DebugAdapterClient has been registered multiple times, you must use DebugAdapterClientResolver instead")
107112
);
108113
}
109114

@@ -113,6 +118,7 @@ public static IServiceCollection AddDebugAdapterClient(this IServiceCollection s
113118
services.TryAddSingleton<DebugAdapterClientResolver>();
114119
services.TryAddSingleton(_ => _.GetRequiredService<DebugAdapterClientResolver>().Get(name));
115120
services.TryAddSingleton<IDebugAdapterClient>(_ => _.GetRequiredService<DebugAdapterClientResolver>().Get(name));
121+
services.TryAddSingleton<IDebugAdapterClientFacade>(_ => _.GetRequiredService<DebugAdapterClientResolver>().Get(name));
116122

117123
if (configureOptions != null)
118124
{

src/Dap.Protocol/Client/IDebugAdapterClient.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
namespace OmniSharp.Extensions.DebugAdapter.Protocol.Client
66
{
7-
public interface IDebugAdapterClient : IDebugAdapterClientProxy, IDisposable
7+
public interface IDebugAdapterClient : IDebugAdapterClientFacade, IDisposable
88
{
99
Task Initialize(CancellationToken token);
10-
IDebugAdapterClientProgressManager ProgressManager { get; }
1110
}
1211
}

src/Dap.Server/DebugAdapterServerServiceCollectionExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ public static IServiceCollection AddDebugAdapterServer(this IServiceCollection s
8181
{
8282
services.RemoveAll<DebugAdapterServer>();
8383
services.RemoveAll<IDebugAdapterServer>();
84+
services.RemoveAll<IDebugAdapterServerFacade>();
8485
services.AddSingleton<IDebugAdapterServer>(
8586
_ =>
86-
throw new NotSupportedException("DebugAdapterServer has been registered multiple times, you must use DebugAdapterServer instead")
87+
throw new NotSupportedException("DebugAdapterServer has been registered multiple times, you must use DebugAdapterServerResolver instead")
88+
);
89+
services.AddSingleton<IDebugAdapterServerFacade>(
90+
_ =>
91+
throw new NotSupportedException("DebugAdapterServer has been registered multiple times, you must use DebugAdapterServerResolver instead")
8792
);
8893
services.AddSingleton<DebugAdapterServer>(
8994
_ =>
90-
throw new NotSupportedException("DebugAdapterServer has been registered multiple times, you must use DebugAdapterServer instead")
95+
throw new NotSupportedException("DebugAdapterServer has been registered multiple times, you must use DebugAdapterServerResolver instead")
9196
);
9297
}
9398

@@ -97,6 +102,7 @@ public static IServiceCollection AddDebugAdapterServer(this IServiceCollection s
97102
services.TryAddSingleton<DebugAdapterServerResolver>();
98103
services.TryAddSingleton(_ => _.GetRequiredService<DebugAdapterServerResolver>().Get(name));
99104
services.TryAddSingleton<IDebugAdapterServer>(_ => _.GetRequiredService<DebugAdapterServerResolver>().Get(name));
105+
services.TryAddSingleton<IDebugAdapterServerFacade>(_ => _.GetRequiredService<DebugAdapterServerResolver>().Get(name));
100106

101107
if (configureOptions != null)
102108
{

src/Server/LanguageServerServiceCollectionExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,18 @@ public static IServiceCollection AddLanguageServer(this IServiceCollection servi
125125
{
126126
services.RemoveAll<LanguageServer>();
127127
services.RemoveAll<ILanguageServer>();
128+
services.RemoveAll<ILanguageServerFacade>();
128129
services.AddSingleton<ILanguageServer>(
129130
_ =>
130-
throw new NotSupportedException("LanguageServer has been registered multiple times, you must use LanguageServer instead")
131+
throw new NotSupportedException("LanguageServer has been registered multiple times, you must use LanguageServerResolver instead")
132+
);
133+
services.AddSingleton<ILanguageServerFacade>(
134+
_ =>
135+
throw new NotSupportedException("LanguageServer has been registered multiple times, you must use LanguageServerResolver instead")
131136
);
132137
services.AddSingleton<LanguageServer>(
133138
_ =>
134-
throw new NotSupportedException("LanguageServer has been registered multiple times, you must use LanguageServer instead")
139+
throw new NotSupportedException("LanguageServer has been registered multiple times, you must use LanguageServerResolver instead")
135140
);
136141
}
137142

@@ -141,6 +146,7 @@ public static IServiceCollection AddLanguageServer(this IServiceCollection servi
141146
services.TryAddSingleton<LanguageServerResolver>();
142147
services.TryAddSingleton(_ => _.GetRequiredService<LanguageServerResolver>().Get(name));
143148
services.TryAddSingleton<ILanguageServer>(_ => _.GetRequiredService<LanguageServerResolver>().Get(name));
149+
services.TryAddSingleton<ILanguageServerFacade>(_ => _.GetRequiredService<LanguageServerResolver>().Get(name));
144150

145151
if (configureOptions != null)
146152
{

test/Lsp.Tests/Matchers/TextDocumentMatcherTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,37 @@ public void Should_Return_Empty_Descriptor()
5454
result.Should().BeEmpty();
5555
}
5656

57+
[Fact]
58+
public void Should_Return_Did_Open_Text_Document_Handler_Descriptor_With_No_Registration_Options()
59+
{
60+
// Given
61+
var textDocumentSyncHandler =
62+
TextDocumentSyncHandlerExtensions.With(null, "csharp");
63+
var textDocumentIdentifiers = new TextDocumentIdentifiers();
64+
AutoSubstitute.Provide(textDocumentIdentifiers);
65+
var collection = new SharedHandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers, Substitute.For<IResolverContext>(),
66+
new LspHandlerTypeDescriptorProvider(new [] { typeof(FoundationTests).Assembly, typeof(LanguageServer).Assembly, typeof(LanguageClient).Assembly, typeof(IRegistrationManager).Assembly, typeof(LspRequestRouter).Assembly }))
67+
{ textDocumentSyncHandler };
68+
AutoSubstitute.Provide<IHandlerCollection>(collection);
69+
AutoSubstitute.Provide<IEnumerable<ILspHandlerDescriptor>>(collection);
70+
var handlerMatcher = AutoSubstitute.Resolve<TextDocumentMatcher>();
71+
72+
// When
73+
var result = handlerMatcher.FindHandler(
74+
new DidOpenTextDocumentParams {
75+
TextDocument = new TextDocumentItem {
76+
Uri = new Uri("file:///abc/123/d.cs")
77+
}
78+
},
79+
collection.Where(x => x.Method == TextDocumentNames.DidOpen)
80+
);
81+
82+
// Then
83+
var lspHandlerDescriptors = result as ILspHandlerDescriptor[] ?? result.ToArray();
84+
lspHandlerDescriptors.Should().NotBeNullOrEmpty();
85+
lspHandlerDescriptors.Should().Contain(x => x.Method == TextDocumentNames.DidOpen);
86+
}
87+
5788
[Fact]
5889
public void Should_Return_Did_Open_Text_Document_Handler_Descriptor()
5990
{

test/Lsp.Tests/TextDocumentSyncHandlerExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ namespace Lsp.Tests
88
{
99
internal static class TextDocumentSyncHandlerExtensions
1010
{
11-
public static ITextDocumentSyncHandler With(DocumentSelector documentSelector, string language) =>
11+
public static ITextDocumentSyncHandler With(DocumentSelector? documentSelector, string language) =>
1212
Substitute.For<ITextDocumentSyncHandler>().With(documentSelector, language);
1313

14-
public static ITextDocumentSyncHandler With(this ITextDocumentSyncHandler handler, DocumentSelector documentSelector, string language)
14+
public static ITextDocumentSyncHandler With(this ITextDocumentSyncHandler handler, DocumentSelector? documentSelector, string language)
1515
{
1616
( (IDidChangeTextDocumentHandler) handler ).GetRegistrationOptions(Arg.Any<SynchronizationCapability>(), Arg.Any<ClientCapabilities>()).Returns(new TextDocumentChangeRegistrationOptions() { DocumentSelector = documentSelector });
1717
( (IDidOpenTextDocumentHandler) handler ).GetRegistrationOptions(Arg.Any<SynchronizationCapability>(), Arg.Any<ClientCapabilities>()).Returns(new TextDocumentOpenRegistrationOptions() { DocumentSelector = documentSelector });

0 commit comments

Comments
 (0)