Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit cc35a4e

Browse files
committed
Merge branch 'feature/v3_6_0'
2 parents 7575820 + 45dd6ba commit cc35a4e

26 files changed

+931
-7
lines changed

LanguageServer/Client/WorkspaceProxy.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,49 @@ public Task<Result<ApplyWorkspaceEditResponse, ResponseError>> ApplyEdit(ApplyWo
3838
(ResponseMessage<ApplyWorkspaceEditResponse, ResponseError> res) => tcs.TrySetResult(Message.ToResult(res)));
3939
return tcs.Task;
4040
}
41+
42+
/// <summary>
43+
/// The <c>workspace/workspaceFolders</c> request is sent from the server to the client
44+
/// to fetch the current open list of workspace folders.
45+
/// </summary>
46+
/// <returns>
47+
/// Returns <c>null</c> in the response if only a single file is open in the tool.
48+
/// Returns an empty array if a workspace is open but no folders are configured.
49+
/// </returns>
50+
/// <seealso>Spec 3.6.0</seealso>
51+
public Task<Result<WorkspaceFolder[], ResponseError>> WorkspaceFolders()
52+
{
53+
var tcs = new TaskCompletionSource<Result<WorkspaceFolder[], ResponseError>>();
54+
_connection.SendRequest(
55+
new VoidRequestMessage
56+
{
57+
id = IdGenerator.Instance.Next(),
58+
method = "workspace/workspaceFolders"
59+
},
60+
(ResponseMessage<WorkspaceFolder[], ResponseError> res) => tcs.TrySetResult(Message.ToResult(res)));
61+
return tcs.Task;
62+
}
63+
64+
/// <summary>
65+
/// The <c>workspace/configuration</c> request is sent from the server to the client
66+
/// to fetch configuration settings from the client.
67+
/// The request can fetch n configuration settings in one roundtrip.
68+
/// </summary>
69+
/// <param name="params">configuration sections asked for</param>
70+
/// <returns>configuration settings</returns>
71+
/// <seealso>Spec 3.6.0</seealso>
72+
public Task<Result<dynamic[], ResponseError>> Configuration(ConfigurationParams @params)
73+
{
74+
var tcs = new TaskCompletionSource<Result<dynamic[], ResponseError>>();
75+
_connection.SendRequest(
76+
new RequestMessage<ConfigurationParams>
77+
{
78+
id = IdGenerator.Instance.Next(),
79+
method = "workspace/configuration",
80+
@params = @params
81+
},
82+
(ResponseMessage<dynamic[], ResponseError> res) => tcs.TrySetResult(Message.ToResult(res)));
83+
return tcs.Task;
84+
}
4185
}
4286
}

LanguageServer/Infrastructure/JsonDotNet/EitherConverter.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public EitherConverter()
2525
table = new Dictionary<Type, Func<JToken, object>>();
2626
table[typeof(NumberOrString)] = token => (object)ToNumberOrString(token);
2727
table[typeof(LocationSingleOrArray)] = token => (object)ToLocationSingleOrArray(token);
28+
table[typeof(ChangeNotificationsOptions)] = token => (object)ToChangeNotificationsOptions(token);
29+
table[typeof(ProviderOptionsOrBoolean)] = token => (object)ToProviderOptionsOrBoolean(token);
2830
table[typeof(TextDocumentSync)] = token => (object)ToTextDocumentSync(token);
2931
table[typeof(Documentation)] = token => (object)ToDocumentation(token);
3032
table[typeof(CompletionResult)] = token => (object)ToCompletionResult(token);
@@ -89,6 +91,36 @@ private LocationSingleOrArray ToLocationSingleOrArray(JToken token)
8991
}
9092
}
9193

