Skip to content

Commit 5c52958

Browse files
Added prepare rename, and fixed build. Tests wip
1 parent 94eddef commit 5c52958

File tree

65 files changed

+763
-508
lines changed

Some content is hidden

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

65 files changed

+763
-508
lines changed

LanguageServer/Protocol/Server/Capabilities/FoldingRangeProviderOptions.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

language-server-protocol.sha.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-- This is the last commit we caught up with https://github.com/Microsoft/language-server-protocol/commits/gh-pages
2-
f39afb47038be65431ec684dc11725ff74e71f48
2+
9e2713d5f1618b8d5e05a91a4e2c637aa51e1ee0

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('Common.Build.props', '$(MSBuildThisFileDirectory)../'))" />
33
<PropertyGroup>
44
<PackageVersion Condition="'$(GitVersion_NuGetVersion)' != ''">$(GitVersion_NuGetVersion)</PackageVersion>
5+
<AssemblyVersion>0.0.9.9</AssemblyVersion>
56
<AssemblyVersion Condition="'$(GitVersion_AssemblySemVer)' != ''">$(GitVersion_Major).$(GitVersion_Minor).0.0</AssemblyVersion>
6-
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">0.0.9.9</AssemblyVersion>
77
<FileVersion Condition="'$(GitVersion_AssemblySemVer)' != ''">$(GitVersion_AssemblySemVer)</FileVersion>
88
<InformationalVersion Condition="'$(GitVersion_InformationalVersion)' != ''">$(GitVersion_InformationalVersion)</InformationalVersion>
99
<IsPackable>true</IsPackable>
Lines changed: 2 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
12
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
23

34
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
@@ -11,104 +12,6 @@ public class CodeActionCapability : DynamicCapability, ConnectedCapability<ICode
1112
/// Since 3.8.0
1213
/// </summary>
1314
[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-
15+
public CodeActionLiteralSupportCapability CodeActionLiteralSupport { get; set; }
11316
}
11417
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
2+
3+
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
4+
{
5+
public class CodeActionKindCapability
6+
{
7+
/// <summary>
8+
/// The code action kind values the client supports. When this
9+
/// property exists the client also guarantees that it will
10+
/// handle values outside its set gracefully and falls back
11+
/// to a default value when unknown.
12+
/// </summary>
13+
public Container<CodeActionKind> ValueSet { get; set; }
14+
}
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
2+
{
3+
public class CodeActionLiteralSupportCapability
4+
{
5+
6+
/// <summary>
7+
/// The code action kind is support with the following value
8+
/// set.
9+
/// </summary>
10+
11+
public CodeActionKindCapability CodeActionKind { get; set; }
12+
}
13+
}

src/Protocol/Client/Capabilities/ColorProviderCapability.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,4 @@
33
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
44
{
55
public class ColorProviderCapability : DynamicCapability, ConnectedCapability<IDocumentColorHandler>, ConnectedCapability<IColorPresentationHandler> { }
6-
public class FoldingRangeCapability : DynamicCapability, ConnectedCapability<IFoldingRangeHandler>, ConnectedCapability<IFoldingRangeHandler>
7-
{
8-
/// <summary>
9-
/// The maximum number of folding ranges that the client prefers to receive per document. The value serves as a
10-
/// hint, servers are free to follow the limit.
11-
/// </summary>
12-
[Optional]
13-
public int? RangeLimit { get; set; }
14-
15-
/// <summary>
16-
/// If set, the client signals that it only supports folding complete lines. If set, client will
17-
/// ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange.
18-
/// </summary>
19-
public bool LineFoldingOnly { get; set; }
20-
}
216
}

src/Protocol/Client/Capabilities/DocumentSymbolCapability.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public class DocumentSymbolCapability : DynamicCapability, ConnectedCapability<I
1616
/// Whether document symbol supports hierarchical `DocumentSymbol`s.
1717
/// </summary>
1818
[Optional]
19-
public bool? hierarchicalDocumentSymbolSupport { get; set; }
19+
public bool? HierarchicalDocumentSymbolSupport { get; set; }
2020
}
2121
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
2+
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
23

