mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 09:35:37 -05:00
Stubbing out query execution settings
Adding a setting for batch separator. Very small refactor to WorkspaceService that will create the basic settings upon construction of the object.
This commit is contained in:
@@ -10,6 +10,8 @@ using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
{
|
||||
@@ -60,6 +62,8 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
private readonly Lazy<ConcurrentDictionary<string, Query>> queries =
|
||||
new Lazy<ConcurrentDictionary<string, Query>>(() => new ConcurrentDictionary<string, Query>());
|
||||
|
||||
private SqlToolsSettings Settings { get { return WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings; } }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -81,6 +85,13 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
Dispose();
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
|
||||
// Register a handler for when the configuration changes
|
||||
WorkspaceService<SqlToolsSettings>.Instance.RegisterConfigChangeCallback((oldSettings, newSettings, eventContext) =>
|
||||
{
|
||||
Settings.QueryExecutionSettings.Update(newSettings.QueryExecutionSettings);
|
||||
return Task.FromResult(0);
|
||||
});
|
||||
}
|
||||
|
||||
#region Request Handlers
|
||||
@@ -281,8 +292,11 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the current settings for executing the query with
|
||||
QueryExecutionSettings settings = WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.QueryExecutionSettings;
|
||||
|
||||
// Launch the query and respond with successfully launching it
|
||||
Task executeTask = query.Execute();
|
||||
Task executeTask = query.Execute(/*settings*/);
|
||||
await requestContext.SendResult(new QueryExecuteResult
|
||||
{
|
||||
Messages = null
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
public class QueryExecutionSettings
|
||||
{
|
||||
private const string DefaultBatchSeparator = "GO";
|
||||
|
||||
private string batchSeparator;
|
||||
|
||||
public string BatchSeparator
|
||||
{
|
||||
get { return batchSeparator ?? DefaultBatchSeparator; }
|
||||
set { batchSeparator = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the current settings with the new settings
|
||||
/// </summary>
|
||||
/// <param name="newSettings">The new settings</param>
|
||||
public void Update(QueryExecutionSettings newSettings)
|
||||
{
|
||||
BatchSeparator = newSettings.BatchSeparator;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
this.ScriptAnalysis.Update(settings.ScriptAnalysis, workspaceRootPath);
|
||||
}
|
||||
}
|
||||
|
||||
public QueryExecutionSettings QueryExecutionSettings { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
ConfigChangeCallbacks = new List<ConfigChangeCallback>();
|
||||
TextDocChangeCallbacks = new List<TextDocChangeCallback>();
|
||||
TextDocOpenCallbacks = new List<TextDocOpenCallback>();
|
||||
|
||||
CurrentSettings = new TConfig();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -101,7 +103,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
{
|
||||
// Create a workspace that will handle state for the session
|
||||
Workspace = new Workspace();
|
||||
CurrentSettings = new TConfig();
|
||||
|
||||
// Register the handlers for when changes to the workspae occur
|
||||
serviceHost.SetEventHandler(DidChangeTextDocumentNotification.Type, HandleDidChangeTextDocumentNotification);
|
||||
|
||||
Reference in New Issue
Block a user