Fix to not add parens for global variable built in functions (#940)

This commit is contained in:
Charles Gagnon
2020-04-07 09:56:24 -07:00
committed by GitHub
parent 1cb0b98148
commit 7d37de218a
2 changed files with 19 additions and 2 deletions

View File

@@ -74,8 +74,11 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
case DeclarationType.BuiltInFunction:
case DeclarationType.ScalarValuedFunction:
case DeclarationType.TableValuedFunction:
// Functions we add on the () at the end since they'll always have them
InsertText = WithDelimitedIdentifier(FunctionPostfix, DeclarationTitle);
// Add ()'s for all functions except global variable system functions (which all start with @@)
if (!DeclarationTitle.StartsWith("@@"))
{
InsertText = WithDelimitedIdentifier(FunctionPostfix, DeclarationTitle);
}
break;
}
}

View File

@@ -263,6 +263,20 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.LanguageServer
}
[Fact]
public void GlobalVariableSystemFunctionsShouldNotHaveParenthesesAdded()
{
string declarationTitle = "@@CONNECTIONS";
string tokenText = "";
SqlCompletionItem item = new SqlCompletionItem(declarationTitle, DeclarationType.BuiltInFunction, tokenText);
CompletionItem completionItem = item.CreateCompletionItem(0, 1, 2);
Assert.Equal(declarationTitle, completionItem.Label);
Assert.Equal($"{declarationTitle}", completionItem.InsertText);
Assert.Equal(declarationTitle, completionItem.Detail);
}
[Theory]
[InlineData(DeclarationType.Server)]
[InlineData(DeclarationType.Database)]