mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-24 17:24:14 -05:00
Feature/delete peek scripts (#174)
* Delete temp script folder * Delete folder and refactor code * Add unit tests * create folder per workspace * Refactor and move creation to FileUtils * Separate multiple assignment
This commit is contained in:
@@ -21,6 +21,7 @@ using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
@@ -216,6 +217,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
serviceHost.RegisterShutdownTask(async (shutdownParams, shutdownRequestContext) =>
|
||||
{
|
||||
Logger.Write(LogLevel.Verbose, "Shutting down language service");
|
||||
DeletePeekDefinitionScripts();
|
||||
await Task.FromResult(0);
|
||||
});
|
||||
|
||||
@@ -1232,5 +1234,14 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal void DeletePeekDefinitionScripts()
|
||||
{
|
||||
// Delete temp folder created to store peek definition scripts
|
||||
if (FileUtils.SafeDirectoryExists(FileUtils.PeekDefinitionTempFolder))
|
||||
{
|
||||
FileUtils.SafeDirectoryDelete(FileUtils.PeekDefinitionTempFolder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,9 @@ using System.Data.SqlClient;
|
||||
using Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.Common;
|
||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
|
||||
@@ -47,9 +48,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
this.serverConnection = serverConnection;
|
||||
this.connectionInfo = connInfo;
|
||||
|
||||
DirectoryInfo tempScriptDirectory = Directory.CreateDirectory(Path.GetTempPath() + "mssql_definition");
|
||||
this.tempPath = tempScriptDirectory.FullName;
|
||||
this.tempPath = FileUtils.GetPeekDefinitionTempFolder();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user