Skip to content

Commit 21ebc56

Browse files
Feature/4 spec update (#446)
* handled a bunch of todo's and the latest spec update * fixed serialization to properly ignore default values for [Optional] properties * Added tests to check for null
1 parent e0c9fc6 commit 21ebc56

File tree

102 files changed

+996
-668
lines changed

Some content is hidden

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

102 files changed

+996
-668
lines changed

language-server-protocol.sha.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- This is the last commit we caught up with https://github.com/Microsoft/language-server-protocol/commits/gh-pages
2-
lastSha: 0e116448e3b3f4ce0b983768c045dba0a41b6a72
2+
lastSha: ed36538a180f15d33ffb03365fba4ace47b42d68
33

4-
https://github.com/Microsoft/language-server-protocol/compare/0e116448e3b3f4ce0b983768c045dba0a41b6a72..gh-pages
4+
https://github.com/Microsoft/language-server-protocol/compare/ed36538a180f15d33ffb03365fba4ace47b42d68..gh-pages

src/Client/LanguageClientServiceCollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal static IContainer AddLanguageClientInternals(this IContainer container,
7272
var providedConfiguration = options.Services.FirstOrDefault(z => z.ServiceType == typeof(IConfiguration) && z.ImplementationInstance is IConfiguration);
7373
container.RegisterDelegate<IConfiguration>(
7474
_ => {
75-
var builder = new ConfigurationBuilder();
75+
var builder = options.ConfigurationBuilder;
7676
var outerConfiguration = outerServiceProvider?.GetService<IConfiguration>();
7777
if (outerConfiguration != null)
7878
{

src/Dap.Protocol/Serialization/DapContractResolver.cs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ
1717
)
1818
{
1919
property.NullValueHandling = NullValueHandling.Ignore;
20+
property.DefaultValueHandling = DefaultValueHandling.Ignore;
2021
}
2122

2223
return property;

src/JsonRpc.Generators/Contexts/JsonRpcAttributes.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ HashSet<string> additionalUsings
146146
var attribute = interfaceType.GetAttributes().First(z => z.AttributeClass?.Name == "MethodAttribute");
147147
if (attribute.ConstructorArguments.Length < 2)
148148
{
149-
cacheDiagnostic( static c => Diagnostic.Create(GeneratorDiagnostics.MissingDirection, c.AttributeLists.GetAttribute("GenerateHandlerMethods")?.GetLocation()));
149+
cacheDiagnostic(static c => Diagnostic.Create(GeneratorDiagnostics.MissingDirection, c.AttributeLists.GetAttribute("GenerateHandlerMethods")?.GetLocation()));
150150
yield break;
151151
}
152152

@@ -344,10 +344,10 @@ public static string GetRequestMethodName(TypeDeclarationSyntax syntax, INamedTy
344344
if (
345345
name.StartsWith("Run")
346346
|| name.StartsWith("Execute")
347-
// TODO: Change this next breaking change
348-
// || name.StartsWith("Set")
349-
// || name.StartsWith("Attach")
350-
// || name.StartsWith("Read")
347+
|| name.StartsWith("Set")
348+
|| name.StartsWith("Attach")
349+
|| name.StartsWith("Launch")
350+
|| name.StartsWith("Read")
351351
|| name.StartsWith("Did")
352352
|| name.StartsWith("Log")
353353
|| name.StartsWith("Show")

src/JsonRpc.Generators/RegistrationOptionsGenerator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ ReportCacheDiagnostic<TypeDeclarationSyntax> cacheDiagnostic
3434
var textDocumentRegistrationOptionsInterfaceSymbol =
3535
compilation.GetTypeByMetadataName("OmniSharp.Extensions.LanguageServer.Protocol.Models.ITextDocumentRegistrationOptions")!;
3636
var workDoneProgressOptionsInterfaceSymbol = compilation.GetTypeByMetadataName("OmniSharp.Extensions.LanguageServer.Protocol.Models.IWorkDoneProgressOptions")!;
37-
// TODO:
3837
var staticRegistrationOptionsInterfaceSymbol = compilation.GetTypeByMetadataName("OmniSharp.Extensions.LanguageServer.Protocol.Models.IStaticRegistrationOptions")!;
3938

4039
foreach (var registrationOptions in syntaxReceiver.RegistrationOptions)

src/Protocol/Client/Capabilities/ClientCapabilities.cs

+4-16
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,12 @@ public class GeneralClientCapabilities
4848
/// </summary>
4949
[Optional]
5050
public RegularExpressionsClientCapabilities? RegularExpressions { get; set; }
51-
}
52-
53-
/// <summary>
54-
/// Client capabilities specific to regular expressions.
55-
///
56-
/// @since 3.16.0 - proposed state
57-
/// </summary>
58-
public class RegularExpressionsClientCapabilities
59-
{
60-
/// <summary>
61-
/// The engine's name.
62-
/// </summary>
63-
public string Engine { get; set; } = null!;
6451

6552
/// <summary>
66-
/// The engine's version.
53+
/// Client capabilities specific to the client's markdown parser.
54+
///
55+
/// @since 3.16.0 - proposed state
6756
/// </summary>
68-
[Optional]
69-
public string? Version { get; set; }
57+
[Optional] public MarkdownClientCapabilities? Markdown { get; set; }
7058
}
7159
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
2+
3+
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
4+
{
5+
/// <summary>
6+
/// Client capabilities specific to the used markdown parser.
7+
///
8+
/// @since 3.16.0 - proposed state
9+
/// </summary>
10+
public record MarkdownClientCapabilities
11+
{
12+
/// <summary>
13+
/// The name of the parser.
14+
/// </summary>
15+
public string Parser { get; set; }
16+
17+
/// <summary>
18+
/// The version of the parser.
19+
/// </summary>
20+
[Optional]
21+
public string? Version { get; set; }
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
2+
3+
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
4+
{
5+
/// <summary>
6+
/// Client capabilities specific to regular expressions.
7+
///
8+
/// @since 3.16.0 - proposed state
9+
/// </summary>
10+
public class RegularExpressionsClientCapabilities
11+
{
12+
/// <summary>
13+
/// The engine's name.
14+
/// </summary>
15+
public string Engine { get; set; } = null!;
16+
17+
/// <summary>
18+
/// The engine's version.
19+
/// </summary>
20+
[Optional]
21+
public string? Version { get; set; }
22+
}
23+
}

src/Protocol/Client/Capabilities/WorkspaceEditCapability.cs

+9
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,14 @@ public class WorkspaceEditCapability : ICapability
3737
/// </summary>
3838
[Optional]
3939
public bool NormalizesLineEndings { get; set; }
40+
41+
/// <summary>
42+
/// Whether the client in general supports change annotations on text edits,
43+
/// create file, rename file and delete file changes.
44+
///
45+
/// @since 3.16.0 - proposed state
46+
/// </summary>
47+
[Optional]
48+
public bool ChangeAnnotationSupport { get; set; }
4049
}
4150
}

src/Protocol/Features/Document/CodeActionFeature.cs

+101-88
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public partial class CodeActionRegistrationOptions : IWorkDoneProgressOptions, I
302302
///
303303
/// @since 3.16.0
304304
/// </summary>
305+
[Optional]
305306
public bool ResolveProvider { get; set; }
306307

307308
class CodeActionRegistrationOptionsConverter : RegistrationOptionsConverterBase<CodeActionRegistrationOptions, StaticOptions>
@@ -324,113 +325,113 @@ public override StaticOptions Convert(CodeActionRegistrationOptions source)
324325
}
325326
}
326327

327-
/// <summary>
328-
/// A set of predefined code action kinds
329-
/// </summary>
330-
[DebuggerDisplay("{" + nameof(_value) + "}")]
331-
[JsonConverter(typeof(EnumLikeStringConverter))]
332-
public readonly struct CodeActionKind : IEquatable<CodeActionKind>, IEnumLikeString
333-
{
334-
private static readonly Lazy<IReadOnlyList<CodeActionKind>> _defaults =
335-
new Lazy<IReadOnlyList<CodeActionKind>>(
336-
() => {
337-
return typeof(CodeActionKind)
338-
.GetFields(BindingFlags.Static | BindingFlags.Public)
339-
.Select(z => z.GetValue(null))
340-
.Cast<CodeActionKind>()
341-
.ToArray();
342-
}
343-
);
344-
345-
public static IEnumerable<CodeActionKind> Defaults => _defaults.Value;
346-
347328
/// <summary>
348-
/// Base kind for quickfix actions: ''
329+
/// A set of predefined code action kinds
349330
/// </summary>
350-
public static readonly CodeActionKind Empty = new CodeActionKind("");
331+
[DebuggerDisplay("{" + nameof(_value) + "}")]
332+
[JsonConverter(typeof(EnumLikeStringConverter))]
333+
public readonly struct CodeActionKind : IEquatable<CodeActionKind>, IEnumLikeString
334+
{
335+
private static readonly Lazy<IReadOnlyList<CodeActionKind>> _defaults =
336+
new Lazy<IReadOnlyList<CodeActionKind>>(
337+
() => {
338+
return typeof(CodeActionKind)
339+
.GetFields(BindingFlags.Static | BindingFlags.Public)
340+
.Select(z => z.GetValue(null))
341+
.Cast<CodeActionKind>()
342+
.ToArray();
343+
}
344+
);
345+
346+
public static IEnumerable<CodeActionKind> Defaults => _defaults.Value;
351347

352-
/// <summary>
353-
/// Base kind for quickfix actions: 'quickfix'
354-
/// </summary>
355-
public static readonly CodeActionKind QuickFix = new CodeActionKind("quickfix");
348+
/// <summary>
349+
/// Base kind for quickfix actions: ''
350+
/// </summary>
351+
public static readonly CodeActionKind Empty = new CodeActionKind("");
356352

357-
/// <summary>
358-
/// Base kind for refactoring actions: 'refactor'
359-
/// </summary>
360-
public static readonly CodeActionKind Refactor = new CodeActionKind("refactor");
353+
/// <summary>
354+
/// Base kind for quickfix actions: 'quickfix'
355+
/// </summary>
356+
public static readonly CodeActionKind QuickFix = new CodeActionKind("quickfix");
361357

362-
/// <summary>
363-
/// Base kind for refactoring extraction actions: 'refactor.extract'
364-
///
365-
/// Example extract actions:
366-
///
367-
/// - Extract method
368-
/// - Extract function
369-
/// - Extract variable
370-
/// - Extract interface from class
371-
/// - ...
372-
/// </summary>
373-
public static readonly CodeActionKind RefactorExtract = new CodeActionKind("refactor.extract");
358+
/// <summary>
359+
/// Base kind for refactoring actions: 'refactor'
360+
/// </summary>
361+
public static readonly CodeActionKind Refactor = new CodeActionKind("refactor");
374362

375-
/// <summary>
376-
/// Base kind for refactoring inline actions: 'refactor.inline'
377-
///
378-
/// Example inline actions:
379-
///
380-
/// - Inline function
381-
/// - Inline variable
382-
/// - Inline constant
383-
/// - ...
384-
/// </summary>
385-
public static readonly CodeActionKind RefactorInline = new CodeActionKind("refactor.inline");
363+
/// <summary>
364+
/// Base kind for refactoring extraction actions: 'refactor.extract'
365+
///
366+
/// Example extract actions:
367+
///
368+
/// - Extract method
369+
/// - Extract function
370+
/// - Extract variable
371+
/// - Extract interface from class
372+
/// - ...
373+
/// </summary>
374+
public static readonly CodeActionKind RefactorExtract = new CodeActionKind("refactor.extract");
386375

387-
/// <summary>
388-
/// Base kind for refactoring rewrite actions: 'refactor.rewrite'
389-
///
390-
/// Example rewrite actions:
391-
///
392-
/// - Convert JavaScript function to class
393-
/// - Add or remove parameter
394-
/// - Encapsulate field
395-
/// - Make method static
396-
/// - Move method to base class
397-
/// - ...
398-
/// </summary>
399-
public static readonly CodeActionKind RefactorRewrite = new CodeActionKind("refactor.rewrite");
376+
/// <summary>
377+
/// Base kind for refactoring inline actions: 'refactor.inline'
378+
///
379+
/// Example inline actions:
380+
///
381+
/// - Inline function
382+
/// - Inline variable
383+
/// - Inline constant
384+
/// - ...
385+
/// </summary>
386+
public static readonly CodeActionKind RefactorInline = new CodeActionKind("refactor.inline");
400387

401-
/// <summary>
402-
/// Base kind for source actions: `source`
403-
///
404-
/// Source code actions apply to the entire file.
405-
/// </summary>
406-
public static readonly CodeActionKind Source = new CodeActionKind("source");
388+
/// <summary>
389+
/// Base kind for refactoring rewrite actions: 'refactor.rewrite'
390+
///
391+
/// Example rewrite actions:
392+
///
393+
/// - Convert JavaScript function to class
394+
/// - Add or remove parameter
395+
/// - Encapsulate field
396+
/// - Make method static
397+
/// - Move method to base class
398+
/// - ...
399+
/// </summary>
400+
public static readonly CodeActionKind RefactorRewrite = new CodeActionKind("refactor.rewrite");
407401

408-
/// <summary>
409-
/// Base kind for an organize imports source action: `source.organizeImports`
410-
/// </summary>
411-
public static readonly CodeActionKind SourceOrganizeImports = new CodeActionKind("source.organizeImports");
402+
/// <summary>
403+
/// Base kind for source actions: `source`
404+
///
405+
/// Source code actions apply to the entire file.
406+
/// </summary>
407+
public static readonly CodeActionKind Source = new CodeActionKind("source");
408+
409+
/// <summary>
410+
/// Base kind for an organize imports source action: `source.organizeImports`
411+
/// </summary>
412+
public static readonly CodeActionKind SourceOrganizeImports = new CodeActionKind("source.organizeImports");
412413

413-
private readonly string? _value;
414+
private readonly string? _value;
414415

415-
public CodeActionKind(string kind) => _value = kind;
416+
public CodeActionKind(string kind) => _value = kind;
416417

417-
public static implicit operator CodeActionKind(string kind) => new CodeActionKind(kind);
418+
public static implicit operator CodeActionKind(string kind) => new CodeActionKind(kind);
418419

419-
public static implicit operator string(CodeActionKind kind) => kind._value ?? string.Empty;
420+
public static implicit operator string(CodeActionKind kind) => kind._value ?? string.Empty;
420421

421-
/// <inheritdoc />
422-
public override string ToString() => _value ?? string.Empty;
422+
/// <inheritdoc />
423+
public override string ToString() => _value ?? string.Empty;
423424

424-
public bool Equals(CodeActionKind other) => _value == other._value;
425+
public bool Equals(CodeActionKind other) => _value == other._value;
425426

426-
public override bool Equals(object obj) => obj is CodeActionKind other && Equals(other);
427+
public override bool Equals(object obj) => obj is CodeActionKind other && Equals(other);
427428

428-
public override int GetHashCode() => _value != null ? _value.GetHashCode() : 0;
429+
public override int GetHashCode() => _value != null ? _value.GetHashCode() : 0;
429430

430-
public static bool operator ==(CodeActionKind left, CodeActionKind right) => left.Equals(right);
431+
public static bool operator ==(CodeActionKind left, CodeActionKind right) => left.Equals(right);
431432

432-
public static bool operator !=(CodeActionKind left, CodeActionKind right) => !left.Equals(right);
433-
}
433+
public static bool operator !=(CodeActionKind left, CodeActionKind right) => !left.Equals(right);
434+
}
434435
}
435436

436437
namespace Client.Capabilities
@@ -479,6 +480,18 @@ public partial class CodeActionCapability : DynamicCapability, ConnectedCapabili
479480
/// </summary>
480481
[Optional]
481482
public CodeActionCapabilityResolveSupportOptions? ResolveSupport { get; set; }
483+
484+
/// <summary>
485+
/// Whether th client honors the change annotations in
486+
/// text edits and resource operations returned via the
487+
/// `CodeAction#edit` property by for example presenting
488+
/// the workspace edit in the user interface and asking
489+
/// for confirmation.
490+
///
491+
/// @since 3.16.0 - proposed state
492+
/// </summary>
493+
[Optional]
494+
public bool HonorsChangeAnnotations { get; set; }
482495
}
483496

484497
public class CodeActionLiteralSupportOptions

src/Protocol/Features/Document/CompletionFeature.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,8 @@ public partial record CompletionItem : ICanBeResolved, IRequest<CompletionItem>
177177
///
178178
/// @since 3.16.0 additional type `InsertReplaceEdit` - proposed state
179179
/// </summary>
180-
/// <remarks>
181-
/// TODO: Update this to union <see cref="TextEdit"/> <see cref="InsertReplaceEdit"/>
182-
/// </remarks>
183180
[Optional]
184-
public TextEdit? TextEdit { get; init; }
181+
public TextEditOrInsertReplaceEdit? TextEdit { get; init; }
185182

186183
/// <summary>
187184
/// An optional array of additional text edits that are applied when

0 commit comments

Comments
 (0)