|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Text; |
| 4 | +using Newtonsoft.Json; |
| 5 | + |
| 6 | +namespace LanguageServer.VsCode.Contracts |
| 7 | +{ |
| 8 | + |
| 9 | + /// <summary> |
| 10 | + /// Contains additional information about the context in which a completion request is triggered. |
| 11 | + /// </summary> |
| 12 | + /// <remarks> |
| 13 | + /// When used to implement <c>textDocument/completion</c>, this instance |
| 14 | + /// is only available if the client specifies to send this using |
| 15 | + /// <c>ClientCapabilities.TextDocument.Completion.ContextSupport == true</c>. |
| 16 | + /// </remarks> |
| 17 | + [JsonObject(MemberSerialization.OptIn)] |
| 18 | + public class CompletionContext |
| 19 | + { |
| 20 | + |
| 21 | + /// <summary> |
| 22 | + /// Initializes a new <see cref="CompletionContext"/> |
| 23 | + /// with <see cref="TriggerKind"/> set to <see cref="CompletionTriggerKind.Invoked"/>. |
| 24 | + /// </summary> |
| 25 | + [JsonConstructor] |
| 26 | + public CompletionContext() |
| 27 | + { |
| 28 | + TriggerKind = CompletionTriggerKind.Invoked; |
| 29 | + } |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Initializes a new <see cref="CompletionContext"/> |
| 33 | + /// with <see cref="TriggerKind"/> set to <see cref="CompletionTriggerKind.TriggerCharacter"/>. |
| 34 | + /// </summary> |
| 35 | + /// <param name="triggerCharacter">The character that triggers the completion.</param> |
| 36 | + public CompletionContext(char triggerCharacter) |
| 37 | + { |
| 38 | + TriggerKind = CompletionTriggerKind.TriggerCharacter; |
| 39 | + TriggerCharacter = triggerCharacter; |
| 40 | + } |
| 41 | + |
| 42 | + /// <summary>How the completion was triggered.</summary> |
| 43 | + [JsonProperty] |
| 44 | + public CompletionTriggerKind TriggerKind { get; set; } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// The trigger character (a single character) that has trigger code complete. |
| 48 | + /// Is undefined if <see cref="TriggerKind"/> is not <see cref="CompletionTriggerKind.TriggerCharacter"/>. |
| 49 | + /// </summary> |
| 50 | + [JsonProperty] |
| 51 | + public char TriggerCharacter { get; set; } |
| 52 | + |
| 53 | + } |
| 54 | + |
| 55 | + /// <summary>How a completion was triggered.</summary> |
| 56 | + public enum CompletionTriggerKind |
| 57 | + { |
| 58 | + /// <summary> |
| 59 | + /// Completion was triggered by typing an identifier (24x7 code complete), |
| 60 | + /// manual invocation (e.g Ctrl+Space) or via API. |
| 61 | + /// </summary> |
| 62 | + Invoked = 1, |
| 63 | + /// <summary> |
| 64 | + /// Completion was triggered by a trigger character specified by |
| 65 | + /// the <see cref="CompletionRegistrationOptions.TriggerCharacters"/> property |
| 66 | + /// of the <see cref="CompletionRegistrationOptions"/>. |
| 67 | + /// </summary> |
| 68 | + TriggerCharacter = 2, |
| 69 | + } |
| 70 | +} |
0 commit comments