mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-26 01:25:42 -05:00
Support "SQL" settings in addition to MSSQL (#398)
* Support "SQL" settings in addition to MSSQL - Handles having 2 separate configuration definitions and merging / treating them as 1 throughout the app - If a settings group such as Intellisense is defined on mssql, it will override any generic SQL properties - Retains backwards compatibility with existing settings.
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
@@ -12,19 +16,17 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
/// </summary>
|
||||
public class SqlToolsSettings
|
||||
{
|
||||
private SqlToolsSettingsValues sqlTools = null;
|
||||
private ISqlToolsSettingsValues sqlTools = null;
|
||||
private SqlToolsSettingsValues mssqlTools = null;
|
||||
private SqlToolsSettingsValues allSqlTools = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the underlying settings value object
|
||||
/// </summary>
|
||||
[JsonProperty("mssql")]
|
||||
public SqlToolsSettingsValues SqlTools
|
||||
public ISqlToolsSettingsValues SqlTools
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.sqlTools == null)
|
||||
{
|
||||
this.sqlTools = new SqlToolsSettingsValues();
|
||||
this.sqlTools = new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
|
||||
}
|
||||
return this.sqlTools;
|
||||
}
|
||||
@@ -34,6 +36,46 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the underlying settings value object
|
||||
/// </summary>
|
||||
[JsonProperty("mssql")]
|
||||
public SqlToolsSettingsValues MssqlTools
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.mssqlTools == null)
|
||||
{
|
||||
this.mssqlTools = new SqlToolsSettingsValues(false);
|
||||
}
|
||||
return this.mssqlTools;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.mssqlTools = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the underlying settings value object
|
||||
/// </summary>
|
||||
[JsonProperty("sql")]
|
||||
public SqlToolsSettingsValues AllSqlTools
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.allSqlTools == null)
|
||||
{
|
||||
this.allSqlTools = new SqlToolsSettingsValues(false);
|
||||
}
|
||||
return this.allSqlTools;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.sqlTools = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Query excution settings forwarding property
|
||||
/// </summary>
|
||||
@@ -50,7 +92,6 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
{
|
||||
if (settings != null)
|
||||
{
|
||||
this.SqlTools.IntelliSense.EnableIntellisense = settings.SqlTools.IntelliSense.EnableIntellisense;
|
||||
this.SqlTools.IntelliSense.Update(settings.SqlTools.IntelliSense);
|
||||
}
|
||||
}
|
||||
@@ -102,43 +143,4 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class that is used to serialize and deserialize SQL Tools settings
|
||||
/// </summary>
|
||||
public class SqlToolsSettingsValues
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the Sql Tools settings values
|
||||
/// </summary>
|
||||
public SqlToolsSettingsValues()
|
||||
{
|
||||
IntelliSense = new IntelliSenseSettings();
|
||||
QueryExecutionSettings = new QueryExecutionSettings();
|
||||
Format = new FormatterSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the detailed IntelliSense settings
|
||||
/// </summary>
|
||||
public IntelliSenseSettings IntelliSense { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the query execution settings
|
||||
/// </summary>
|
||||
[JsonProperty("query")]
|
||||
public QueryExecutionSettings QueryExecutionSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the formatter settings
|
||||
/// </summary>
|
||||
[JsonProperty("format")]
|
||||
public FormatterSettings Format { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the formatter settings
|
||||
/// </summary>
|
||||
[JsonProperty("objectExplorer")]
|
||||
public ObjectExplorerSettings ObjectExplorer { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user