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

Commit 4af229c

Browse files
committed
Merge branch 'feature/v3_3_0'
2 parents 62dccf6 + 80cceeb commit 4af229c

23 files changed

+660
-49
lines changed

LanguageServer/Infrastructure/JsonDotNet/EitherConverter.cs

+56-3
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,45 @@
1010

1111
namespace LanguageServer.Infrastructure.JsonDotNet
1212
{
13+
/// <summary>
14+
/// Converts an Either-derived types to and from JSON.
15+
/// </summary>
1316
public class EitherConverter : JsonConverter
1417
{
1518
private readonly Dictionary<Type, Func<JToken, object>> table;
1619

20+
/// <summary>
21+
/// Initializes a new instance of the EitherConverter class.
22+
/// </summary>
1723
public EitherConverter()
1824
{
1925
table = new Dictionary<Type, Func<JToken, object>>();
2026
table[typeof(NumberOrString)] = token => (object)ToNumberOrString(token);
2127
table[typeof(LocationSingleOrArray)] = token => (object)ToLocationSingleOrArray(token);
2228
table[typeof(TextDocumentSync)] = token => (object)ToTextDocumentSync(token);
29+
table[typeof(Documentation)] = token => (object)ToDocumentation(token);
2330
table[typeof(CompletionResult)] = token => (object)ToCompletionResult(token);
2431
table[typeof(HoverContents)] = token => (object)ToHoverContents(token);
2532
}
2633

34+
/// <summary>
35+
/// Determines whether this instance can convert the specified object type.
36+
/// </summary>
37+
/// <param name="objectType"></param>
38+
/// <returns></returns>
2739
public override bool CanConvert(Type objectType)
2840
{
2941
return typeof(Either).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo());
3042
}
3143

44+
/// <summary>
45+
/// Reads the JSON representation of the object.
46+
/// </summary>
47+
/// <param name="reader"></param>
48+
/// <param name="objectType"></param>
49+
/// <param name="existingValue"></param>
50+
/// <param name="serializer"></param>
51+
/// <returns></returns>
3252
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
3353
{
3454
var convert = table[objectType] ??
@@ -84,6 +104,21 @@ private TextDocumentSync ToTextDocumentSync(JToken token)
84104
}
85105
}
86106

107+
private Documentation ToDocumentation(JToken token)
108+
{
109+
switch (token.Type)
110+
{
111+
case JTokenType.Null:
112+
return null;
113+
case JTokenType.String:
114+
return new Documentation(token.ToObject<string>());
115+
case JTokenType.Object:
116+
return new Documentation(token.ToObject<MarkupContent>());
117+
default:
118+
throw new JsonSerializationException();
119+
}
120+
}
121+
87122
private CompletionResult ToCompletionResult(JToken token)
88123
{
89124
switch (token.Type)
@@ -108,9 +143,21 @@ private HoverContents ToHoverContents(JToken token)
108143
case JTokenType.String:
109144
return new HoverContents(token.ToObject<string>());
110145
case JTokenType.Object:
111-
return new HoverContents(token.ToObject<MarkedString>());
146+
var obj = (JObject)token;
147+
if (obj.Property("kind") != null)
148+
{
149+
return new HoverContents(obj.ToObject<MarkupContent>());
150+
}
151+
else if (obj.Property("language") != null)
152+
{
153+
return new HoverContents(obj.ToObject<MarkedString>());
154+
}
155+
else
156+
{
157+
throw new JsonSerializationException();
158+
}
112159
case JTokenType.Array:
113-
var array = (JArray) token;
160+
var array = (JArray)token;
114161
if (array.Count == 0)
115162
{
116163
return new HoverContents(new string[0]);
@@ -134,9 +181,15 @@ private HoverContents ToHoverContents(JToken token)
134181
throw new JsonSerializationException();
135182
}
136183
}
137-
184+
138185
#endregion
139186

