mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Don't add parentheses to ANSI Scalar functions (#1487)
* Don't add parentheses to ANSI Scalar functions * fix test
This commit is contained in:
@@ -248,6 +248,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
{
|
||||
foreach (string word in AutoCompleteHelper.DefaultCompletionText)
|
||||
{
|
||||
if (SqlCompletionItem.AnsiScalarFunctions.Contains(word.ToUpperInvariant()))
|
||||
{
|
||||
// Skip ANSI scalar functions, those don't have parentheses
|
||||
continue;
|
||||
}
|
||||
string declarationTitle = word;
|
||||
string tokenText = "";
|
||||
SqlCompletionItem item = new SqlCompletionItem(declarationTitle, declarationType, tokenText);
|
||||
@@ -261,9 +266,16 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GlobalVariableSystemFunctionsShouldNotHaveParenthesesAdded()
|
||||
[TestCase("@@CONNECTIONS")]
|
||||
[TestCase("CURRENT_DATE")]
|
||||
[TestCase("CURRENT_TIME")]
|
||||
[TestCase("CURRENT_TIMESTAMP")]
|
||||
[TestCase("CURRENT_USER")]
|
||||
[TestCase("SESSION_USER")]
|
||||
[TestCase("SYSTEM_USER")]
|
||||
[TestCase("USER")]
|
||||
public void GlobalVariable_And_AnsiScalar_Functions_Should_Not_Have_Parentheses_Added(string declarationTitle)
|
||||
{
|
||||
string declarationTitle = "@@CONNECTIONS";
|
||||
string tokenText = "";
|
||||
SqlCompletionItem item = new SqlCompletionItem(declarationTitle, DeclarationType.BuiltInFunction, tokenText);
|
||||
CompletionItem completionItem = item.CreateCompletionItem(0, 1, 2);
|
||||
@@ -271,7 +283,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
|
||||
Assert.AreEqual(declarationTitle, completionItem.Label);
|
||||
Assert.AreEqual($"{declarationTitle}", completionItem.InsertText);
|
||||
Assert.AreEqual(declarationTitle, completionItem.Detail);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user