94+
private ChangeNotificationsOptions ToChangeNotificationsOptions(JToken token)
95+
{
96+
switch (token.Type)
97+
{
98+
case JTokenType.Null:
99+
return null;
100+
case JTokenType.Boolean:
101+
return new ChangeNotificationsOptions(token.ToObject<bool>());
102+
case JTokenType.String:
103+
return new ChangeNotificationsOptions(token.ToObject<string>());
104+
default:
105+
throw new JsonSerializationException();
106+
}
107+
}
108+
109+
private ProviderOptionsOrBoolean ToProviderOptionsOrBoolean(JToken token)
110+
{
111+
switch (token.Type)
112+
{
113+
case JTokenType.Null:
114+
return null;
115+
case JTokenType.Boolean:
116+
return new ProviderOptionsOrBoolean(token.ToObject<bool>());
117+
case JTokenType.Object:
118+
return new ProviderOptionsOrBoolean(token.ToObject<ProviderOptions>());
119+
default:
120+
throw new JsonSerializationException();
121+
}
122+
}
123+
92124
private TextDocumentSync ToTextDocumentSync(JToken token)
93125
{
94126
switch (token.Type)

LanguageServer/Json/Either.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ namespace LanguageServer.Json
1010
/// <list type="bullet">
1111
/// <item><description><see cref="NumberOrString"/></description></item>
1212
/// <item><description><see cref="LanguageServer.Parameters.LocationSingleOrArray"/></description></item>
13-
/// <item><description><see cref="LanguageServer.Parameters.General.ChangeNotifications"/></description></item>
13+
/// <item><description><see cref="LanguageServer.Parameters.General.ChangeNotificationsOptions"/></description></item>
1414
/// <item><description><see cref="LanguageServer.Parameters.General.ColorProviderCapabilities"/></description></item>
1515
/// <item><description><see cref="LanguageServer.Parameters.General.FoldingRangeProviderCapabilities"/></description></item>
16-
/// <item><description><see cref="LanguageServer.Parameters.General.ProviderCapabilities"/></description></item>
16+
/// <item><description><see cref="LanguageServer.Parameters.General.ProviderOptionsOrBoolean"/></description></item>
1717
/// <item><description><see cref="LanguageServer.Parameters.General.TextDocumentSync"/></description></item>
1818
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.CodeActionResult"/></description></item>
1919
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.Documentation"/></description></item>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using LanguageServer.Json;
2+
3+
namespace LanguageServer.Parameters.General
4+
{
5+
/// <summary>
6+
/// For <c>initialize</c>
7+
/// </summary>
8+
/// <seealso>Spec 3.6.0</seealso>
9+
public class ChangeNotificationsOptions : Either
10+
{
11+
/// <summary>
12+
/// Defines an implicit conversion of a <see cref="string"/> to a <see cref="ChangeNotificationsOptions"/>
13+
/// </summary>
14+
/// <param name="value"></param>
15+
/// <returns></returns>
16+
public static implicit operator ChangeNotificationsOptions(string value)
17+
=> new ChangeNotificationsOptions(value);
18+
19+
/// <summary>
20+
/// Defines an implicit conversion of a <see cref="bool"/> to a <see cref="ChangeNotificationsOptions"/>
21+
/// </summary>
22+
/// <param name="value"></param>
23+
/// <returns></returns>
24+
public static implicit operator ChangeNotificationsOptions(bool value)
25+
=> new ChangeNotificationsOptions(value);
26+
27+
/// <summary>
28+
/// Initializes a new instance of <c>ChangeNotificationsOptions</c> with the specified value.
29+
/// </summary>
30+
/// <param name="value"></param>
31+
public ChangeNotificationsOptions(string value)
32+
{
33+
Type = typeof(string);
34+
Value = value;
35+
}
36+
37+
/// <summary>
38+
/// Initializes a new instance of <c>ChangeNotificationsOptions</c> with the specified value.
39+
/// </summary>
40+
/// <param name="value"></param>
41+
public ChangeNotificationsOptions(bool value)
42+
{
43+
Type = typeof(bool);
44+
Value = value;
45+
}
46+
}
47+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace LanguageServer.Parameters.General
2+
{
3+
/// <summary>
4+
/// For <c>initialize</c>
5+
/// </summary>
6+
/// <remarks>
7+
/// The original spec describes the intersection type
8+
/// <c>(ColorProviderOptions &amp; TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>.
9+
/// This implementation merges their types into this class.
10+
/// </remarks>
11+
/// <seealso>Spec 3.6.0</seealso>
12+
public class ColorProviderOptions : ProviderOptions
13+
{
14+
}
15+
}

LanguageServer/Parameters/General/InitializeParams.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using LanguageServer.Parameters.Workspace;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

@@ -40,5 +41,16 @@ public class InitializeParams
4041
/// </value>
4142
/// <seealso cref="LanguageServer.Parameters.TraceKind"/>
4243
public string trace { get; set; }
44+
45+
/// <summary>
46+
/// The workspace folders configured in the client when the server starts.
47+
/// </summary>
48+
/// <remarks>
49+
/// This property is only available if the client supports workspace folders.
50+
/// It can be <c>null</c> if the client supports workspace folders but none are
51+
/// configured.
52+
/// </remarks>
53+
/// <seealso>Spec 3.6.0</seealso>
54+
public WorkspaceFolder[] workspaceFolders { get; set; }
4355
}
4456
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using LanguageServer.Parameters.Client;
2+
3+
namespace LanguageServer.Parameters.General
4+
{
5+
/// <summary>
6+
/// For <c>initialize</c>
7+
/// </summary>
8+
/// <remarks>
9+
/// The original spec describes the intersection type
10+
/// <c>(TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>.
11+
/// This implementation merges their types into this class.
12+
/// </remarks>
13+
/// <seealso>Spec 3.6.0</seealso>
14+
public class ProviderOptions
15+
{
16+
/// <summary>
17+
/// A document selector to identify the scope of the registration. If set to null
18+
/// the document selector provided on the client side will be used.
19+
/// </summary>
20+
/// <remarks>
21+
/// Merged from <see cref="TextDocumentRegistrationOptions"/>.
22+
/// </remarks>
23+
/// <seealso>Spec 3.6.0</seealso>
24+
public DocumentFilter[] documentSelector { get; set; }
25+
26+
/// <summary>
27+
/// The id used to register the request. The id can be used to deregister
28+
/// the request again.
29+
/// </summary>
30+
/// <remarks>
31+
/// Merged from <c>StaticRegistrationOptions</c>.
32+
/// </remarks>
33+
/// <seealso cref="Registration.id"/>
34+
/// <seealso>Spec 3.6.0</seealso>
35+
public string id { get; set; }
36+
}
37+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using LanguageServer.Json;
2+
3+
namespace LanguageServer.Parameters.General
4+
{
5+
/// <summary>
6+
/// For <c>initialize</c>
7+
/// </summary>
8+
/// <remarks>
9+
/// The original spec describes the union type of <c>boolean</c> or the intersection type
10+
/// <c>(TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>.
11+
/// This implementation defines <see cref="ProviderOptions"/> class instead of the intersection type.
12+
/// </remarks>
13+
/// <seealso>Spec 3.6.0</seealso>
14+
public class ProviderOptionsOrBoolean : Either
15+
{
16+
/// <summary>
17+
/// Defines an implicit conversion of a <see cref="ProviderOptions"/> to a <see cref="ProviderOptionsOrBoolean"/>
18+
/// </summary>
19+
/// <param name="value"></param>
20+
/// <seealso>Spec 3.6.0</seealso>
21+
public static implicit operator ProviderOptionsOrBoolean(ProviderOptions value)
22+
=> new ProviderOptionsOrBoolean(value);
23+
24+
/// <summary>
25+
/// Defines an implicit conversion of a <see cref="bool"/> to a <see cref="ProviderOptionsOrBoolean"/>
26+
/// </summary>
27+
/// <param name="value"></param>
28+
/// <seealso>Spec 3.6.0</seealso>
29+
public static implicit operator ProviderOptionsOrBoolean(bool value)
30+
=> new ProviderOptionsOrBoolean(value);
31+
32+
/// <summary>
33+
/// Initializes a new instance of <c>ProviderOptionsOrBoolean</c> with the specified value.
34+
/// </summary>
35+
/// <param name="value"></param>
36+
/// <seealso>Spec 3.6.0</seealso>
37+
public ProviderOptionsOrBoolean(ProviderOptions value)
38+
{
39+
Type = typeof(ProviderOptions);
40+
Value = value;
41+
}
42+
43+
/// <summary>
44+
/// Initializes a new instance of <c>ProviderOptionsOrBoolean</c> with the specified value.
45+
/// </summary>
46+
/// <param name="value"></param>
47+
/// <seealso>Spec 3.6.0</seealso>
48+
public ProviderOptionsOrBoolean(bool value)
49+
{
50+
Type = typeof(bool);
51+
Value = value;
52+
}
53+
54+
/// <summary>
55+
/// Returns true if its underlying value is a <see cref="ProviderOptions"/>.
56+
/// </summary>
57+
/// <seealso>Spec 3.6.0</seealso>
58+
public bool IsProviderOptions => Type == typeof(ProviderOptions);
59+
60+
/// <summary>
61+
/// Returns true if its underlying value is a <see cref="bool"/>.
62+
/// </summary>
63+
/// <seealso>Spec 3.6.0</seealso>
64+
public bool IsBoolean => Type == typeof(bool);
65+
66+
/// <summary>
67+
/// Gets the value of the current object if its underlying value is a <see cref="ProviderOptions"/>.
68+
/// </summary>
69+
/// <seealso>Spec 3.6.0</seealso>
70+
public ProviderOptions ProviderOptions => GetValue<ProviderOptions>();
71+
72+
/// <summary>
73+
/// Gets the value of the current object if its underlying value is a <see cref="bool"/>.
74+
/// </summary>
75+
/// <seealso>Spec 3.6.0</seealso>
76+
public bool Boolean => GetValue<bool>();
77+
}
78+
}

LanguageServer/Parameters/General/ServerCapabilities.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public class ServerCapabilities
4141
/// </summary>
4242
public bool? definitionProvider { get; set; }
4343

44+
/// <summary>
45+
/// The server provides Goto Type Definition support.
46+
/// </summary>
47+
/// <seealso>Spec 3.6.0</seealso>
48+
public ProviderOptionsOrBoolean typeDefinitionProvider { get; set; }
49+
50+
/// <summary>
51+
/// The server provides Goto Implementation support.
52+
/// </summary>
53+
/// <seealso>Spec 3.6.0</seealso>
54+
public ProviderOptionsOrBoolean implementationProvider { get; set; }
55+
4456
/// <summary>
4557
/// The server provides find references support.
4658
/// </summary>
@@ -105,11 +117,23 @@ public class ServerCapabilities
105117
/// </summary>
106118
public DocumentLinkOptions documentLinkProvider { get; set; }
107119

120+
/// <summary>
121+
/// The server provides color provider support.
122+
/// </summary>
123+
/// <seealso>Spec 3.6.0</seealso>
124+
public ColorProviderOptions colorProvider { get; set; }
125+
108126
/// <summary>
109127
/// The server provides execute command support.
110128
/// </summary>
111129
public ExecuteCommandOptions executeCommandProvider { get; set; }
112130

131+
/// <summary>
132+
/// Workspace specific server capabilities
133+
/// </summary>
134+
/// <seealso>Spec 3.6.0</seealso>
135+
public WorkspaceOptions workspace { get; set; }
136+
113137
/// <summary>
114138
/// Experimental server capabilities.
115139
/// </summary>

LanguageServer/Parameters/General/TextDocumentClientCapabilities.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ public class TextDocumentClientCapabilities
6565
/// </summary>
6666
public RegistrationCapabilities definition { get; set; }
6767

68+
/// <summary>
69+
/// Capabilities specific to the <c>textDocument/typeDefinition</c>
70+
/// </summary>
71+
/// <seealso cref="ProviderOptions"/>
72+
/// <seealso>Spec 3.6.0</seealso>
73+
public RegistrationCapabilities typeDefinition { get; set; }
74+
75+
/// <summary>
76+
/// Capabilities specific to the <c>textDocument/implementation</c>.
77+
/// </summary>
78+
/// <seealso cref="ProviderOptions"/>
79+
/// <seealso>Spec 3.6.0</seealso>
80+
public RegistrationCapabilities implementation { get; set; }
81+
6882
/// <summary>
6983
/// Capabilities specific to the <c>textDocument/codeAction</c>
7084
/// </summary>
@@ -80,6 +94,20 @@ public class TextDocumentClientCapabilities
8094
/// </summary>
8195
public RegistrationCapabilities documentLink { get; set; }
8296

97+
/// <summary>
98+
/// Capabilities specific to the <c>textDocument/documentColor</c> and the
99+
/// <c>textDocument/colorPresentation</c> request.
100+
/// </summary>
101+
/// <remarks>
102+
/// <c>dynamicRegistration</c> property shows whether colorProvider supports dynamic registration.
103+
/// If this is set to <c>true</c> the client supports the new
104+
/// <c>(ColorProviderOptions &amp; TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>
105+
/// return value for the corresponding server capability as well.
106+
/// </remarks>
107+
/// <seealso cref="ColorProviderOptions"/>
108+
/// <seealso>Spec 3.6.0</seealso>
109+
public RegistrationCapabilities colorProvider { get; set; }
110+
83111
/// <summary>
84112
/// Capabilities specific to the <c>textDocument/rename</c>
85113
/// </summary>

0 commit comments

Comments
 (0)