Enable Quick Info hover tooltips (#65)

Pushing to include in tomorrow's partner release build.  Please send me any feedback and I'll address in the next Intellisense PR.
This commit is contained in:
Karl Burtram
2016-09-26 20:11:26 -07:00
committed by GitHub
parent 8b6e15a43b
commit 3777cceb57
14 changed files with 241 additions and 182 deletions

3
.gitignore vendored
View File

@@ -15,6 +15,9 @@ project.lock.json
*.sln.docstates
*.exe
# mergetool conflict files
*.orig
# Build results
[Dd]ebug/
[Dd]ebugPublic/

View File

@@ -4,13 +4,13 @@
//
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Hosting.Contracts;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
using System.Reflection;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Hosting
@@ -63,8 +63,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
#region Member Variables
/// <summary>
/// Delegate definition for the host shutdown event
/// </summary>
/// <param name="shutdownParams"></param>
/// <param name="shutdownRequestContext"></param>
public delegate Task ShutdownCallback(object shutdownParams, RequestContext<object> shutdownRequestContext);
/// <summary>
/// Delegate definition for the host initialization event
/// </summary>
/// <param name="startupParams"></param>
/// <param name="requestContext"></param>
public delegate Task InitializeCallback(InitializeRequest startupParams, RequestContext<InitializeResult> requestContext);
private readonly List<ShutdownCallback> shutdownCallbacks;
@@ -119,8 +129,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
/// <returns></returns>
private async Task HandleInitializeRequest(InitializeRequest initializeParams, RequestContext<InitializeResult> requestContext)
{
Logger.Write(LogLevel.Verbose, "HandleInitializationRequest");
// Call all tasks that registered on the initialize request
var initializeTasks = initializeCallbacks.Select(t => t(initializeParams, requestContext));
await Task.WhenAll(initializeTasks);
@@ -136,7 +144,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
TextDocumentSync = TextDocumentSyncKind.Incremental,
DefinitionProvider = true,
ReferencesProvider = true,
DocumentHighlightProvider = true,
DocumentHighlightProvider = true,
HoverProvider = true,
CompletionProvider = new CompletionOptions
{
ResolveProvider = true,
@@ -144,7 +153,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
},
SignatureHelpProvider = new SignatureHelpOptions
{
TriggerCharacters = new string[] { " " } // TODO: Other characters here?
TriggerCharacters = new string[] { " ", "," }
}
}
});
@@ -157,7 +166,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting
object versionRequestParams,
RequestContext<string> requestContext)
{
Logger.Write(LogLevel.Verbose, "HandleVersionRequest");
await requestContext.SendResult(serviceVersion.ToString());
}

View File

