reserved words with brackets in autocomplete

This commit is contained in:
Aditya Bist
2016-12-15 11:12:36 -08:00
parent 9c6162282a
commit 6e746efad0
2 changed files with 18 additions and 2 deletions

View File

@@ -342,6 +342,14 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
}
}
/// <summary>
/// Retrieves the reserved word list
/// </summary>
public static string[] GetReservedWordList()
{
return DefaultCompletionText;
}
/// <summary>
/// Gets or sets the current workspace service instance
/// Setter for internal testing purposes only

View File

@@ -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;
}
}
}