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

Commit 52d7deb

Browse files
committed
Merge branch 'feature/v3_10_0'
2 parents abd7519 + 9db4977 commit 52d7deb

15 files changed

+494
-10
lines changed

LanguageServer/Infrastructure/JsonDotNet/EitherConverter.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ public EitherConverter()
2727
table[typeof(LocationSingleOrArray)] = token => (object)ToLocationSingleOrArray(token);
2828
table[typeof(ChangeNotificationsOptions)] = token => (object)ToChangeNotificationsOptions(token);
2929
table[typeof(ColorProviderOptionsOrBoolean)] = token => (object)ToColorProviderOptionsOrBoolean(token);
30+
table[typeof(FoldingRangeProviderOptionsOrBoolean)] = token => (object)ToFoldingRangeProviderOptionsOrBoolean(token);
3031
table[typeof(ProviderOptionsOrBoolean)] = token => (object)ToProviderOptionsOrBoolean(token);
3132
table[typeof(TextDocumentSync)] = token => (object)ToTextDocumentSync(token);
3233
table[typeof(CodeActionResult)] = token => (object)ToCodeActionResult(token);
3334
table[typeof(Documentation)] = token => (object)ToDocumentation(token);
3435
table[typeof(CompletionResult)] = token => (object)ToCompletionResult(token);
36+
table[typeof(DocumentSymbolResult)] = token => (object)ToDocumentSymbolResult(token);
3537
table[typeof(HoverContents)] = token => (object)ToHoverContents(token);
3638
}
3739

@@ -123,6 +125,21 @@ private ColorProviderOptionsOrBoolean ToColorProviderOptionsOrBoolean(JToken tok
123125
}
124126
}
125127

128+
private FoldingRangeProviderOptionsOrBoolean ToFoldingRangeProviderOptionsOrBoolean(JToken token)
129+
{
130+
switch (token.Type)
131+
{
132+
case JTokenType.Null:
133+
return null;
134+
case JTokenType.Boolean:
135+
return new FoldingRangeProviderOptionsOrBoolean(token.ToObject<bool>());
136+
case JTokenType.Object:
137+
return new FoldingRangeProviderOptionsOrBoolean(token.ToObject<FoldingRangeProviderOptions>());
138+
default:
139+
throw new JsonSerializationException();
140+
}
141+
}
142+
126143
private ProviderOptionsOrBoolean ToProviderOptionsOrBoolean(JToken token)
127144
{
128145
switch (token.Type)
@@ -220,6 +237,37 @@ private CompletionResult ToCompletionResult(JToken token)
220237
}
221238
}
222239