34
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
45
{
5-
public class FoldingRangeCapability : DynamicCapability
6+
public class FoldingRangeCapability : DynamicCapability, ConnectedCapability<IFoldingRangeHandler>
67
{
78
/// <summary>
89
/// The maximum number of folding ranges that the client prefers to receive per document. The value serves as a
910
/// hint, servers are free to follow the limit.
1011
/// </summary>
1112
[Optional]
12-
public long? RangeLimit { get; set; }
13+
public int? RangeLimit { get; set; }
1314

1415
/// <summary>
15-
/// set, the client signals that it only supports folding complete lines. If set, client will
16+
/// If set, the client signals that it only supports folding complete lines. If set, client will
1617
/// ignore specified `startCharacter` and `endCharacter` properties in a FoldingRange.
1718
/// </summary>
18-
[Optional]
1919
public bool LineFoldingOnly { get; set; }
2020
}
2121
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
12
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
23

34
namespace OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities
45
{
5-
public class RenameCapability : DynamicCapability, ConnectedCapability<IRenameHandler> { }
6+
public class RenameCapability : DynamicCapability, ConnectedCapability<IRenameHandler>, ConnectedCapability<IPrepareRenameHandler>
7+
{
8+
/// <summary>
9+
/// Client supports testing for validity of rename operations
10+
/// before execution.
11+
/// </summary>
12+
[Optional]
13+
public bool PrepareSupport { get; set; }
14+
}
615
}

src/Protocol/Client/Capabilities/TextDocumentClientCapabilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public class TextDocumentClientCapabilities
104104
///
105105
/// Since 3.10.0
106106
/// </summary>
107-
public Supports<FoldingRangeProviderCapability> FoldingRangeProvider { get; set; }
107+
public Supports<FoldingRangeCapability> FoldingRangeProvider { get; set; }
108108

109109
/// <summary>
110110
/// Capabilities specific to `textDocument/publishDiagnostics`.

src/Protocol/Document/Client/CodeActionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol.Client
99
{
1010
public static class CodeActionExtensions
1111
{
12-
public static Task<CommandContainer> CodeAction(this ILanguageClientDocument mediator, CodeActionParams @params)
12+
public static Task<CommandOrCodeActionContainer> CodeAction(this ILanguageClientDocument mediator, CodeActionParams @params)
1313
{
14-
return mediator.SendRequest<CodeActionParams, CommandContainer>(DocumentNames.CodeAction, @params);
14+
return mediator.SendRequest<CodeActionParams, CommandOrCodeActionContainer>(DocumentNames.CodeAction, @params);
1515
}
1616
}
1717
}

src/Protocol/Document/Server/ICodeActionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol.Server
88
{
99
using static DocumentNames;
1010
[Parallel, Method(CodeAction)]
11-
public interface ICodeActionHandler : IJsonRpcRequestHandler<CodeActionParams, CommandContainer>, IRegistration<TextDocumentRegistrationOptions>, ICapability<CodeActionCapability> { }
11+
public interface ICodeActionHandler : IJsonRpcRequestHandler<CodeActionParams, CommandOrCodeActionContainer>, IRegistration<TextDocumentRegistrationOptions>, ICapability<CodeActionCapability> { }
1212
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using OmniSharp.Extensions.JsonRpc;
2+
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
3+
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
4+
5+
// ReSharper disable CheckNamespace
6+
7+
namespace OmniSharp.Extensions.LanguageServer.Protocol.Server
8+
{
9+
using static DocumentNames;
10+
[Serial, Method(PrepareRename)]
11+
public interface IPrepareRenameHandler : IJsonRpcRequestHandler<PrepareRenameParams, RangeOrPlaceholderRange>, ICapability<RenameCapability> { }
12+
}

src/Protocol/Document/Server/IRenameHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ namespace OmniSharp.Extensions.LanguageServer.Protocol.Server
88
{
99
using static DocumentNames;
1010
[Serial, Method(Rename)]
11-
public interface IRenameHandler : IJsonRpcRequestHandler<RenameParams, WorkspaceEdit>, IRegistration<TextDocumentRegistrationOptions>, ICapability<RenameCapability> { }
11+
public interface IRenameHandler : IJsonRpcRequestHandler<RenameParams, WorkspaceEdit>, IRegistration<RenameRegistrationOptions>, ICapability<RenameCapability> { }
1212
}

src/Protocol/DocumentNames.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static class DocumentNames
2525
public const string Implementation = "textDocument/implementation";
2626
public const string References = "textDocument/references";
2727
public const string Rename = "textDocument/rename";
28+
public const string PrepareRename = "textDocument/prepareRename";
2829
public const string SignatureHelp = "textDocument/signatureHelp";
2930
public const string TypeDefinition = "textDocument/typeDefinition";
3031
public const string WillSave = "textDocument/willSave";

src/Protocol/Models/BooleanOr.cs

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -56,97 +56,4 @@ 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-
}
15259
}

0 commit comments

Comments
 (0)