187+
/// <summary>
188+
/// Writes the JSON representation of the object.
189+
/// </summary>
190+
/// <param name="writer"></param>
191+
/// <param name="value"></param>
192+
/// <param name="serializer"></param>
140193
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
141194
{
142195
var either = (Either)value;

LanguageServer/Json/Either.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace LanguageServer.Json
1616
/// <item><description><see cref="LanguageServer.Parameters.General.ProviderCapabilities"/></description></item>
1717
/// <item><description><see cref="LanguageServer.Parameters.General.TextDocumentSync"/></description></item>
1818
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.CodeActionResult"/></description></item>
19-
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.CompletionItemDocumentation"/></description></item>
19+
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.Documentation"/></description></item>
2020
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.CompletionResult"/></description></item>
2121
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.DocumentSymbolResult"/></description></item>
2222
/// <item><description><see cref="LanguageServer.Parameters.TextDocument.HoverContents"/></description></item>

LanguageServer/Parameters/General/CompletionCapabilities.cs

+8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
/// <summary>
44
/// For <c>initialize</c>
55
/// </summary>
6+
/// <seealso>Spec 3.3.0</seealso>
67
public class CompletionCapabilities : RegistrationCapabilities
78
{
89
/// <summary>
910
/// The client supports the following <c>CompletionItem</c> specific capabilities.
1011
/// </summary>
1112
public CompletionItemCapabilities completionItem { get; set; }
13+
14+
/// <summary>
15+
/// The client supports to send additional context information for a
16+
/// <c>textDocument/completion</c> request.
17+
/// </summary>
18+
/// <seealso>Spec 3.3.0</seealso>
19+
public bool? contextSupport { get; set; }
1220
}
1321
}

