mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-15 10:58:31 -05:00
Adding completion extension loading and execution logic (#833)
* 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
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion.Extension
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public class CompletionExtensionParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Absolute path for the assembly containing the completion extension
|
||||
/// </summary>
|
||||
public string AssemblyPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type name for the completion extension
|
||||
/// </summary>
|
||||
public string TypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Property bag for initializing the completion extension
|
||||
/// </summary>
|
||||
public Dictionary<string, object> Properties { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion.Extension
|
||||
{
|
||||
public interface ICompletionExtension : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique name for the extension
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Method for initializing the extension, this is called once when the extension is loaded
|
||||
/// </summary>
|
||||
/// <param name="properties">Parameters needed by the extension</param>
|
||||
/// <param name="cancelToken">Cancellation token used to indicate that the initialization should be cancelled</param>
|
||||
/// <returns></returns>
|
||||
Task Initialize(IReadOnlyDictionary<string, object> properties, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Handles the completion request, returning the modified CompletionItemList if used
|
||||
/// </summary>
|
||||
/// <param name="connInfo">Connection information for the completion session</param>
|
||||
/// <param name="scriptDocumentInfo">Script parsing information</param>
|
||||
/// <param name="completions">Current completion list</param>
|
||||
/// <param name="cancelToken">Token used to indicate that the completion request should be cancelled</param>
|
||||
/// <returns></returns>
|
||||
Task<CompletionItem[]> HandleCompletionAsync(ConnectionInfo connInfo, ScriptDocumentInfo scriptDocumentInfo, CompletionItem[] completions, CancellationToken cancelToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user