mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-22 17:24:07 -05:00
Added initial tests for the connection manager's intellisense cache
This commit is contained in:
@@ -80,13 +80,36 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ConnectionService connectionService = null;
|
||||
|
||||
/// <summary>
|
||||
/// Internal for testing purposes only
|
||||
/// </summary>
|
||||
internal ConnectionService ConnectionServiceInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
if(connectionService == null)
|
||||
{
|
||||
connectionService = ConnectionService.Instance;
|
||||
}
|
||||
return connectionService;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
connectionService = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeService(ServiceHost serviceHost)
|
||||
{
|
||||
// Register a callback for when a connection is created
|
||||
ConnectionService.Instance.RegisterOnConnectionTask(UpdateAutoCompleteCache);
|
||||
ConnectionServiceInstance.RegisterOnConnectionTask(UpdateAutoCompleteCache);
|
||||
|
||||
// Register a callback for when a connection is closed
|
||||
ConnectionService.Instance.RegisterOnDisconnectTask(RemoveAutoCompleteCacheUriReference);
|
||||
ConnectionServiceInstance.RegisterOnDisconnectTask(RemoveAutoCompleteCacheUriReference);
|
||||
}
|
||||
|
||||
private async Task UpdateAutoCompleteCache(ConnectionInfo connectionInfo)
|
||||
@@ -97,6 +120,14 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intellisense cache count access for testing.
|
||||
/// </summary>
|
||||
public int GetCacheCount()
|
||||
{
|
||||
return caches.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a reference to an autocomplete cache from a URI. If
|
||||
/// it is the last URI connected to a particular connection,
|
||||
@@ -157,7 +188,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
// that are not backed by a SQL connection
|
||||
ConnectionInfo info;
|
||||
IntellisenseCache cache;
|
||||
if (ConnectionService.Instance.TryFindConnection(textDocumentPosition.Uri, out info)
|
||||
if (ConnectionServiceInstance.TryFindConnection(textDocumentPosition.Uri, out info)
|
||||
&& caches.TryGetValue((ConnectionSummary)info.ConnectionDetails, out cache))
|
||||
{
|
||||
return cache.GetAutoCompleteItems(textDocumentPosition).ToArray();
|
||||
|
||||
Reference in New Issue
Block a user