LanguageServer/Parameters/General/CompletionItemCapabilities.cs

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/// <summary>
44
/// For <c>initialize</c>
55
/// </summary>
6+
/// <seealso>Spec 3.3.0</seealso>
67
public class CompletionItemCapabilities
78
{
89
/// <summary>
@@ -21,5 +22,17 @@ public class CompletionItemCapabilities
2122
/// </summary>
2223
/// <seealso>Spec 3.2.0</seealso>
2324
public bool? commitCharactersSupport { get; set; }
25+
26+
/// <summary>
27+
/// Client supports the follow content formats for the documentation
28+
/// property.The order describes the preferred format of the client.
29+
/// </summary>
30+
/// <value>
31+
/// See <see cref="LanguageServer.Parameters.MarkupKind"/> for an enumeration of standardized kinds.
32+
/// </value>
33+
/// <seealso>Spec 3.3.0</seealso>
34+
/// <seealso cref="LanguageServer.Parameters.MarkupKind"/>
35+
public string[] documentationFormat { get; set; }
36+
2437
}
2538
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace LanguageServer.Parameters.General
2+
{
3+
/// <summary>
4+
/// For <c>initialize</c>.
5+
/// </summary>
6+
/// <seealso>Spec 3.3.0</seealso>
7+
public class HoverCapabilities : RegistrationCapabilities
8+
{
9+
/// <summary>
10+
/// Client supports the follow content formats for the content property.
11+
/// </summary>
12+
/// <remarks>
13+
/// The order describes the preferred format of the client.
14+
/// </remarks>
15+
/// <value>
16+
/// See <see cref="LanguageServer.Parameters.MarkupKind"/> for an enumeration of standardized kinds.
17+
/// </value>
18+
/// <seealso>Spec 3.3.0</seealso>
19+
/// <seealso cref="LanguageServer.Parameters.MarkupKind"/>
20+
public string[] contentFormat { get; set; }
21+
}
22+
}
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+
/// <seealso>Spec 3.3.0</seealso>
7+
public class SignatureHelpCapabilities : RegistrationCapabilities
8+
{
9+
/// <summary>
10+
/// The client supports the following <c>SignatureInformation</c> specific properties.
11+
/// </summary>
12+
/// <seealso>Spec 3.3.0</seealso>
13+
public SignatureInformationCapabilities signatureInformation { get; set; }
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace LanguageServer.Parameters.General
2+
{
3+
/// <summary>
4+
/// For <c>initialize</c>.
5+
/// </summary>
6+
/// <seealso>Spec 3.3.0</seealso>
7+
public class SignatureInformationCapabilities
8+
{
9+
/// <summary>
10+
/// Client supports the follow content formats for the documentation property.
11+
/// </summary>
12+
/// <remarks>
13+
/// The order describes the preferred format of the client.
14+
/// </remarks>
15+
/// <value>
16+
/// See <see cref="LanguageServer.Parameters.MarkupKind"/> for an enumeration of standardized kinds.
17+
/// </value>
18+
/// <seealso>Spec 3.3.0</seealso>
19+
/// <seealso cref="LanguageServer.Parameters.MarkupKind"/>
20+
public string[] documentationFormat { get; set; }
21+
}
22+
}

LanguageServer/Parameters/General/TextDocumentClientCapabilities.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/// <summary>
44
/// For <c>initialize</c>
55
/// </summary>
6+
/// <seealso>Spec 3.3.0</seealso>
67
public class TextDocumentClientCapabilities
78
{
89
/// <summary>
@@ -19,12 +20,14 @@ public class TextDocumentClientCapabilities
1920
/// <summary>
2021
/// Capabilities specific to the <c>textDocument/hover</c>
2122
/// </summary>
22-
public RegistrationCapabilities hover { get; set; }
23+
/// <seealso>Spec 3.3.0</seealso>
24+
public HoverCapabilities hover { get; set; }
2325

2426
/// <summary>
2527
/// Capabilities specific to the <c>textDocument/signatureHelp</c>
2628
/// </summary>
27-
public RegistrationCapabilities signatureHelp { get; set; }
29+
/// <seealso>Spec 3.3.0</seealso>
30+
public SignatureHelpCapabilities signatureHelp { get; set; }
2831

2932
/// <summary>
3033
/// Capabilities specific to the <c>textDocument/references</c>
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace LanguageServer.Parameters
2+
{
3+
/// <summary>
4+
/// Describes the content type that a client supports in various result literals
5+
/// like <c>Hover</c>, <c>ParameterInfo</c> or <c>CompletionItem</c>.
6+
/// </summary>
7+
/// <remarks>
8+
/// Please note that <c>MarkupKind</c>s must not start with a <c>$</c>.
9+
/// This kinds are reserved for internal usage.
10+
/// </remarks>
11+
/// <seealso cref="LanguageServer.Parameters.General.CompletionItemCapabilities.documentationFormat"/>
12+
/// <seealso cref="LanguageServer.Parameters.General.HoverCapabilities.contentFormat"/>
13+
/// <seealso cref="LanguageServer.Parameters.General.SignatureInformationCapabilities.documentationFormat"/>
14+
/// <seealso cref="LanguageServer.Parameters.TextDocument.MarkupContent.kind"/>
15+
/// <seealso>Spec 3.3.0</seealso>
16+
public static class MarkupKind
17+
{
18+
/// <summary>
19+
/// Plain text is supported as a content format
20+
/// </summary>
21+
/// <seealso>Spec 3.3.0</seealso>
22+
public const string PlainText = "plaintext";
23+
24+
/// <summary>
25+
/// Markdown is supported as a content format
26+
/// </summary>
27+
/// <seealso>Spec 3.3.0</seealso>
28+
public const string Markdown = "markdown";
29+
}
30+
}

LanguageServer/Parameters/TextDocument/CompletionContext.cs

+2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public class CompletionContext
1313
/// <summary>
1414
/// How the completion was triggered.
1515
/// </summary>
16+
/// <seealso>Spec 3.3.0</seealso>
1617
public CompletionTriggerKind triggerKind { get; set; }
1718

1819
/// <summary>
1920
/// The trigger character (a single character) that has trigger code complete.
2021
/// Is undefined if <c>triggerKind !== CompletionTriggerKind.TriggerCharacter</c>
2122
/// </summary>
23+
/// <seealso>Spec 3.3.0</seealso>
2224
public string triggerCharacter { get; set; }
2325
}
2426
}

