Skip to content

Commit 29f8809

Browse files
committed
Add some overloads in Hover and SignatureHelp.
Add demo code for SignatureHelp.
1 parent 63dfe0d commit 29f8809

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

DemoLanguageServer/Services/InitializaionService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public InitializeResult Initialize(int processId, Uri rootUri, ClientCapabilitie
1919
return new InitializeResult(new ServerCapabilities
2020
{
2121
HoverProvider = true,
22+
SignatureHelpProvider = new SignatureHelpOptions("()"),
2223
CompletionProvider = new CompletionOptions(true, "."),
2324
TextDocumentSync = new TextDocumentSyncOptions
2425
{

DemoLanguageServer/Services/TextDocumentService.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public async Task<Hover> Hover(TextDocumentIdentifier textDocument, Position pos
2222
return new Hover {Contents = "Test _hover_ @" + position + "\n\n" + textDocument};
2323
}
2424

25+
[JsonRpcMethod]
26+
public SignatureHelp SignatureHelp(TextDocumentIdentifier textDocument, Position position)
27+
{
28+
return new SignatureHelp(new List<SignatureInformation>
29+
{
30+
new SignatureInformation("**Function1**", "Documentation1"),
31+
new SignatureInformation("**Function2** <strong>test</strong>", "Documentation2"),
32+
});
33+
}
34+
2535
[JsonRpcMethod(IsNotification = true)]
2636
public async Task DidOpen(TextDocumentItem textDocument)
2737
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
11

2+
using Newtonsoft.Json;
3+
24
namespace LanguageServer.VsCode.Contracts
35
{
46
/// <summary>
57
/// Represents the result of a hover request - a formatted tooltip.
68
/// </summary>
9+
[JsonObject(MemberSerialization.OptIn)]
710
public class Hover
811
{
12+
[JsonConstructor]
13+
public Hover()
14+
{
15+
16+
}
17+
18+
public Hover(string contents) : this(contents, new Range())
19+
{
20+
}
21+
22+
public Hover(string contents, Range range)
23+
{
24+
Contents = contents;
25+
Range = range;
26+
}
27+
928
/// <summary>
1029
/// A Markdown string to display in the Hover.
1130
/// </summary>
31+
[JsonProperty]
1232
public string Contents { get; set; }
1333

1434
/// <summary>
1535
/// The range to which this Hover applies.
1636
/// </summary>
37+
[JsonProperty]
1738
public Range Range { get; set; }
1839
}
1940
}

LanguageServer.VsCode/Contracts/SignatureHelp.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public SignatureHelp()
2020

2121
}
2222

23+
public SignatureHelp(IList<SignatureInformation> signatures) : this(signatures, 0, 0)
24+
{
25+
}
26+
2327
public SignatureHelp(IList<SignatureInformation> signatures, int activeSignature, int activeParameter)
2428
{
2529
Signatures = signatures;
@@ -73,6 +77,14 @@ public SignatureInformation()
7377

7478
}
7579

80+
public SignatureInformation(string label) : this(label, null, null)
81+
{
82+
}
83+
84+
public SignatureInformation(string label, string documentation) : this(label, documentation, null)
85+
{
86+
}
87+
7688
public SignatureInformation(string label, string documentation, IList<ParameterInformation> parameters)
7789
{
7890
Label = label;

LanguageServer.VsCode/LanguageServer.VsCode.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PackageId>CXuesong.LanguageServer.VsCode</PackageId>
66
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
77
<Authors>CXuesong</Authors>
8-
<Version>0.1.1-int1</Version>
8+
<Version>0.1.1</Version>
99
<Company />
1010
<Description>A .NET Language Server library for VSCode.</Description>
1111
<Copyright>Copyright 2017 CXuesong</Copyright>
@@ -15,8 +15,8 @@
1515
<RepositoryUrl>https://github.com/CXuesong/LanguageServer.NET</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
1717
<PackageReleaseNotes>See https://github.com/CXuesong/LanguageServer.NET/releases .</PackageReleaseNotes>
18-
<AssemblyVersion>0.1.1.1</AssemblyVersion>
19-
<FileVersion>0.1.1.1</FileVersion>
18+
<AssemblyVersion>0.1.1.2</AssemblyVersion>
19+
<FileVersion>0.1.1.2</FileVersion>
2020
</PropertyGroup>
2121

2222
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

0 commit comments

Comments
 (0)