mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-25 17:24:17 -05:00
Fixed null ref exception in GetSignatureHelp (#175)
- Fixed a few places where ScriptParseInfo was being used before it was verified to be non-null - Added 1 basic test for GetSignatureHelp scenario
This commit is contained in:
committed by
Kevin Cunnane
parent
431dfa4156
commit
40c1434745
@@ -5,6 +5,7 @@
|
||||
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Microsoft.SqlTools.Test.Utility;
|
||||
using Xunit;
|
||||
@@ -125,6 +126,36 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServer
|
||||
Assert.Equal(10, fileMarkers[1].ScriptRegion.EndColumnNumber);
|
||||
Assert.Equal(3, fileMarkers[1].ScriptRegion.EndLineNumber);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSignatureHelpReturnsNullIfParseInfoNotInitialized()
|
||||
{
|
||||
// Given service doesn't have parseinfo intialized for a document
|
||||
const string docContent = "SELECT * FROM sys.objects";
|
||||
LanguageService service = TestObjects.GetTestLanguageService();
|
||||
var scriptFile = new ScriptFile();
|
||||
scriptFile.SetFileContents(docContent);
|
||||
|
||||
// When requesting SignatureHelp
|
||||
SignatureHelp signatureHelp = service.GetSignatureHelp(CreateDummyDocPosition(), scriptFile);
|
||||
|
||||
// Then null is returned as no parse info can be used to find the signature
|
||||
Assert.Null(signatureHelp);
|
||||
}
|
||||
|
||||
private TextDocumentPosition CreateDummyDocPosition()
|
||||
{
|
||||
return new TextDocumentPosition
|
||||
{
|
||||
TextDocument = new TextDocumentIdentifier { Uri = TestObjects.ScriptUri },
|
||||
Position = new Position
|
||||
{
|
||||
Line = 0,
|
||||
Character = 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user