LanguageServer/Parameters/TextDocument/CompletionItem.cs

+38-14
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,61 @@ namespace LanguageServer.Parameters.TextDocument
77
/// <summary>
88
/// For <c>textDocument/completion</c> and <c>completionItem/resolve</c>
99
/// </summary>
10-
/// <seealso>Spec 3.2.0</seealso>
10+
/// <seealso>Spec 3.3.0</seealso>
1111
public class CompletionItem
1212
{
13+
/// <summary>
14+
/// The label of this completion item.
15+
/// </summary>
1316
public string label { get; set; }
1417

18+
/// <summary>
19+
/// The kind of this completion item.
20+
/// </summary>
1521
public CompletionItemKind? kind { get; set; }
1622

23+
/// <summary>
24+
/// A human-readable string with additional information
25+
/// about this item, like type or symbol information.
26+
/// </summary>
1727
public string detail { get; set; }
1828

19-
public string documentation { get; set; }
20-
2129
/// <summary>
22-
/// Indicates if this item is deprecated.
30+
/// A human-readable string that represents a doc-comment.
2331
/// </summary>
24-
/// <seealso>Spec 3.7.2</seealso>
25-
public bool? deprecated { get; set; }
32+
/// <seealso>Spec 3.3.0</seealso>
33+
public Documentation documentation { get; set; }
2634

2735
/// <summary>
28-
/// Select this item when showing.
36+
/// A string that should be used when comparing this item with other items.
2937
/// </summary>
30-
/// <remarks>
31-
/// Note that only one completion item can be selected and that the tool / client decides which item that is.
32-
/// The rule is that the <b>first</b> item of those that match best is selected.
33-
/// </remarks>
34-
/// <seealso>Spec 3.9.0</seealso>
35-
public bool? preselect { get; set; }
36-
3738
public string sortText { get; set; }
3839

40+
/// <summary>
41+
/// A string that should be used when filtering a set of completion items.
42+
/// </summary>
3943
public string filterText { get; set; }
4044

45+
/// <summary>
46+
/// A string that should be inserted into a document when selecting this completion.
47+
/// </summary>
48+
/// <seealso>Spec 3.3.0</seealso>
49+
[Obsolete("insertText is deprecated since the spec v3.3.0, please use textEdit instead.")]
4150
public string insertText { get; set; }
4251

52+
/// <summary>
53+
/// The format of the insert text.
54+
/// </summary>
4355
public InsertTextFormat? insertTextFormat { get; set; }
4456

57+
/// <summary>
58+
/// An edit which is applied to a document when selecting this completion.
59+
/// </summary>
4560
public TextEdit textEdit { get; set; }
4661

62+
/// <summary>
63+
/// An optional array of additional text edits that are applied when selecting this completion.
64+
/// </summary>
4765
public TextEdit[] additionalTextEdits { get; set; }
4866

4967
/// <summary>
@@ -56,8 +74,14 @@ public class CompletionItem
5674
/// <seealso>Spec 3.2.0</seealso>
5775
public string[] commitCharacters { get; set; }
5876

77+
/// <summary>
78+
/// An optional command that is executed <b>after</b> inserting this completion.
79+
/// </summary>
5980
public Command command { get; set; }
6081

82+
/// <summary>
83+
/// An data entry field that is preserved on a completion item between a completion and a completion resolve request.
84+
/// </summary>
6185
public dynamic data { get; set; }
6286
}
6387
}

0 commit comments

Comments
 (0)