diff --git a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs index cf48aba0..796871bd 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Connection/ConnectionService.cs @@ -1008,7 +1008,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection } /// - /// Invokes the fianl on-disconnect activities if the provided DisconnectParams represents the default + /// Invokes the final on-disconnect activities if the provided DisconnectParams represents the default /// connection or is null - representing that all connections are being disconnected. /// private void InvokeOnDisconnectionActivities(ConnectionInfo connectionInfo) diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs index 58a9bf68..12f0cbf0 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/LanguageServer/PeekDefinitionTests.cs @@ -700,111 +700,114 @@ GO"; /// /// Get Definition for a object with no definition. Expect a error result /// - // [Fact] - // public async void GetDefinitionFromChildrenAndParents() - // { - // string queryString = "select * from master.sys.objects"; + [Fact] + public async void GetDefinitionFromChildrenAndParents() + { + string queryString = "select * from master.sys.objects"; - // // place the cursor on every token + // place the cursor on every token - // //cursor on objects - // TextDocumentPosition objectDocument = CreateTextDocPositionWithCursor(26, OwnerUri); + //cursor on objects + TextDocumentPosition objectDocument = CreateTextDocPositionWithCursor(26, OwnerUri); - // //cursor on sys - // TextDocumentPosition sysDocument = CreateTextDocPositionWithCursor(22, OwnerUri); + //cursor on sys + TextDocumentPosition sysDocument = CreateTextDocPositionWithCursor(22, OwnerUri); - // //cursor on master - // TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(15, OwnerUri); + //cursor on master + TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(15, OwnerUri); - // LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo(); - // ScriptFile scriptFile = connectionResult.ScriptFile; - // ConnectionInfo connInfo = connectionResult.ConnectionInfo; + LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo(); + ScriptFile scriptFile = connectionResult.ScriptFile; + ConnectionInfo connInfo = connectionResult.ConnectionInfo; + connInfo.RemoveAllConnections(); + var bindingQueue = new ConnectedBindingQueue(); + bindingQueue.AddConnectionContext(connInfo); + scriptFile.Contents = queryString; - // var bindingQueue = new ConnectedBindingQueue(); - // bindingQueue.AddConnectionContext(connInfo); - // scriptFile.Contents = queryString; + var service = new LanguageService(); + service.BindingQueue = bindingQueue; + await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo); + Thread.Sleep(2000); - // var service = new LanguageService(); - // service.BindingQueue = bindingQueue; - // await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo); - // Thread.Sleep(2000); + ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true }; + scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo); + service.ScriptParseInfoMap.Add(OwnerUri, scriptInfo); - // ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true }; - // scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo); - // service.ScriptParseInfoMap.Add(OwnerUri, scriptInfo); + // When I call the language service + var objectResult = service.GetDefinition(objectDocument, scriptFile, connInfo); + var sysResult = service.GetDefinition(sysDocument, scriptFile, connInfo); + var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo); - // // When I call the language service - // var objectResult = service.GetDefinition(objectDocument, scriptFile, connInfo); - // var sysResult = service.GetDefinition(sysDocument, scriptFile, connInfo); - // var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo); + // Then I expect the results to be non-null + Assert.NotNull(objectResult); + Assert.NotNull(sysResult); + Assert.NotNull(masterResult); - // // Then I expect the results to be non-null - // Assert.NotNull(objectResult); - // Assert.NotNull(sysResult); - // Assert.NotNull(masterResult); + // And I expect the all results to be the same + Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations)); + Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations)); - // // And I expect the all results to be the same - // Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations)); - // Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations)); + Cleanup(objectResult.Locations); + Cleanup(sysResult.Locations); + Cleanup(masterResult.Locations); + service.ScriptParseInfoMap.Remove(OwnerUri); + connInfo.RemoveAllConnections(); + } - // Cleanup(objectResult.Locations); - // Cleanup(sysResult.Locations); - // Cleanup(masterResult.Locations); - // service.ScriptParseInfoMap.Remove(OwnerUri); - // } + [Fact] + public async void GetDefinitionFromProcedures() + { - // [Fact] - // public async void GetDefinitionFromProcedures() - // { + string queryString = "EXEC master.dbo.sp_MSrepl_startup"; - // string queryString = "EXEC master.dbo.sp_MSrepl_startup"; + // place the cursor on every token - // // place the cursor on every token + //cursor on objects + TextDocumentPosition fnDocument = CreateTextDocPositionWithCursor(30, TestUri); - // //cursor on objects - // TextDocumentPosition fnDocument = CreateTextDocPositionWithCursor(30, TestUri); + //cursor on sys + TextDocumentPosition dboDocument = CreateTextDocPositionWithCursor(14, TestUri); - // //cursor on sys - // TextDocumentPosition dboDocument = CreateTextDocPositionWithCursor(14, TestUri); + //cursor on master + TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(10, TestUri); - // //cursor on master - // TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(10, TestUri); + LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo(); + ScriptFile scriptFile = connectionResult.ScriptFile; + ConnectionInfo connInfo = connectionResult.ConnectionInfo; + connInfo.RemoveAllConnections(); + var bindingQueue = new ConnectedBindingQueue(); + bindingQueue.AddConnectionContext(connInfo); + scriptFile.Contents = queryString; - // LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo(); - // ScriptFile scriptFile = connectionResult.ScriptFile; - // ConnectionInfo connInfo = connectionResult.ConnectionInfo; - // var bindingQueue = new ConnectedBindingQueue(); - // bindingQueue.AddConnectionContext(connInfo); - // scriptFile.Contents = queryString; + var service = new LanguageService(); + service.BindingQueue = bindingQueue; + await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo); + Thread.Sleep(2000); - // var service = new LanguageService(); - // service.BindingQueue = bindingQueue; - // await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo); - // Thread.Sleep(2000); + ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true }; + scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo); + service.ScriptParseInfoMap.Add(TestUri, scriptInfo); - // ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true }; - // scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo); - // service.ScriptParseInfoMap.Add(TestUri, scriptInfo); + // When I call the language service + var fnResult = service.GetDefinition(fnDocument, scriptFile, connInfo); + var sysResult = service.GetDefinition(dboDocument, scriptFile, connInfo); + var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo); - // // When I call the language service - // var fnResult = service.GetDefinition(fnDocument, scriptFile, connInfo); - // var sysResult = service.GetDefinition(dboDocument, scriptFile, connInfo); - // var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo); + // Then I expect the results to be non-null + Assert.NotNull(fnResult); + Assert.NotNull(sysResult); + Assert.NotNull(masterResult); - // // Then I expect the results to be non-null - // Assert.NotNull(fnResult); - // Assert.NotNull(sysResult); - // Assert.NotNull(masterResult); + // And I expect the all results to be the same + Assert.True(CompareLocations(fnResult.Locations, sysResult.Locations)); + Assert.True(CompareLocations(fnResult.Locations, masterResult.Locations)); - // // And I expect the all results to be the same - // Assert.True(CompareLocations(fnResult.Locations, sysResult.Locations)); - // Assert.True(CompareLocations(fnResult.Locations, masterResult.Locations)); - - // Cleanup(fnResult.Locations); - // Cleanup(sysResult.Locations); - // Cleanup(masterResult.Locations); - // service.ScriptParseInfoMap.Remove(TestUri); - // } + Cleanup(fnResult.Locations); + Cleanup(sysResult.Locations); + Cleanup(masterResult.Locations); + service.ScriptParseInfoMap.Remove(TestUri); + connInfo.RemoveAllConnections(); + } /// @@ -863,4 +866,4 @@ GO"; return textDocPos; } } -} +} \ No newline at end of file