mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Ensure test file is deleted and fix test project path (#843)
* Ensure test file is always deleted * Fix up project path
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// 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.ComponentModel.Composition;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion.Extension;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.Test.CompletionExtension
|
||||
{
|
||||
|
||||
[Export(typeof(ICompletionExtension))]
|
||||
public class CompletionExt : ICompletionExtension
|
||||
{
|
||||
public string Name => "CompletionExt";
|
||||
|
||||
private string modelPath;
|
||||
|
||||
public CompletionExt()
|
||||
{
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
async Task<CompletionItem[]> ICompletionExtension.HandleCompletionAsync(ConnectionInfo connInfo, ScriptDocumentInfo scriptDocumentInfo, CompletionItem[] completions, CancellationToken token)
|
||||
{
|
||||
if (completions == null || completions == null || completions.Length == 0)
|
||||
{
|
||||
return completions;
|
||||
}
|
||||
return await Run(completions, token);
|
||||
}
|
||||
|
||||
async Task ICompletionExtension.Initialize(IReadOnlyDictionary<string, object> properties, CancellationToken token)
|
||||
{
|
||||
modelPath = (string)properties["modelPath"];
|
||||
await LoadModel(token).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
private async Task LoadModel(CancellationToken token)
|
||||
{
|
||||
//loading model logic here
|
||||
await Task.Delay(2000).ConfigureAwait(false); //for testing
|
||||
token.ThrowIfCancellationRequested();
|
||||
Console.WriteLine("Model loaded from: " + modelPath);
|
||||
}
|
||||
|
||||
private async Task<CompletionItem[]> Run(CompletionItem[] completions, CancellationToken token)
|
||||
{
|
||||
Console.WriteLine("Enter ExecuteAsync");
|
||||
|
||||
var sortedItems = completions.OrderBy(item => item.SortText);
|
||||
sortedItems.First().Preselect = true;
|
||||
foreach(var item in sortedItems)
|
||||
{
|
||||
item.Command = new Command
|
||||
{
|
||||
CommandStr = "vsintellicode.completionItemSelected",
|
||||
Arguments = new object[] { new Dictionary<string, string> { { "IsCommit", "True" } } }
|
||||
};
|
||||
}
|
||||
|
||||
//code to augment the default completion list
|
||||
await Task.Delay(20); // for testing
|
||||
token.ThrowIfCancellationRequested();
|
||||
Console.WriteLine("Exit ExecuteAsync");
|
||||
return sortedItems.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="../../Common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<DebugType>portable</DebugType>
|
||||
<AssemblyName>Microsoft.SqlTools.Test.CompletionExtension</AssemblyName>
|
||||
<PackageId>Microsoft.SqlTools.Test.CompletionExtension</PackageId>
|
||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user