@@ -12,7 +12,6 @@ using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.SqlParser;
using Microsoft.SqlServer.Management.SqlParser.Binder;
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
using Microsoft.SqlServer.Management.SqlParser.Parser;
using Microsoft.SqlServer.Management.SmoMetadataProvider;
using Microsoft.SqlTools.ServiceLayer.Connection;
@@ -49,11 +48,6 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
private ScriptParseInfo currentCompletionParseInfo;
internal bool ShouldEnableAutocomplete()
{
return true;
}
private ConnectionService connectionService = null;
/// <summary>
@@ -83,6 +77,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
private Lazy<Dictionary<string, ScriptParseInfo>> scriptParseInfoMap
= new Lazy<Dictionary<string, ScriptParseInfo>>(() => new Dictionary<string, ScriptParseInfo>());
/// <summary>
/// Gets a mapping dictionary for SQL file URIs to ScriptParseInfo objects
/// </summary>
internal Dictionary<string, ScriptParseInfo> ScriptParseInfoMap
{
get
@@ -91,6 +88,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
}
}
/// <summary>
/// Gets the singleton instance object
/// </summary>
public static LanguageService Instance
{
get { return instance.Value; }
@@ -228,7 +228,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{
completionItem = LanguageService.Instance.ResolveCompletionItem(completionItem);
await requestContext.SendResult(completionItem);
}
}
}
private static async Task HandleDefinitionRequest(
@@ -262,8 +262,21 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
private static async Task HandleHoverRequest(
TextDocumentPosition textDocumentPosition,
RequestContext<Hover> requestContext)
{
await Task.FromResult(true);
{
// check if Quick Info hover tooltips are enabled
if (WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.IsQuickInfoEnabled)
{
var scriptFile = WorkspaceService<SqlToolsSettings>.Instance.Workspace.GetFile(
textDocumentPosition.TextDocument.Uri);
var hover = LanguageService.Instance.GetHoverItem(textDocumentPosition, scriptFile);
if (hover != null)
{
await requestContext.SendResult(hover);
}
}
await requestContext.SendResult(new Hover());
}
#endregion
@@ -280,7 +293,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
ScriptFile scriptFile,
EventContext eventContext)
{
// if not in the preview window and diagnostics are enabled the run diagnostics
// if not in the preview window and diagnostics are enabled then run diagnostics
if (!IsPreviewWindow(scriptFile)
&& WorkspaceService<SqlToolsSettings>.Instance.CurrentSettings.IsDiagnositicsEnabled)
{
@@ -323,15 +336,20 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
bool oldEnableIntelliSense = oldSettings.SqlTools.EnableIntellisense;
bool? oldEnableDiagnostics = oldSettings.SqlTools.IntelliSense.EnableDiagnostics;
// Update the settings in the current
// update the current settings to reflect any changes
CurrentSettings.Update(newSettings);
// If script analysis settings have changed we need to clear & possibly update the current diagnostic records.
// update the script parse info objects if the settings have changed
foreach (var scriptInfo in this.ScriptParseInfoMap.Values)
{
scriptInfo.OnSettingsChanged(newSettings);
}
// if script analysis settings have changed we need to clear the current diagnostic markers
if (oldEnableIntelliSense != newSettings.SqlTools.EnableIntellisense
|| oldEnableDiagnostics != newSettings.SqlTools.IntelliSense.EnableDiagnostics)
{
// If the user just turned off script analysis or changed the settings path, send a diagnostics
// event to clear the analysis markers that they already have.
// if the user just turned off diagnostics then send an event to clear the error markers
if (!newSettings.IsDiagnositicsEnabled)
{
ScriptFileMarker[] emptyAnalysisDiagnostics = new ScriptFileMarker[0];
@@ -341,6 +359,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
await DiagnosticsHelper.PublishScriptDiagnostics(scriptFile, emptyAnalysisDiagnostics, eventContext);
}
}
// otherwise rerun diagnostic analysis on all opened SQL files
else
{
await this.RunScriptDiagnostics(CurrentWorkspace.GetOpenedFiles(), eventContext);
@@ -440,8 +459,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
ReliableSqlConnection sqlConn = info.SqlConnection as ReliableSqlConnection;
if (sqlConn != null)
{
ServerConnection serverConn = new ServerConnection(sqlConn.GetUnderlyingConnection());
scriptInfo.MetadataDisplayInfoProvider = new MetadataDisplayInfoProvider();
ServerConnection serverConn = new ServerConnection(sqlConn.GetUnderlyingConnection());
scriptInfo.MetadataProvider = SmoMetadataProvider.CreateConnectedProvider(serverConn);
scriptInfo.Binder = BinderProvider.CreateBinder(scriptInfo.MetadataProvider);
scriptInfo.ServerConnection = serverConn;
@@ -516,6 +534,75 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
return completionItem;
}
/// <summary>
/// Get quick info hover tooltips for the current position
/// </summary>
/// <param name="textDocumentPosition"></param>
/// <param name="scriptFile"></param>
internal Hover GetHoverItem(TextDocumentPosition textDocumentPosition, ScriptFile scriptFile)
{
int startLine = textDocumentPosition.Position.Line;
int startColumn = TextUtilities.PositionOfPrevDelimeter(
scriptFile.Contents,
textDocumentPosition.Position.Line,
textDocumentPosition.Position.Character);
int endColumn = textDocumentPosition.Position.Character;
ScriptParseInfo scriptParseInfo = GetScriptParseInfo(textDocumentPosition.TextDocument.Uri);
if (scriptParseInfo != null && scriptParseInfo.ParseResult != null)
{
if (scriptParseInfo.BuildingMetadataEvent.WaitOne(LanguageService.FindCompletionStartTimeout))
{
scriptParseInfo.BuildingMetadataEvent.Reset();
try
{
// get the current quick info text
Babel.CodeObjectQuickInfo quickInfo = Resolver.GetQuickInfo(
scriptParseInfo.ParseResult,
startLine + 1,
endColumn + 1,
scriptParseInfo.MetadataDisplayInfoProvider);
// convert from the parser format to the VS Code wire format
var markedStrings = new MarkedString[1];
if (quickInfo != null)
{
markedStrings[0] = new MarkedString()
{
Language = "SQL",
Value = quickInfo.Text
};
return new Hover()
{
Contents = markedStrings,
Range = new Range
{
Start = new Position
{
Line = startLine,
Character = startColumn
},
End = new Position
{
Line = startLine,
Character = endColumn
}
}
};
}
}
finally
{
scriptParseInfo.BuildingMetadataEvent.Set();
}
}
}
// return null if there isn't a tooltip for the current location
return null;
}
/// <summary>
/// Return the completion item list for the current text position.
/// This method does not await cache builds since it expects to return quickly
@@ -646,8 +733,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
/// <param name="eventContext"></param>
private Task RunScriptDiagnostics(ScriptFile[] filesToAnalyze, EventContext eventContext)
{
if (!CurrentSettings.SqlTools.EnableIntellisense
|| !CurrentSettings.SqlTools.IntelliSense.EnableDiagnostics.Value)
if (!CurrentSettings.IsDiagnositicsEnabled)
{
// If the user has disabled script analysis, skip it entirely
return Task.FromResult(true);
@@ -769,7 +855,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
}
else if (createIfNotExists)
{
// create a new script parse info object and initialize with the current settings
ScriptParseInfo scriptInfo = new ScriptParseInfo();
scriptInfo.OnSettingsChanged(this.CurrentSettings);
this.ScriptParseInfoMap.Add(uri, scriptInfo);
return scriptInfo;
}

View File

@@ -13,6 +13,7 @@ using Microsoft.SqlServer.Management.SqlParser.Common;
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
using Microsoft.SqlServer.Management.SqlParser.Parser;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{
@@ -27,6 +28,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
private ServerConnection serverConnection;
private Lazy<MetadataDisplayInfoProvider> metadataDisplayInfoProvider = new Lazy<MetadataDisplayInfoProvider>(() =>
{
var infoProvider = new MetadataDisplayInfoProvider();
return infoProvider;
});
/// <summary>
/// Event which tells if MetadataProvider is built fully or not
/// </summary>
@@ -141,13 +148,31 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
/// <summary>
/// Gets or sets the SMO metadata display info provider
/// </summary>
public MetadataDisplayInfoProvider MetadataDisplayInfoProvider { get; set; }
public MetadataDisplayInfoProvider MetadataDisplayInfoProvider
{
get
{
return this.metadataDisplayInfoProvider.Value;
}
}
/// <summary>
/// Gets or sets the current autocomplete suggestion list
/// </summary>
public IEnumerable<Declaration> CurrentSuggestions { get; set; }
/// <summary>
/// Update parse settings if the current configuration has changed
/// </summary>
/// <param name="settings"></param>
public void OnSettingsChanged(SqlToolsSettings settings)
{
this.MetadataDisplayInfoProvider.BuiltInCasing =
settings.SqlTools.IntelliSense.LowerCaseSuggestions.Value
? CasingStyle.Lowercase
: CasingStyle.Uppercase;
}
/// <summary>
/// Gets the database compatibility level from a server version
/// </summary>

View File

@@ -16,26 +16,22 @@ namespace Microsoft.SqlTools.ServiceLayer
/// <summary>
/// Main application class for SQL Tools API Service Host executable
/// </summary>
class Program
internal class Program
{
/// <summary>
/// Main entry point into the SQL Tools API Service Host
/// </summary>
static void Main(string[] args)
internal static void Main(string[] args)
{
// turn on Verbose logging during early development
// we need to switch to Normal when preparing for public preview
Logger.Initialize(minimumLogLevel: LogLevel.Verbose);
Logger.Write(LogLevel.Normal, "Starting SQL Tools Service Host");
const string hostName = "SQL Tools Service Host";
const string hostProfileId = "SQLToolsService";
Version hostVersion = new Version(1,0);
// set up the host details and profile paths
var hostDetails = new HostDetails(hostName, hostProfileId, hostVersion);
var profilePaths = new ProfilePaths(hostProfileId, "baseAllUsersPath", "baseCurrentUserPath");
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails, profilePaths);
var hostDetails = new HostDetails(version: new Version(1,0));
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
// Grab the instance of the service host
ServiceHost serviceHost = ServiceHost.Instance;

View File

@@ -19,13 +19,13 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
/// The default host name for SqlTools Editor Services. Used
/// if no host name is specified by the host application.
/// </summary>
public const string DefaultHostName = "SqlTools Editor Services Host";
public const string DefaultHostName = "SqlTools Service Host";
/// <summary>
/// The default host ID for SqlTools Editor Services. Used
/// for the host-specific profile path if no host ID is specified.
/// </summary>
public const string DefaultHostProfileId = "Microsoft.SqlToolsEditorServices";
public const string DefaultHostProfileId = "Microsoft.SqlToolsServiceHost";
/// <summary>
/// The default host version for SqlTools Editor Services. If
@@ -78,9 +78,9 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
/// </param>
/// <param name="version">The host application's version.</param>
public HostDetails(
string name,
string profileId,
Version version)
string name = null,
string profileId = null,
Version version = null)
{
this.Name = name ?? DefaultHostName;
this.ProfileId = profileId ?? DefaultHostProfileId;

View File

@@ -18,6 +18,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
this.EnableSuggestions = true;
this.LowerCaseSuggestions = false;
this.EnableDiagnostics = true;
this.EnableQuickInfo = true;
}
/// <summary>
@@ -36,6 +37,11 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
/// </summary>
public bool? EnableDiagnostics { 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>
@@ -47,6 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
this.EnableSuggestions = settings.EnableSuggestions;
this.LowerCaseSuggestions = settings.LowerCaseSuggestions;
this.EnableDiagnostics = settings.EnableDiagnostics;
this.EnableQuickInfo = settings.EnableQuickInfo;
}
}
}

View File

@@ -1,108 +0,0 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Microsoft.SqlTools.ServiceLayer.SqlContext
{
/// <summary>
/// Provides profile path resolution behavior relative to the name
/// of a particular SqlTools host.
/// </summary>
public class ProfilePaths
{
#region Constants
/// <summary>
/// The file name for the "all hosts" profile. Also used as the
/// suffix for the host-specific profile filenames.
/// </summary>
public const string AllHostsProfileName = "profile.ps1";
#endregion
#region Properties
/// <summary>
/// Gets the profile path for all users, all hosts.
/// </summary>
public string AllUsersAllHosts { get; private set; }
/// <summary>
/// Gets the profile path for all users, current host.
/// </summary>
public string AllUsersCurrentHost { get; private set; }
/// <summary>
/// Gets the profile path for the current user, all hosts.
/// </summary>
public string CurrentUserAllHosts { get; private set; }
/// <summary>
/// Gets the profile path for the current user and host.
/// </summary>
public string CurrentUserCurrentHost { get; private set; }
#endregion
#region Public Methods
/// <summary>
/// Creates a new instance of the ProfilePaths class.
/// </summary>
/// <param name="hostProfileId">
/// The identifier of the host used in the host-specific X_profile.ps1 filename.
/// </param>
/// <param name="baseAllUsersPath">The base path to use for constructing AllUsers profile paths.</param>
/// <param name="baseCurrentUserPath">The base path to use for constructing CurrentUser profile paths.</param>
public ProfilePaths(
string hostProfileId,
string baseAllUsersPath,
string baseCurrentUserPath)
{
this.Initialize(hostProfileId, baseAllUsersPath, baseCurrentUserPath);
}
private void Initialize(
string hostProfileId,
string baseAllUsersPath,
string baseCurrentUserPath)
{
string currentHostProfileName =
string.Format(
"{0}_{1}",
hostProfileId,
AllHostsProfileName);
this.AllUsersCurrentHost = Path.Combine(baseAllUsersPath, currentHostProfileName);
this.CurrentUserCurrentHost = Path.Combine(baseCurrentUserPath, currentHostProfileName);
this.AllUsersAllHosts = Path.Combine(baseAllUsersPath, AllHostsProfileName);
this.CurrentUserAllHosts = Path.Combine(baseCurrentUserPath, AllHostsProfileName);
}
/// <summary>
/// Gets the list of profile paths that exist on the filesystem.
/// </summary>
/// <returns>An IEnumerable of profile path strings to be loaded.</returns>
public IEnumerable<string> GetLoadableProfilePaths()
{
var profilePaths =
new string[]
{
this.AllUsersAllHosts,
this.AllUsersCurrentHost,
this.CurrentUserAllHosts,
this.CurrentUserCurrentHost
};
return profilePaths.Where(p => File.Exists(p));
}
#endregion
}
}

View File

@@ -20,9 +20,14 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
get; private set;
}
public SqlToolsContext(HostDetails hostDetails, ProfilePaths profilePaths)
/// <summary>
/// Initalizes the SQL Tools context instance
/// </summary>
/// <param name="hostDetails"></param>
public SqlToolsContext(HostDetails hostDetails)
{
this.SqlToolsVersion = hostDetails.Version;
}
}
}

View File

@@ -75,6 +75,18 @@ namespace Microsoft.SqlTools.ServiceLayer.SqlContext
&& this.SqlTools.IntelliSense.EnableSuggestions.Value;
}
}
/// <summary>
/// Gets a flag determining if quick info is enabled
/// </summary>
public bool IsQuickInfoEnabled
{
get
{
return this.SqlTools.EnableIntellisense
&& this.SqlTools.IntelliSense.EnableQuickInfo.Value;
}
}
}
/// <summary>

View File

@@ -45,6 +45,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
{
private static LogWriter logWriter;
private static bool isEnabled;
private static bool isInitialized = false;
/// <summary>
/// Initializes the Logger for the current session.
/// </summary>
@@ -56,8 +60,19 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
/// </param>
public static void Initialize(
string logFilePath = "sqltools",
LogLevel minimumLogLevel = LogLevel.Normal)
LogLevel minimumLogLevel = LogLevel.Normal,
bool isEnabled = true)
{
Logger.isEnabled = isEnabled;
// return if the logger is not enabled or already initialized
if (!Logger.isEnabled || Logger.isInitialized)
{
return;
}
Logger.isInitialized = true;
// get a unique number to prevent conflicts of two process launching at the same time
int uniqueId;
try
@@ -89,6 +104,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
minimumLogLevel,
fullFileName,
true);
Logger.Write(LogLevel.Normal, "Initializing SQL Tools Service Host logger");
}
/// <summary>
@@ -116,7 +133,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
[CallerMemberName] string callerName = null,
[CallerFilePath] string callerSourceFile = null,
[CallerLineNumber] int callerLineNumber = 0)
{
{
// return if the logger is not enabled or not initialized
if (!Logger.isEnabled || !Logger.isInitialized)
{
return;
}
if (logWriter != null)
{
logWriter.Write(

View File

@@ -7,18 +7,8 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.SmoMetadataProvider;
using Microsoft.SqlServer.Management.SqlParser;
using Microsoft.SqlServer.Management.SqlParser.Binder;
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
using Microsoft.SqlServer.Management.SqlParser.MetadataProvider;
using Microsoft.SqlServer.Management.SqlParser.Parser;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Credentials;
@@ -154,17 +144,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
#region "General Language Service tests"
/// <summary>
/// Check that autocomplete is enabled by default
/// </summary>
[Fact]
public void CheckAutocompleteEnabledByDefault()
{
// get test service
LanguageService service = TestObjects.GetTestLanguageService();
Assert.True(service.ShouldEnableAutocomplete());
}
/// <summary>
/// Test the service initialization code path and verify nothing throws
/// </summary>
@@ -260,8 +239,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
// set up the host details and profile paths
var hostDetails = new HostDetails(hostName, hostProfileId, hostVersion);
var profilePaths = new ProfilePaths(hostProfileId, "baseAllUsersPath", "baseCurrentUserPath");
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails, profilePaths);
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
// Grab the instance of the service host
Hosting.ServiceHost serviceHost = Hosting.ServiceHost.Instance;
@@ -282,9 +260,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
private Hosting.ServiceHost GetTestServiceHost()
{
// set up the host details and profile paths
var hostDetails = new HostDetails("Test Service Host", "SQLToolsService", new Version(1,0));
var profilePaths = new ProfilePaths("SQLToolsService", "baseAllUsersPath", "baseCurrentUserPath");
SqlToolsContext context = new SqlToolsContext(hostDetails, profilePaths);
var hostDetails = new HostDetails("Test Service Host", "SQLToolsService", new Version(1,0));
SqlToolsContext context = new SqlToolsContext(hostDetails);
// Grab the instance of the service host
Hosting.ServiceHost host = Hosting.ServiceHost.Instance;

View File

@@ -257,8 +257,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.QueryExecution
new ScriptParseInfo
{
Binder = binder,
MetadataProvider = metadataProvider,
MetadataDisplayInfoProvider = displayInfoProvider
MetadataProvider = metadataProvider
});
scriptFile = new ScriptFile {ClientFilePath = textDocument.TextDocument.Uri};

View File

@@ -25,6 +25,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
Assert.True(sqlToolsSettings.SqlTools.EnableIntellisense);
Assert.True(sqlToolsSettings.SqlTools.IntelliSense.EnableDiagnostics);
Assert.True(sqlToolsSettings.SqlTools.IntelliSense.EnableSuggestions);
Assert.True(sqlToolsSettings.SqlTools.IntelliSense.EnableQuickInfo);
Assert.False(sqlToolsSettings.SqlTools.IntelliSense.LowerCaseSuggestions);
}
@@ -52,7 +53,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
}
/// <summary>
/// Validate that the IsDiagnositicsEnabled flag behavior
/// Validate that the IsSuggestionsEnabled flag behavior
/// </summary>
[Fact]
public void ValidateIsSuggestionsEnabled()
@@ -73,5 +74,28 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
sqlToolsSettings.SqlTools.IntelliSense.EnableSuggestions = false;
Assert.False(sqlToolsSettings.IsSuggestionsEnabled);
}
/// <summary>
/// Validate that the IsQuickInfoEnabled flag behavior
/// </summary>
[Fact]
public void ValidateIsQuickInfoEnabled()
{
var sqlToolsSettings = new SqlToolsSettings();
// quick info is enabled if IntelliSense and quick info flags are set
sqlToolsSettings.SqlTools.EnableIntellisense = true;
sqlToolsSettings.SqlTools.IntelliSense.EnableQuickInfo = true;
Assert.True(sqlToolsSettings.IsQuickInfoEnabled);
// quick info is disabled if either IntelliSense and quick info flags is not set
sqlToolsSettings.SqlTools.EnableIntellisense = false;
sqlToolsSettings.SqlTools.IntelliSense.EnableQuickInfo = true;
Assert.False(sqlToolsSettings.IsQuickInfoEnabled);
sqlToolsSettings.SqlTools.EnableIntellisense = true;
sqlToolsSettings.SqlTools.IntelliSense.EnableQuickInfo = false;
Assert.False(sqlToolsSettings.IsQuickInfoEnabled);
}
}
}