Skip to content

Commit cd0c4e6

Browse files
committed
Client methods that take file-system paths now delegate to overloads that take document URIs (#43).
1 parent 50f4e87 commit cd0c4e6

File tree

3 files changed

+11
-39
lines changed

3 files changed

+11
-39
lines changed

src/Client/Clients/TextDocumentClient.Completions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using OmniSharp.Extensions.LanguageServer.Models;
2+
using OmniSharp.Extensions.LanguageServerProtocol.Client.Utilities;
23
using System;
34
using System.Threading;
45
using System.Threading.Tasks;
@@ -33,7 +34,9 @@ public partial class TextDocumentClient
3334
if (String.IsNullOrWhiteSpace(filePath))
3435
throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(filePath)}.", nameof(filePath));
3536

36-
return PositionalRequest<CompletionList>("textDocument/completion", filePath, line, column, cancellationToken);
37+
Uri documentUri = DocumentUri.FromFileSystemPath(filePath);
38+
39+
return Completions(documentUri, line, column, cancellationToken);
3740
}
3841

3942
/// <summary>

src/Client/Clients/TextDocumentClient.Hover.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Threading;
55
using System.Threading.Tasks;
6+
using OmniSharp.Extensions.LanguageServerProtocol.Client.Utilities;
67

78
namespace OmniSharp.Extensions.LanguageServerProtocol.Client.Clients
89
{
@@ -31,7 +32,12 @@ public partial class TextDocumentClient
3132
/// </returns>
3233
public Task<Hover> Hover(string filePath, int line, int column, CancellationToken cancellationToken = default(CancellationToken))
3334
{
34-
return PositionalRequest<Hover>("textDocument/hover", filePath, line, column, cancellationToken);
35+
if (String.IsNullOrWhiteSpace(filePath))
36+
throw new ArgumentException("Argument cannot be null, empty, or entirely composed of whitespace: 'filePath'.", nameof(filePath));
37+
38+
Uri documentUri = DocumentUri.FromFileSystemPath(filePath);
39+
40+
return Hover(documentUri, line, column, cancellationToken);
3541
}
3642

3743
/// <summary>

src/Client/Clients/TextDocumentClient.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,6 @@ public TextDocumentClient(LanguageClient client)
3131
/// </summary>
3232
public LanguageClient Client { get; }
3333

34-
/// <summary>
35-
/// Make a request to the server for the specified document position.
36-
/// </summary>
37-
/// <typeparam name="TResponse">
38-
/// The response payload type.
39-
/// </typeparam>
40-
/// <param name="method">
41-
/// The name of the operation to invoke.
42-
/// </param>
43-
/// <param name="filePath">
44-
/// The file-system path of the target document.
45-
/// </param>
46-
/// <param name="line">
47-
/// The target line numer (0-based).
48-
/// </param>
49-
/// <param name="column">
50-
/// The target column (0-based).
51-
/// </param>
52-
/// <param name="cancellationToken">
53-
/// A cancellation token that can be used to cancel the request.
54-
/// </param>
55-
/// <returns>
56-
/// A <see cref="Task{TResult}"/> representing the request.
57-
/// </returns>
58-
Task<TResponse> PositionalRequest<TResponse>(string method, string filePath, int line, int column, CancellationToken cancellationToken)
59-
{
60-
if (String.IsNullOrWhiteSpace(method))
61-
throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(method)}.", nameof(method));
62-
63-
if (String.IsNullOrWhiteSpace(filePath))
64-
throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(filePath)}.", nameof(filePath));
65-
66-
Uri documentUri = DocumentUri.FromFileSystemPath(filePath);
67-
68-
return PositionalRequest<TResponse>(method, documentUri, line, column, cancellationToken);
69-
}
70-
7134
/// <summary>
7235
/// Make a request to the server for the specified document position.
7336
/// </summary>

0 commit comments

Comments
 (0)