mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
* Adding ICompletionExtension interface * Adding extension loading and execution logic * Fixing compilation error in VS 2017 * Using MEF for completion extension discovery * using await on GetCompletionItems * Adding an integration test for completion extension and update the completion extension interface * Update the completion extension test * Fix issues based on review comments * Remove try/cache based on review comments, fix a integration test. * More changes based on review comments * Fixing SendResult logic for completion extension loading * Only load completion extension from the assembly passed in, add more comments in the test * Adding right assert messages in the test. * More fixes based on review comments * Dropping ICompletionExtensionProvider, load assembly only if it's loaded at the first time or updated since last load. * Fix based on the latest review comments * Adding missing TSQL functions in default completion list * Update jsonrpc documentation for completion/extLoad
110 lines
3.3 KiB
C#
110 lines
3.3 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System.Diagnostics;
|
|
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
|
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion.Extension;
|
|
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts
|
|
{
|
|
public class CompletionRequest
|
|
{
|
|
public static readonly
|
|
RequestType<TextDocumentPosition, CompletionItem[]> Type =
|
|
RequestType<TextDocumentPosition, CompletionItem[]>.Create("textDocument/completion");
|
|
}
|
|
|
|
public class CompletionResolveRequest
|
|
{
|
|
public static readonly
|
|
RequestType<CompletionItem, CompletionItem> Type =
|
|
RequestType<CompletionItem, CompletionItem>.Create("completionItem/resolve");
|
|
}
|
|
|
|
public class CompletionExtLoadRequest
|
|
{
|
|
public static readonly
|
|
RequestType<CompletionExtensionParams, bool> Type =
|
|
RequestType<CompletionExtensionParams, bool>.Create("completion/extLoad");
|
|
}
|
|
|
|
public enum CompletionItemKind
|
|
{
|
|
Text = 1,
|
|
Method = 2,
|
|
Function = 3,
|
|
Constructor = 4,
|
|
Field = 5,
|
|
Variable = 6,
|
|
Class = 7,
|
|
Interface = 8,
|
|
Module = 9,
|
|
Property = 10,
|
|
Unit = 11,
|
|
Value = 12,
|
|
Enum = 13,
|
|
Keyword = 14,
|
|
Snippet = 15,
|
|
Color = 16,
|
|
File = 17,
|
|
Reference = 18
|
|
}
|
|
|
|
public class Command
|
|
{
|
|
/// <summary>
|
|
/// The identifier of the actual command handler, like `vsintellicode.completionItemSelected`.
|
|
/// </summary>
|
|
public string CommandStr { get; set; }
|
|
|
|
/// <summary>
|
|
/// Arguments that the command handler should be invoked with.
|
|
/// </summary>
|
|
public object[] Arguments { get; set; }
|
|
}
|
|
|
|
[DebuggerDisplay("Kind = {Kind.ToString()}, Label = {Label}, Detail = {Detail}")]
|
|
public class CompletionItem
|
|
{
|
|
public string Label { get; set; }
|
|
|
|
public CompletionItemKind? Kind { get; set; }
|
|
|
|
public string Detail { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the documentation string for the completion item.
|
|
/// </summary>
|
|
public string Documentation { get; set; }
|
|
|
|
public string SortText { get; set; }
|
|
|
|
public string FilterText { get; set; }
|
|
|
|
public string InsertText { get; set; }
|
|
|
|
public TextEdit TextEdit { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets a custom data field that allows the server to mark
|
|
/// each completion item with an identifier that will help correlate
|
|
/// the item to the previous completion request during a completion
|
|
/// resolve request.
|
|
/// </summary>
|
|
public object Data { get; set; }
|
|
|
|
/// <summary>
|
|
/// Exposing a command field for a completion item for passing telemetry
|
|
/// </summary>
|
|
public Command Command { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether this completion item is preselected or not
|
|
/// </summary>
|
|
public bool? Preselect { get; set; }
|
|
}
|
|
}
|