Merge pull request #191 from Microsoft/customerIssue/escapeReservedWordsAutocomplete

reserved words with brackets in autocomplete
This commit is contained in:
Aditya Bist
2016-12-19 11:25:18 -08:00
committed by GitHub
3 changed files with 330 additions and 3 deletions

View File

@@ -332,7 +332,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
/// <summary>
/// Gets a static instance of an empty completion list to avoid
// unneeded memory allocations
/// unneeded memory allocations
/// </summary>
internal static CompletionItem[] EmptyCompletionList
{
@@ -342,6 +342,16 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
}
}
/// <summary>
/// Checks whether a given word is in the reserved
/// word list or not
/// </summary>
internal static bool IsReservedWord(string text)
{
int pos = Array.IndexOf(DefaultCompletionText, text.ToLower());
return pos > -1;
}
/// <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) || AutoCompleteHelper.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,