Skip to content

Commit b4fcc89

Browse files
Lsp models 1/2
1 parent 5f7f738 commit b4fcc89

File tree

95 files changed

+331
-335
lines changed

Some content is hidden

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

95 files changed

+331
-335
lines changed

src/Protocol/Models/ApplyWorkspaceEditParams.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class ApplyWorkspaceEditParams : IRequest<ApplyWorkspaceEditResponse>
1313
/// stack to undo the workspace edit.
1414
/// </summary>
1515
[Optional]
16-
public string Label { get; set; }
16+
public string? Label { get; set; }
1717

1818
/// <summary>
1919
/// The edits to apply.
2020
/// </summary>
21-
public WorkspaceEdit Edit { get; set; }
21+
public WorkspaceEdit Edit { get; set; } = null!;
2222
}
2323
}

src/Protocol/Models/ApplyWorkspaceEditResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public class ApplyWorkspaceEditResponse
1616
/// triggered the edit.
1717
/// </summary>
1818
[Optional]
19-
public string FailureReason { get; set; }
19+
public string? FailureReason { get; set; }
2020
}
2121
}

src/Protocol/Models/BooleanNumberString.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
77
public struct BooleanNumberString
88
{
99
private long? _long;
10-
private string _string;
10+
private string? _string;
1111
private bool? _bool;
1212

1313
public BooleanNumberString(long value)
@@ -37,7 +37,7 @@ public long Long
3737
{
3838
get => _long ?? 0;
3939
set {
40-
String = null;
40+
_string = null;
4141
_long = value;
4242
_bool = null;
4343
}
@@ -47,7 +47,7 @@ public long Long
4747

4848
public string String
4949
{
50-
get => _string;
50+
get => _string ?? string.Empty;
5151
set {
5252
_string = value;
5353
_long = null;
@@ -61,7 +61,7 @@ public bool Bool
6161
{
6262
get => _bool.HasValue && _bool.Value;
6363
set {
64-
String = null;
64+
_string = null;
6565
_long = null;
6666
_bool = value;
6767
}

src/Protocol/Models/BooleanOr.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public BooleanOr(T value)
1515

1616
public BooleanOr(bool value)
1717
{
18-
_value = default;
18+
_value = default!;
1919
_bool = value;
2020
}
2121

2222
// To avoid boxing, the best way to compare generics for equality is with EqualityComparer<T>.Default.
2323
// This respects IEquatable<T> (without boxing) as well as object.Equals, and handles all the Nullable<T> "lifted" nuances.
2424
// https://stackoverflow.com/a/864860
25-
public bool IsValue => !EqualityComparer<T>.Default.Equals(_value, default);
25+
public bool IsValue => !EqualityComparer<T>.Default.Equals(_value, default!);
2626

2727
public T Value
2828
{
@@ -39,12 +39,12 @@ public bool Bool
3939
{
4040
get => _bool.HasValue && _bool.Value;
4141
set {
42-
Value = default;
42+
_value = default!;
4343
_bool = value;
4444
}
4545
}
4646

47-
public object RawValue
47+
public object? RawValue
4848
{
4949
get {
5050
if (IsBool) return Bool;
@@ -53,7 +53,7 @@ public object RawValue
5353
}
5454
}
5555

56-
public static implicit operator BooleanOr<T>(T value) => value != null ? new BooleanOr<T>(value) : null;
56+
public static implicit operator BooleanOr<T>(T value) => value != null ? new BooleanOr<T>(value) : new BooleanOr<T>(false);
5757

5858
public static implicit operator BooleanOr<T>(bool value) => new BooleanOr<T>(value);
5959
}

src/Protocol/Models/BooleanString.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
66
[JsonConverter(typeof(BooleanStringConverter))]
77
public struct BooleanString
88
{
9-
private string _string;
9+
private string? _string;
1010
private bool? _bool;
1111

1212
public BooleanString(string value)
@@ -25,7 +25,7 @@ public BooleanString(bool value)
2525

2626
public string String
2727
{
28-
get => _string;
28+
get => _string ?? string.Empty;
2929
set {
3030
_string = value;
3131
_bool = null;
@@ -38,7 +38,7 @@ public bool Bool
3838
{
3939
get => _bool.HasValue && _bool.Value;
4040
set {
41-
String = null;
41+
_string = null;
4242
_bool = value;
4343
}
4444
}

src/Protocol/Models/ClientInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public class ClientInfo
1414
/// <summary>
1515
/// The name of the client as defined by the client.
1616
/// </summary>
17-
public string Name { get; set; }
17+
public string Name { get; set; } = null!;
1818

1919
/// <summary>
2020
/// The client's version as defined by the client.
2121
/// </summary>
2222
[Optional]
23-
public string Version { get; set; }
23+
public string? Version { get; set; }
2424

2525
private string DebuggerDisplay => string.IsNullOrWhiteSpace(Version) ? Name : $"{Name} ({Version})";
2626

src/Protocol/Models/CodeAction.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class CodeAction
99
/// <summary>
1010
/// A short, human-readable, title for this code action.
1111
/// </summary>
12-
public string Title { get; set; }
12+
public string Title { get; set; } = null!;
1313

1414
/// <summary>
1515
/// The kind of the code action.
@@ -35,21 +35,21 @@ public class CodeAction
3535
/// The diagnostics that this code action resolves.
3636
/// </summary>
3737
[Optional]
38-
public Container<Diagnostic> Diagnostics { get; set; }
38+
public Container<Diagnostic>? Diagnostics { get; set; }
3939

4040
/// <summary>
4141
/// The workspace edit this code action performs.
4242
/// </summary>
4343
[Optional]
44-
public WorkspaceEdit Edit { get; set; }
44+
public WorkspaceEdit? Edit { get; set; }
4545

4646
/// <summary>
4747
/// A command this code action executes. If a code action
4848
/// provides an edit and a command, first the edit is
4949
/// executed and then the command.
5050
/// </summary>
5151
[Optional]
52-
public Command Command { get; set; }
52+
public Command? Command { get; set; }
5353

5454
private string DebuggerDisplay => $"[{Kind}] {Title}";
5555

src/Protocol/Models/CodeActionContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class CodeActionContext
1515
/// that these accurately reflect the error state of the resource. The primary parameter
1616
/// to compute code actions is the provided range.
1717
/// </summary>
18-
public Container<Diagnostic> Diagnostics { get; set; }
18+
public Container<Diagnostic> Diagnostics { get; set; } = null!;
1919

2020
/// <summary>
2121
/// Requested kind of actions to return.
@@ -24,6 +24,6 @@ public class CodeActionContext
2424
/// can omit computing them.
2525
/// </summary>
2626
[Optional]
27-
public Container<CodeActionKind> Only { get; set; }
27+
public Container<CodeActionKind>? Only { get; set; }
2828
}
2929
}

src/Protocol/Models/CodeActionKind.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
7878
/// </summary>
7979
public static readonly CodeActionKind SourceOrganizeImports = new CodeActionKind("source.organizeImports");
8080

81-
private readonly string _value;
81+
private readonly string? _value;
8282

8383
public CodeActionKind(string kind) => _value = kind;
8484

8585
public static implicit operator CodeActionKind(string kind) => new CodeActionKind(kind);
8686

87-
public static implicit operator string(CodeActionKind kind) => kind._value;
87+
public static implicit operator string(CodeActionKind kind) => kind._value ?? string.Empty;
8888

8989
/// <inheritdoc />
90-
public override string ToString() => _value;
90+
public override string ToString() => _value ?? string.Empty;
9191

9292
public bool Equals(CodeActionKind other) => _value == other._value;
9393

src/Protocol/Models/CodeActionParams.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ public class CodeActionParams : ITextDocumentIdentifierParams, IPartialItemsRequ
1212
/// <summary>
1313
/// The document in which the command was invoked.
1414
/// </summary>
15-
public TextDocumentIdentifier TextDocument { get; set; }
15+
public TextDocumentIdentifier TextDocument { get; set; } = null!;
1616

1717
/// <summary>
1818
/// The range for which the command was invoked.
1919
/// </summary>
20-
public Range Range { get; set; }
20+
public Range Range { get; set; } = null!;
2121

2222
/// <summary>
2323
/// Context carrying additional information.
2424
/// </summary>
25-
public CodeActionContext Context { get; set; }
25+
public CodeActionContext Context { get; set; } = null!;
2626

2727
/// <inheritdoc />
2828
[Optional]
29-
public ProgressToken PartialResultToken { get; set; }
29+
public ProgressToken? PartialResultToken { get; set; }
3030

3131
/// <inheritdoc />
3232
[Optional]
33-
public ProgressToken WorkDoneToken { get; set; }
33+
public ProgressToken? WorkDoneToken { get; set; }
3434
}
3535
}

src/Protocol/Models/CodeActionRegistrationOptions.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
32
using OmniSharp.Extensions.LanguageServer.Protocol.Server.Capabilities;
43

@@ -13,7 +12,7 @@ public class CodeActionRegistrationOptions : WorkDoneTextDocumentRegistrationOpt
1312
/// may list out every specific kind they provide.
1413
/// </summary>
1514
[Optional]
16-
public Container<CodeActionKind> CodeActionKinds { get; set; } = new Container<CodeActionKind>();
15+
public Container<CodeActionKind>? CodeActionKinds { get; set; } = new Container<CodeActionKind>();
1716

1817
public class StaticOptions : WorkDoneProgressOptions
1918
{
@@ -24,12 +23,15 @@ public class StaticOptions : WorkDoneProgressOptions
2423
/// may list out every specific kind they provide.
2524
/// </summary>
2625
[Optional]
27-
public Container<CodeActionKind> CodeActionKinds { get; set; } = new Container<CodeActionKind>();
26+
public Container<CodeActionKind>? CodeActionKinds { get; set; } = new Container<CodeActionKind>();
2827
}
2928

3029
class CodeActionRegistrationOptionsConverter : RegistrationOptionsConverterBase<CodeActionRegistrationOptions, StaticOptions>
3130
{
32-
public CodeActionRegistrationOptionsConverter() : base(nameof(ServerCapabilities.CodeActionProvider)) { }
31+
public CodeActionRegistrationOptionsConverter() : base(nameof(ServerCapabilities.CodeActionProvider))
32+
{
33+
}
34+
3335
public override StaticOptions Convert(CodeActionRegistrationOptions source)
3436
{
3537
return new StaticOptions {

src/Protocol/Models/CodeLens.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ public class CodeLens : IRequest<CodeLens>, ICanBeResolved
2020
/// <summary>
2121
/// The range in which this code lens is valid. Should only span a single line.
2222
/// </summary>
23-
public Range Range { get; set; }
23+
public Range Range { get; set; } = null!;
2424

2525
/// <summary>
2626
/// The command this code lens represents.
2727
/// </summary>
2828
[Optional]
29-
public Command Command { get; set; }
29+
public Command? Command { get; set; }
3030

3131
/// <summary>
3232
/// A data entry field that is preserved on a code lens item between
3333
/// a code lens and a code lens resolve request.
3434
/// </summary>
3535
[Optional]
36-
public JToken Data { get; set; }
36+
public JToken? Data { get; set; }
3737

3838
private string DebuggerDisplay => $"{Range}{( Command != null ? $" {Command}" : "" )}";
3939

@@ -55,24 +55,28 @@ public class CodeLens : IRequest<CodeLens>, ICanBeResolved
5555
public class CodeLens<T> : ICanBeResolved
5656
where T : HandlerIdentity, new()
5757
{
58-
/// <inheritdoc />
59-
public Range Range { get; set; }
58+
/// <summary>
59+
/// The range in which this code lens is valid. Should only span a single line.
60+
/// </summary>
61+
public Range Range { get; set; } = null!;
6062

61-
/// <inheritdoc />
63+
/// <summary>
64+
/// The command this code lens represents.
65+
/// </summary>
6266
[Optional]
63-
public Command Command { get; set; }
67+
public Command? Command { get; set; }
6468

6569
/// <summary>
6670
/// A data entry field that is preserved on a code lens item between
6771
/// a code lens and a code lens resolve request.
6872
/// </summary>
6973
public T Data
7074
{
71-
get => ( (ICanBeResolved) this ).Data?.ToObject<T>();
72-
set => ( (ICanBeResolved) this ).Data = JToken.FromObject(value ?? new object());
75+
get => ( (ICanBeResolved) this ).Data?.ToObject<T>()!;
76+
set => ( (ICanBeResolved) this ).Data = JToken.FromObject(value);
7377
}
7478

75-
JToken ICanBeResolved.Data { get; set; }
79+
JToken? ICanBeResolved.Data { get; set; }
7680

7781
public static implicit operator CodeLens(CodeLens<T> value) => new CodeLens {
7882
Data = ( (ICanBeResolved) value ).Data,

src/Protocol/Models/CodeLensParams.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ public class CodeLensParams : ITextDocumentIdentifierParams, IWorkDoneProgressPa
99
/// <summary>
1010
/// The document to request code lens for.
1111
/// </summary>
12-
public TextDocumentIdentifier TextDocument { get; set; }
12+
public TextDocumentIdentifier TextDocument { get; set; } = null!;
1313

1414
/// <inheritdoc />
1515
[Optional]
16-
public ProgressToken PartialResultToken { get; set; }
16+
public ProgressToken? PartialResultToken { get; set; }
1717

1818
/// <inheritdoc />
1919
[Optional]
20-
public ProgressToken WorkDoneToken { get; set; }
20+
public ProgressToken? WorkDoneToken { get; set; }
2121
}
2222
}

src/Protocol/Models/CodeLensRegistrationOptions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
1+
using System.Linq;
32
using OmniSharp.Extensions.JsonRpc;
43
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
54
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;

src/Protocol/Models/ColorInformation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ public class ColorInformation
55
/// <summary>
66
/// The range in the document where this color appers.
77
/// </summary>
8-
public Range Range { get; set; }
8+
public Range Range { get; set; } = null!;
99

1010
/// <summary>
1111
/// The actual color value for this color range.
1212
/// </summary>
13-
public DocumentColor Color { get; set; }
13+
public DocumentColor Color { get; set; } = null!;
1414
}
1515
}

src/Protocol/Models/ColorPresentation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ public class ColorPresentation
99
/// picker header. By default this is also the text that is inserted when selecting
1010
/// this color presentation.
1111
/// </summary>
12-
public string Label { get; set; }
12+
public string Label { get; set; } = null!;
1313

1414
/// <summary>
1515
/// An [edit](#TextEdit) which is applied to a document when selecting
1616
/// this presentation for the color. When `falsy` the [label](#ColorPresentation.label)
1717
/// is used.
1818
/// </summary>
1919
[Optional]
20-
public TextEdit TextEdit { get; set; }
20+
public TextEdit? TextEdit { get; set; }
2121

2222
/// <summary>
2323
/// An optional array of additional [text edits](#TextEdit) that are applied when
2424
/// selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves.
2525
/// </summary>
2626
[Optional]
27-
public TextEditContainer AdditionalTextEdits { get; set; }
27+
public TextEditContainer? AdditionalTextEdits { get; set; }
2828
}
2929
}

0 commit comments

Comments
 (0)