Move unused forked code to external directory (#1192)

* Move unused forked code to external directory

* Fix SLN build errors

* Add back resource provider core since it's referenced by main resource provider project

* Update PackageProjects step of pipeline
This commit is contained in:
Karl Burtram
2021-04-16 15:33:35 -07:00
committed by GitHub
parent dc6555a823
commit ccf95aed77
229 changed files with 10058 additions and 10124 deletions

View File

@@ -0,0 +1,102 @@
//
// 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.Linq;
using Microsoft.SqlTools.Hosting.Utility;
using Newtonsoft.Json;
namespace Microsoft.SqlTools.CoreServices.SqlContext
{
/// <summary>
/// Handles backwards compatibility of settings by checking for settings in a priority list. If a settings
/// group such as Intellisense is defined on a serialized setting it's used in the order of mssql, then sql, then
/// falls back to a default value.
/// </summary>
public class CompoundToolsSettingsValues: ISqlToolsSettingsValues
{
private List<ISqlToolsSettingsValues> priorityList = new List<ISqlToolsSettingsValues>();
private SqlToolsSettingsValues defaultValues;
public CompoundToolsSettingsValues(ISqlToolsSettingsValues mssql, ISqlToolsSettingsValues all)
{
Validate.IsNotNull(nameof(mssql), mssql);
Validate.IsNotNull(nameof(all), all);
priorityList.Add(mssql);
priorityList.Add(all);
// Always add in a fallback which has default values to be used.
defaultValues = new SqlToolsSettingsValues(createDefaults: true);
priorityList.Add(defaultValues);
}
private T GetSettingOrDefault<T>(Func<ISqlToolsSettingsValues, T> lookup)
where T : new()
{
T value = priorityList.Select( (settings) => lookup(settings)).Where(val => val != null).FirstOrDefault();
return value != null ? value : new T();
}
/// <summary>
/// Gets or sets the detailed IntelliSense settings
/// </summary>
public IntelliSenseSettings IntelliSense
{
get
{
return GetSettingOrDefault((settings) => settings.IntelliSense);
}
set
{
priorityList[0].IntelliSense = value;
}
}
// /// <summary>
// /// Gets or sets the query execution settings
// /// </summary>
// public QueryExecutionSettings QueryExecutionSettings
// {
// get
// {
// return GetSettingOrDefault((settings) => settings.QueryExecutionSettings);
// }
// set
// {
// priorityList[0].QueryExecutionSettings = value;
// }
// }
// /// <summary>
// /// Gets or sets the formatter settings
// /// </summary>
// public FormatterSettings Format
// {
// get
// {
// return GetSettingOrDefault((settings) => settings.Format);
// }
// set
// {
// priorityList[0].Format = value;
// }
// }
/// <summary>
/// Gets or sets the object explorer settings
/// </summary>
public ObjectExplorerSettings ObjectExplorer
{
get
{
return GetSettingOrDefault((settings) => settings.ObjectExplorer);
}
set
{
priorityList[0].ObjectExplorer = value;
}
}
}
}

View File

@@ -0,0 +1,33 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.CoreServices.SqlContext
{
/// <summary>
/// Defines the common settings used by the tools service
/// </summary>
public interface ISqlToolsSettingsValues
{
/// <summary>
/// Intellisense specific settings
/// </summary>
IntelliSenseSettings IntelliSense { get; set; }
/// <summary>
/// Query execution specific settings
/// </summary>
// QueryExecutionSettings QueryExecutionSettings { get; set; }
// /// <summary>
// /// Formatter settings
// /// </summary>
// FormatterSettings Format { get; set; }
/// <summary>
/// Object Explorer specific settings
/// </summary>
ObjectExplorerSettings ObjectExplorer { get; set; }
}
}

View File

@@ -0,0 +1,68 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.CoreServices.SqlContext
{
/// <summary>
/// Class for serialization and deserialization of IntelliSense settings
/// </summary>
public class IntelliSenseSettings
{
/// <summary>
/// Initialize the IntelliSense settings defaults
/// </summary>
public IntelliSenseSettings()
{
this.EnableIntellisense = true;
this.EnableSuggestions = true;
this.LowerCaseSuggestions = false;
this.EnableErrorChecking = true;
this.EnableQuickInfo = true;
}
/// <summary>
/// Gets or sets a flag determining if IntelliSense is enabled
/// </summary>
/// <returns></returns>
public bool EnableIntellisense { get; set; }
/// <summary>
/// Gets or sets a flag determining if suggestions are enabled
/// </summary>
/// <returns></returns>
public bool? EnableSuggestions { get; set; }
/// <summary>
/// Gets or sets a flag determining if built-in suggestions should be lowercase
/// </summary>
public bool? LowerCaseSuggestions { get; set; }
/// <summary>
/// Gets or sets a flag determining if diagnostics are enabled
/// </summary>
public bool? EnableErrorChecking { get; set; }
/// <summary>
/// Gets or sets a flag determining if quick info is enabled
/// </summary>
public bool? EnableQuickInfo { get; set; }
/// <summary>
/// Update the Intellisense settings
/// </summary>
/// <param name="settings"></param>
public void Update(IntelliSenseSettings settings)
{
if (settings != null)
{
this.EnableIntellisense = settings.EnableIntellisense;
this.EnableSuggestions = settings.EnableSuggestions;
this.LowerCaseSuggestions = settings.LowerCaseSuggestions;
this.EnableErrorChecking = settings.EnableErrorChecking;
this.EnableQuickInfo = settings.EnableQuickInfo;
}
}
}
}

View File

@@ -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.
//
namespace Microsoft.SqlTools.CoreServices.SqlContext
{
/// <summary>
/// Contract for receiving object explorer settings as part of workspace settings
/// </summary>
public class ObjectExplorerSettings
{
public static int DefaultCreateSessionTimeout = 45;
public static int DefaultExpandTimeout = 45;
public ObjectExplorerSettings()
{
CreateSessionTimeout = DefaultCreateSessionTimeout;
ExpandTimeout = DefaultExpandTimeout;
}
/// <summary>
/// Number of seconds to wait before fail create session request with timeout error
/// </summary>
public int CreateSessionTimeout { get; set; }
/// <summary>
/// Number of seconds to wait before fail expand request with timeout error
/// </summary>
public int ExpandTimeout { get; set; }
}
}

View File

@@ -0,0 +1,145 @@
//
// 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.Linq;
using Newtonsoft.Json;
namespace Microsoft.SqlTools.CoreServices.SqlContext
{
/// <summary>
/// Class for serialization and deserialization of the settings the SQL Tools Service needs.
/// </summary>
public class SqlToolsSettings
{
private ISqlToolsSettingsValues sqlTools = null;
private SqlToolsSettingsValues mssqlTools = null;
private SqlToolsSettingsValues allSqlTools = null;
public ISqlToolsSettingsValues SqlTools
{
get
{
if (this.sqlTools == null)
{
this.sqlTools = new CompoundToolsSettingsValues(MssqlTools, AllSqlTools);
}
return this.sqlTools;
}
set
{
this.sqlTools = value;
}
}
/// <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>
// public QueryExecutionSettings QueryExecutionSettings
// {
// get { return this.SqlTools.QueryExecutionSettings; }
// }
/// <summary>
/// Updates the extension settings
/// </summary>
/// <param name="settings"></param>
public void Update(SqlToolsSettings settings)
{
if (settings != null)
{
this.SqlTools.IntelliSense.Update(settings.SqlTools.IntelliSense);
}
}
/// <summary>
/// Gets a flag determining if diagnostics are enabled
/// </summary>
public bool IsDiagnosticsEnabled
{
get
{
return this.SqlTools.IntelliSense.EnableIntellisense
&& this.SqlTools.IntelliSense.EnableErrorChecking.Value;
}
}
/// <summary>
/// Gets a flag determining if suggestions are enabled
/// </summary>
public bool IsSuggestionsEnabled
{
get
{
return this.SqlTools.IntelliSense.EnableIntellisense
&& this.SqlTools.IntelliSense.EnableSuggestions.Value;
}
}
/// <summary>
/// Gets a flag determining if quick info is enabled
/// </summary>
public bool IsQuickInfoEnabled
{
get
{
return this.SqlTools.IntelliSense.EnableIntellisense
&& this.SqlTools.IntelliSense.EnableQuickInfo.Value;
}
}
/// <summary>
/// Gets a flag determining if IntelliSense is enabled
/// </summary>
public bool IsIntelliSenseEnabled
{
get
{
return this.SqlTools.IntelliSense.EnableIntellisense;
}
}
}
}

View File

@@ -0,0 +1,54 @@
//
// 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.Linq;
using Newtonsoft.Json;
namespace Microsoft.SqlTools.CoreServices.SqlContext
{
/// <summary>
/// Class that is used to serialize and deserialize SQL Tools settings
/// </summary>
public class SqlToolsSettingsValues : ISqlToolsSettingsValues
{
/// <summary>
/// Initializes the Sql Tools settings values
/// </summary>
public SqlToolsSettingsValues(bool createDefaults = true)
{
if (createDefaults)
{
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; }
}
}