|
| 1 | +using System; |
| 2 | +using System.Threading; |
| 3 | +using System.Threading.Tasks; |
| 4 | +using OmniSharp.Extensions.LanguageServer.Client.Utilities; |
| 5 | +using OmniSharp.Extensions.LanguageServer.Protocol; |
| 6 | +using OmniSharp.Extensions.LanguageServer.Protocol.Models; |
| 7 | + |
| 8 | +namespace OmniSharp.Extensions.LanguageServer.Client.Clients |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Client for the LSP Text Document API. |
| 12 | + /// </summary> |
| 13 | + public partial class TextDocumentClient |
| 14 | + { |
| 15 | + /// <summary> |
| 16 | + /// Request definition at the specified document position. |
| 17 | + /// </summary> |
| 18 | + /// <param name="filePath"> |
| 19 | + /// The full file-system path of the text document. |
| 20 | + /// </param> |
| 21 | + /// <param name="line"> |
| 22 | + /// The target line (0-based). |
| 23 | + /// </param> |
| 24 | + /// <param name="column"> |
| 25 | + /// The target column (0-based). |
| 26 | + /// </param> |
| 27 | + /// <param name="cancellationToken"> |
| 28 | + /// An optional <see cref="CancellationToken"/> that can be used to cancel the request. |
| 29 | + /// </param> |
| 30 | + /// <returns> |
| 31 | + /// A <see cref="Task{TResult}"/> that resolves to the completions or <c>null</c> if no completions are available at the specified position. |
| 32 | + /// </returns> |
| 33 | + public Task<LocationOrLocationLinks> Definition(string filePath, int line, int column, CancellationToken cancellationToken = default(CancellationToken)) |
| 34 | + { |
| 35 | + if (string.IsNullOrWhiteSpace(filePath)) |
| 36 | + throw new ArgumentException($"Argument cannot be null, empty, or entirely composed of whitespace: {nameof(filePath)}.", nameof(filePath)); |
| 37 | + |
| 38 | + var documentUri = DocumentUri.FromFileSystemPath(filePath); |
| 39 | + |
| 40 | + return Definition(documentUri, line, column, cancellationToken); |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Request definition at the specified document position. |
| 45 | + /// </summary> |
| 46 | + /// <param name="documentUri"> |
| 47 | + /// The document URI. |
| 48 | + /// </param> |
| 49 | + /// <param name="line"> |
| 50 | + /// The target line (0-based). |
| 51 | + /// </param> |
| 52 | + /// <param name="column"> |
| 53 | + /// The target column (0-based). |
| 54 | + /// </param> |
| 55 | + /// <param name="cancellationToken"> |
| 56 | + /// An optional <see cref="CancellationToken"/> that can be used to cancel the request. |
| 57 | + /// </param> |
| 58 | + /// <returns> |
| 59 | + /// A <see cref="Task{TResult}"/> that resolves to the completions or <c>null</c> if no completions are available at the specified position. |
| 60 | + /// </returns> |
| 61 | + public Task<LocationOrLocationLinks> Definition(Uri documentUri, int line, int column, CancellationToken cancellationToken = default(CancellationToken)) |
| 62 | + { |
| 63 | + return PositionalRequest<LocationOrLocationLinks>(DocumentNames.Definition, documentUri, line, column, cancellationToken); |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments