Don't add parentheses to ANSI Scalar functions (#1487)

* Don't add parentheses to ANSI Scalar functions

* fix test
This commit is contained in:
Charles Gagnon
2022-05-09 18:57:14 -07:00
committed by GitHub
parent 99d0959291
commit 70be8f5ef5
2 changed files with 27 additions and 4 deletions

View File

@@ -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]