diff --git a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs
index df5ea3c9..b01b9f73 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/AutoCompleteHelper.cs
@@ -342,6 +342,14 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
}
}
+ ///
+ /// Retrieves the reserved word list
+ ///
+ public static string[] GetReservedWordList()
+ {
+ return DefaultCompletionText;
+ }
+
///
/// Gets or sets the current workspace service instance
/// Setter for internal testing purposes only
diff --git a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/Completion/SqlCompletionItem.cs b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/Completion/SqlCompletionItem.cs
index 39247f34..33108d97 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/Completion/SqlCompletionItem.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/Completion/SqlCompletionItem.cs
@@ -3,6 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using System;
using System.Globalization;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
@@ -45,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
{
InsertText = GetCompletionItemInsertName();
Label = DeclarationTitle;
- if (StartsWithBracket(TokenText))
+ if (StartsWithBracket(TokenText) || IsReservedWord(InsertText))
{
Label = WithBracket(Label);
InsertText = WithBracket(InsertText);
@@ -142,7 +143,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
int row,
int startColumn,
int endColumn)
- {
+ {
CompletionItem item = new CompletionItem()
{
Label = label,
@@ -202,5 +203,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
return text;
}
}
+
+ private bool IsReservedWord(string text)
+ {
+ string[] ReservedWords = AutoCompleteHelper.GetReservedWordList();
+ int pos = Array.IndexOf(ReservedWords, text.ToLower());
+ return pos > -1 ? true : false;
+ }
}
}