mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Added notification for when language service is done updating after connect (#146)
* Added notification for when language service is done updating after connect * Addressing feedback * Added unit test
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parameters sent back with an IntelliSense ready event
|
||||||
|
/// </summary>
|
||||||
|
public class IntelliSenseReadyParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// URI identifying the text document
|
||||||
|
/// </summary>
|
||||||
|
public string OwnerUri { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event sent when the language service is finished updating after a connection
|
||||||
|
/// </summary>
|
||||||
|
public class IntelliSenseReadyNotification
|
||||||
|
{
|
||||||
|
public static readonly
|
||||||
|
EventType<IntelliSenseReadyParams> Type =
|
||||||
|
EventType<IntelliSenseReadyParams>.Create("textDocument/intelliSenseReady");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -562,6 +562,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
|||||||
}
|
}
|
||||||
|
|
||||||
AutoCompleteHelper.PrepopulateCommonMetadata(info, scriptInfo, this.BindingQueue);
|
AutoCompleteHelper.PrepopulateCommonMetadata(info, scriptInfo, this.BindingQueue);
|
||||||
|
|
||||||
|
// Send a notification to signal that autocomplete is ready
|
||||||
|
ServiceHost.Instance.SendEvent(IntelliSenseReadyNotification.Type, new IntelliSenseReadyParams() {OwnerUri = info.OwnerUri});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
|
|||||||
|
|
||||||
// Setup events to queue for testing
|
// Setup events to queue for testing
|
||||||
this.QueueEventsForType(ConnectionCompleteNotification.Type);
|
this.QueueEventsForType(ConnectionCompleteNotification.Type);
|
||||||
|
this.QueueEventsForType(IntelliSenseReadyNotification.Type);
|
||||||
this.QueueEventsForType(QueryExecuteCompleteEvent.Type);
|
this.QueueEventsForType(QueryExecuteCompleteEvent.Type);
|
||||||
this.QueueEventsForType(PublishDiagnosticsNotification.Type);
|
this.QueueEventsForType(PublishDiagnosticsNotification.Type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,5 +258,26 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task NotificationIsSentAfterOnConnectionAutoCompleteUpdate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Connect
|
||||||
|
string ownerUri = System.IO.Path.GetTempFileName();
|
||||||
|
await Connect(ownerUri, ConnectionTestUtils.LocalhostConnection);
|
||||||
|
|
||||||
|
// An event signalling that IntelliSense is ready should be sent shortly thereafter
|
||||||
|
var readyParams = await Driver.WaitForEvent(IntelliSenseReadyNotification.Type, 30000);
|
||||||
|
Assert.NotNull(readyParams);
|
||||||
|
Assert.Equal(ownerUri, readyParams.OwnerUri);
|
||||||
|
|
||||||
|
await Disconnect(ownerUri);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WaitForExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user