mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-04 17:24:56 -05:00
reserved words with brackets in autocomplete
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user