Skip to content

Commit c8429d2

Browse files
started spec update
1 parent efe2312 commit c8429d2

16 files changed

+420
-17
lines changed

LanguageServer/Protocol/Models/FoldingRangeKind.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ public enum FoldingRangeKind
88
/// <summary>
99
/// Folding range for a comment
1010
/// </summary>
11+
[EnumMember(Value="comment")]
1112
Comment,
1213
/// <summary>
1314
/// Folding range for a imports or includes
1415
/// </summary>
16+
[EnumMember(Value="imports")]
1517
Imports,
1618
/// <summary>
1719
/// Folding range for a region (e.g. `#region`)
1820
/// </summary>
21+
[EnumMember(Value="region")]
1922
Region
2023
}
2124
}

src/Protocol/Client/Capabilities/CodeActionCapability.cs

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,113 @@
22

33
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
44
{
5-
public class CodeActionCapability : DynamicCapability, ConnectedCapability<ICodeActionHandler> { }
5+
public class CodeActionCapability : DynamicCapability, ConnectedCapability<ICodeActionHandler>
6+
{
7+
/// <summary>
8+
/// The client support code action literals as a valid
9+
/// response of the `textDocument/codeAction` request.
10+
///
11+
/// Since 3.8.0
12+
/// </summary>
13+
[Optional]
14+
public CodeActionLiteralSupportCapability codeActionLiteralSupport { get; set; }
15+
}
16+
17+
public class CodeActionLiteralSupportCapability
18+
{
19+
20+
/// <summary>
21+
/// The code action kind is support with the following value
22+
/// set.
23+
/// </summary>
24+
25+
public CodeActionKindCapability CodeActionKind { get; set; }
26+
}
27+
28+
public class CodeActionKindCapability
29+
{
30+
/// <summary>
31+
/// The code action kind values the client supports. When this
32+
/// property exists the client also guarantees that it will
33+
/// handle values outside its set gracefully and falls back
34+
/// to a default value when unknown.
35+
/// </summary>
36+
public Container<CodeActionKind> ValueSet { get; set; }
37+
}
38+
39+
/// <summary>
40+
/// A set of predefined code action kinds
41+
/// </summary>
42+
[JsonConverter(typeof(CodeActionKindConverter))]
43+
public class CodeActionKind
44+
{
45+
/// <summary>
46+
/// Base kind for quickfix actions: 'quickfix'
47+
/// </summary>
48+
public static CodeActionKind QuickFix = new CodeActionKind("quickfix");
49+
50+
/// <summary>
51+
/// Base kind for refactoring actions: 'refactor'
52+
/// </summary>
53+
public static CodeActionKind Refactor = new CodeActionKind("refactor");
54+
55+
/// <summary>
56+
/// Base kind for refactoring extraction actions: 'refactor.extract'
57+
///
58+
/// Example extract actions:
59+
///
60+
/// - Extract method
61+
/// - Extract function
62+
/// - Extract variable
63+
/// - Extract interface from class
64+
/// - ...
65+
/// </summary>
66+
public static CodeActionKind RefactorExtract = new CodeActionKind("refactor.extract");
67+
68+
/// <summary>
69+
/// Base kind for refactoring inline actions: 'refactor.inline'
70+
///
71+
/// Example inline actions:
72+
///
73+
/// - Inline function
74+
/// - Inline variable
75+
/// - Inline constant
76+
/// - ...
77+
/// </summary>
78+
public static CodeActionKind RefactorInline = new CodeActionKind("refactor.inline");
79+
80+
/// <summary>
81+
/// Base kind for refactoring rewrite actions: 'refactor.rewrite'
82+
///
83+
/// Example rewrite actions:
84+
///
85+
/// - Convert JavaScript function to class
86+
/// - Add or remove parameter
87+
/// - Encapsulate field
88+
/// - Make method static
89+
/// - Move method to base class
90+
/// - ...
91+
/// </summary>
92+
public static CodeActionKind RefactorRewrite = new CodeActionKind("refactor.rewrite");
93+
94+
/// <summary>
95+
/// Base kind for source actions: `source`
96+
///
97+
/// Source code actions apply to the entire file.
98+
/// </summary>
99+
public static CodeActionKind Source = new CodeActionKind("source");
100+
101+
/// <summary>
102+
/// Base kind for an organize imports source action: `source.organizeImports`
103+
/// </summary>
104+
public static CodeActionKind SourceOrganizeImports = new CodeActionKind("source.organizeImports");
105+
106+
public CodeActionKind(string kind)
107+
{
108+
kind = kind;
109+
}
110+
111+
public string Kind { get; }
112+
113+
}
6114
}