240+
private DocumentSymbolResult ToDocumentSymbolResult(JToken token)
241+
{
242+
switch (token.Type)
243+
{
244+
case JTokenType.Null:
245+
return null;
246+
case JTokenType.Array:
247+
var array = (JArray) token;
248+
if (array.Count == 0)
249+
{
250+
return new DocumentSymbolResult(new DocumentSymbol[0]);
251+
}
252+
253+
var element = (array[0] as JObject) ?? throw new JsonSerializationException();
254+
if (element.Property("range") != null)
255+
{
256+
return new DocumentSymbolResult(array.ToObject<DocumentSymbol[]>());
257+
}
258+
else if (element.Property("location") != null)
259+
{
260+
return new DocumentSymbolResult(array.ToObject<SymbolInformation[]>());
261+
}
262+
else
263+
{
264+
throw new JsonSerializationException();
265+
}
266+
default:
267+
throw new JsonSerializationException();
268+
}
269+
}
270+
223271
private HoverContents ToHoverContents(JToken token)
224272
{
225273
switch (token.Type)

LanguageServer/Json/Either.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace LanguageServer.Json
1212
/// <item><description><see cref="LanguageServer.Parameters.LocationSingleOrArray"/></description></item>
1313
/// <item><description><see cref="LanguageServer.Parameters.General.ChangeNotificationsOptions"/></description></item>
1414
/// <item><description><see cref="LanguageServer.Parameters.General.ColorProviderOptionsOrBoolean"/></description></item>
15-
/// <item><description><see cref="LanguageServer.Parameters.General.FoldingRangeProviderCapabilities"/></description></item>
15+
/// <item><description><see cref="LanguageServer.Parameters.General.FoldingRangeProviderOptionsOrBoolean"/></description></item>
1616
/// <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>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace LanguageServer.Parameters
2+
{
3+
/// <summary>
4+
/// Enum of known range kinds
5+
/// </summary>
6+
/// <seealso>Spec 3.10.0</seealso>
7+
public static class FoldingRangeKind
8+
{
9+
/// <summary>
10+
/// Folding range for a comment
11+
/// </summary>
12+
/// <seealso>Spec 3.10.0</seealso>
13+
public const string Comment = "comment";
14+
15+
/// <summary>
16+
/// Folding range for a imports or includes
17+
/// </summary>
18+
/// <seealso>Spec 3.10.0</seealso>
19+
public const string Imports = "imports";
20+
21+
/// <summary>
22+
/// Folding range for a region (e.g. <c>#region</c>)
23+
/// </summary>
24+
/// <seealso>Spec 3.10.0</seealso>
25+
public const string Region = "region";
26+
}
27+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace LanguageServer.Parameters.General
2+
{
3+
/// <summary>
4+
/// For <c>initialize</c>
5+
/// </summary>
6+
/// <remarks>
7+
/// <c>dynamicRegistration</c> property shows whether implementation supports dynamic registration.
8+
/// If this is set to <c>true</c> the client supports the new
9+
/// <c>(FoldingRangeProviderOptions &amp; TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>
10+
/// return value for the corresponding server capability as well.
11+
/// </remarks>
12+
/// <seealso>Spec 3.10.0</seealso>
13+
public class FoldingRangeCapabilities : RegistrationCapabilities
14+
{
15+
/// <summary>
16+
/// The maximum number of folding ranges that the client prefers to receive per document.
17+
/// </summary>
18+
/// <remarks>
19+
/// The value serves as a hint, servers are free to follow the limit.
20+
/// </remarks>
21+
/// <seealso>Spec 3.10.0</seealso>
22+
public long? rangeLimit { get; set; }
23+
24+
/// <summary>
25+
/// If set, the client signals that it only supports folding complete lines.
26+
/// </summary>
27+
/// <remarks>
28+
/// If set, client will ignore specified <c>startCharacter</c>
29+
/// and <c>endCharacter</c> properties in a FoldingRange.
30+
/// </remarks>
31+
/// <seealso>Spec 3.10.0</seealso>
32+
public bool? lineFoldingOnly { get; set; }
33+
}
34+
}
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>(FoldingRangeProviderOptions &amp; TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>.
9+
/// This implementation merges their types into this class.
10+
/// </remarks>
11+
/// <seealso>Spec 3.10.0</seealso>
12+
public class FoldingRangeProviderOptions : ProviderOptions
13+
{
14+
}
15+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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
10+
/// <c>boolean</c>, <c>FoldingRangeProviderOptions</c>, or the intersection type
11+
/// <c>(FoldingRangeProviderOptions &amp; TextDocumentRegistrationOptions &amp; StaticRegistrationOptions)</c>.
12+
/// This implementation defines <see cref="FoldingRangeProviderOptions"/> class instead of the intersection type.
13+
/// </remarks>
14+
/// <seealso>Spec 3.10.0</seealso>
15+
public class FoldingRangeProviderOptionsOrBoolean : Either
16+
{
17+
/// <summary>
18+
/// Defines an implicit conversion of a <see cref="FoldingRangeProviderOptions"/> to a <see cref="FoldingRangeProviderOptionsOrBoolean"/>
19+
/// </summary>
20+
/// <param name="value"></param>
21+
/// <returns></returns>
22+
public static implicit operator FoldingRangeProviderOptionsOrBoolean(FoldingRangeProviderOptions value)
23+
=> new FoldingRangeProviderOptionsOrBoolean(value);
24+
25+
/// <summary>
26+
/// Defines an implicit conversion of a <see cref="bool"/> to a <see cref="FoldingRangeProviderOptionsOrBoolean"/>
27+
/// </summary>
28+
/// <param name="value"></param>
29+
/// <returns></returns>
30+
public static implicit operator FoldingRangeProviderOptionsOrBoolean(bool value)
31+
=> new FoldingRangeProviderOptionsOrBoolean(value);
32+
33+
/// <summary>
34+
/// Initializes a new instance of <c>FoldingRangeProviderOptionsOrBoolean</c> with the specified value.
35+
/// </summary>
36+
/// <param name="value"></param>
37+
public FoldingRangeProviderOptionsOrBoolean(FoldingRangeProviderOptions value)
38+
{
39+
Type = typeof(FoldingRangeProviderOptions);
40+
Value = value;
41+
}
42+
43+
/// <summary>
44+
/// Initializes a new instance of <c>FoldingRangeProviderOptionsOrBoolean</c> with the specified value.
45+
/// </summary>
46+
/// <param name="value"></param>
47+
public FoldingRangeProviderOptionsOrBoolean(bool value)
48+
{
49+
Type = typeof(bool);
50+
Value = value;
51+
}
52+
53+
/// <summary>
54+
/// Returns true if its underlying value is a <see cref="FoldingRangeProviderOptions"/>.
55+
/// </summary>
56+
public bool IsFoldingRangeProviderOptions => Type == typeof(FoldingRangeProviderOptions);
57+
58+
/// <summary>
59+
/// Returns true if its underlying value is a <see cref="bool"/>.
60+
/// </summary>
61+
public bool IsBoolean => Type == typeof(bool);
62+
63+
/// <summary>
64+
/// Gets the value of the current object if its underlying value is a <see cref="FoldingRangeProviderOptions"/>.
65+
/// </summary>
66+
public FoldingRangeProviderOptions FoldingRangeProviderOptions => GetValue<FoldingRangeProviderOptions>();
67+
68+
/// <summary>
69+
/// Gets the value of the current object if its underlying value is a <see cref="bool"/>.
70+
/// </summary>
71+
public bool Boolean => GetValue<bool>();
72+
}
73+
}

LanguageServer/Parameters/General/ServerCapabilities.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace LanguageServer.Parameters.General
55
/// <summary>
66
/// For <c>initialize</c>
77
/// </summary>
8-
/// <seealso>Spec 3.8.0</seealso>
8+
/// <seealso>Spec 3.10.0</seealso>
99
public class ServerCapabilities
1010
{
1111
/// <summary>
@@ -124,6 +124,12 @@ public class ServerCapabilities
124124
/// <seealso>Spec 3.8.0</seealso>
125125
public ColorProviderOptionsOrBoolean colorProvider { get; set; }
126126

127+
/// <summary>
128+
/// The server provides folding provider support.
129+
/// </summary>
130+
/// <seealso>Spec 3.10.0</seealso>
131+
public FoldingRangeProviderOptionsOrBoolean foldingRangeProvider { get; set; }
132+
127133
/// <summary>
128134
/// The server provides execute command support.
129135
/// </summary>

LanguageServer/Parameters/General/SymbolCapabilities.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
/// <remarks>
77
/// Capabilities specific to the <c>workspace/symbol</c> request.
88
/// </remarks>
9-
/// <seealso>Spec 3.4.0</seealso>
9+
/// <seealso>Spec 3.10.0</seealso>
1010
public class SymbolCapabilities : RegistrationCapabilities
1111
{
1212
/// <summary>
1313
/// Specific capabilities for the <c>SymbolKind</c> in the <c>workspace/symbol</c> request.
1414
/// </summary>
1515
/// <seealso>Spec 3.4.0</seealso>
1616
public SymbolKindCapabilities symbolKind { get; set; }
17+
18+
/// <summary>
19+
/// The client support hierarchical document symbols.
20+
/// </summary>
21+
/// <seealso>Spec 3.10.0</seealso>
22+
public bool? hierarchicalDocumentSymbolSupport { get; set; }
1723
}
1824
}

LanguageServer/Parameters/General/TextDocumentClientCapabilities.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// For <c>initialize</c>
55
/// </summary>
6-
/// <seealso>Spec 3.8.0</seealso>
6+
/// <seealso>Spec 3.10.0</seealso>
77
public class TextDocumentClientCapabilities
88
{
99
/// <summary>
@@ -119,5 +119,11 @@ public class TextDocumentClientCapabilities
119119
/// </summary>
120120
/// <seealso>Spec 3.7.0</seealso>
121121
public PublishDiagnosticsCapabilities publishDiagnostics { get; set; }
122+
123+
/// <summary>
124+
/// Capabilities specific to <c>textDocument/foldingRange</c> requests.
125+
/// </summary>
126+
/// <seealso>Spec 3.10.0</seealso>
127+
public FoldingRangeCapabilities foldingRange { get; set; }
122128
}
123129
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
namespace LanguageServer.Parameters.TextDocument
2+
{
3+
/// <summary>
4+
/// For <c>textDocument/documentSymbol</c>
5+
/// </summary>
6+
/// <remarks>
7+
/// Represents programming constructs like variables, classes, interfaces etc. that appear in a document.
8+
/// Document symbols can be hierarchical and they have two ranges:
9+
/// one that encloses its definition and one that points to its most interesting range,
10+
/// e.g. the range of an identifier.
11+
/// </remarks>
12+
/// <seealso>Spec 3.10.0</seealso>
13+
public class DocumentSymbol
14+
{
15+
/// <summery>
16+
/// The name of this symbol.
17+
/// </summery>
18+
/// <seealso>Spec 3.10.0</seealso>
19+
public string name { get; set; }
20+
21+
/// <summery>
22+
/// More detail for this symbol, e.g the signature of a function. If not provided the name is used.
23+
/// </summery>
24+
/// <seealso>Spec 3.10.0</seealso>
25+
public string detail { get; set; }
26+
27+
/// <summery>
28+
/// The kind of this symbol.
29+
/// </summery>
30+
/// <seealso>Spec 3.10.0</seealso>
31+
public SymbolKind kind { get; set; }
32+
33+
/// <summery>
34+
/// Indicates if this symbol is deprecated.
35+
/// </summery>
36+
/// <seealso>Spec 3.10.0</seealso>
37+
public bool? deprecated { get; set; }
38+
39+
/// <summery>
40+
/// The range enclosing this symbol not including leading/trailing whitespace but everything else
41+
/// like comments. This information is typically used to determine if the the clients cursor is
42+
/// inside the symbol to reveal in the symbol in the UI.
43+
/// </summery>
44+
/// <seealso>Spec 3.10.0</seealso>
45+
public Range range { get; set; }
46+
47+
/// <summery>
48+
/// The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
49+
/// Must be contained by the the <c>range</c>.
50+
/// </summery>
51+
/// <seealso>Spec 3.10.0</seealso>
52+
public Range selectionRange { get; set; }
53+
54+
/// <summery>
55+
/// Children of this symbol, e.g. properties of a class.
56+
/// </summery>
57+
/// <seealso>Spec 3.10.0</seealso>
58+
public DocumentSymbol[] children { get; set; }
59+
}
60+
}

0 commit comments

Comments
 (0)