src/Protocol/Client/Capabilities/CompletionItemCapability.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,16 @@ public class CompletionItemCapability
3030
/// </summary>
3131
[Optional]
3232
public Container<MarkupKind> DocumentationFormat { get; set; }
33+
34+
/// <summary>
35+
/// Client supports the deprecated property on a completion item.
36+
/// </summary>
37+
[Optional]
38+
public bool DeprecatedSupport { get; set; }
39+
/// <summary>
40+
/// Client supports the preselect property on a completion item.
41+
/// </summary>
42+
[Optional]
43+
public bool PreselectSupport { get; set; }
3344
}
3445
}

src/Protocol/Models/BooleanOr.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,97 @@ public static implicit operator BooleanOr<T>(bool value)
5656
return new BooleanOr<T>(value);
5757
}
5858
}
59+
60+
public struct CommandOrCodeAction
61+
{
62+
private CodeAction _codeAction;
63+
private Command _command;
64+
public CommandOrCodeAction(CodeAction value)
65+
{
66+
_codeAction = value;
67+
_command = default;
68+
}
69+
public CommandOrCodeAction(Command value)
70+
{
71+
_codeAction = default;
72+
_command = value;
73+
}
74+
75+
public bool IsCommand => this._command != null;
76+
public T Command
77+
{
78+
get { return this._command; }
79+
set
80+
{
81+
this._command = value;
82+
this._codeAction = null;
83+
}
84+
}
85+
86+
public bool IsCodeAction => this._codeAction != null;
87+
public bool CodeAction
88+
{
89+
get { return this._codeAction; }
90+
set
91+
{
92+
this._command = default;
93+
this._codeAction = value;
94+
}
95+
}
96+
public object RawValue
97+
{
98+
get
99+
{
100+
if (IsCommand) return Command;
101+
if (IsCodeAction) return CodeAction;
102+
return default;
103+
}
104+
}
105+
106+
public static implicit operator CommandOrCodeAction(Command value)
107+
{
108+
return new CommandOrCodeAction(value);
109+
}
110+
111+
public static implicit operator CommandOrCodeAction(CodeAction value)
112+
{
113+
return new CommandOrCodeAction(value);
114+
}
115+
}
116+
117+
public class CodeAction
118+
{
119+
/// <summary>
120+
/// A short, human-readable, title for this code action.
121+
/// </summary>
122+
public string Title { get; set; }
123+
124+
/// <summary>
125+
/// The kind of the code action.
126+
///
127+
/// Used to filter code actions.
128+
/// </summary>
129+
[Optional]
130+
public CodeActionKind Kind { get; set; }
131+
132+
/// <summary>
133+
/// The diagnostics that this code action resolves.
134+
/// </summary>
135+
[Optional]
136+
public Container<Diagnostic> Diagnostics { get; set; }
137+
138+
/// <summary>
139+
/// The workspace edit this code action performs.
140+
/// </summary>
141+
[Optional]
142+
public WorkspaceEdit Edit { get; set; }
143+
144+
/// <summary>
145+
/// A command this code action executes. If a code action
146+
/// provides an edit and a command, first the edit is
147+
/// executed and then the command.
148+
/// </summary>
149+
[Optional]
150+
public Command Command { get; set; }
151+
}
59152
}

src/Protocol/Models/CodeActionContext.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,13 @@ public class CodeActionContext
1313
/// An array of diagnostics.
1414
/// </summary>
1515
public Container<Diagnostic> Diagnostics { get; set; }
16+
17+
/// <summary>
18+
/// Requested kind of actions to return.
19+
///
20+
/// Actions not of this kind are filtered out by the client before being shown. So servers
21+
/// can omit computing them.
22+
/// </summary>
23+
public Container<CodeActionKind> Only { get; set; }
1624
}
1725
}

src/Protocol/Models/ColorPresentationParams.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ public class ColorPresentationParams : IRequest<Container<ColorPresentation>>
1111
/// <summary>
1212
/// The actual color value for this color range.
1313
/// </summary>
14-
public Color ColorInfo { get; set; }
14+
public Color Color { get; set; }
1515
/// <summary>
1616
/// The range in the document where this color appers.
1717
/// </summary>
1818
public Range Range { get; set; }
1919
}
20-
}
20+
}

src/Protocol/Models/CompletionItem.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ public class CompletionItem : ICanBeResolved, IRequest<CompletionItem>
3535
[Optional]
3636
public StringOrMarkupContent Documentation { get; set; }
3737

38+
/// <summary>
39+
/// Indicates if this item is deprecated.
40+
/// </summary>
41+
[Optional]
42+
public bool Deprecated { get; set; }
43+
44+
/// <summary>
45+
/// Select this item when showing.
46+
///
47+
/// *Note* that only one completion item can be selected and that the
48+
/// tool / client decides which item that is. The rule is that the *first*
49+
/// item of those that match best is selected.
50+
/// </summary>
51+
[Optional]
52+
public bool Preselect { get; set; }
53+
3854
/// <summary>
3955
/// A string that shoud be used when comparing this item
4056
/// with other items. When `falsy` the label is used.

0 commit comments

Comments
 (0)