mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -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>
|
/// <summary>
|
||||||
/// Gets or sets the current workspace service instance
|
/// Gets or sets the current workspace service instance
|
||||||
/// Setter for internal testing purposes only
|
/// 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.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
using Microsoft.SqlServer.Management.SqlParser.Intellisense;
|
||||||
@@ -45,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
|
|||||||
{
|
{
|
||||||
InsertText = GetCompletionItemInsertName();
|
InsertText = GetCompletionItemInsertName();
|
||||||
Label = DeclarationTitle;
|
Label = DeclarationTitle;
|
||||||
if (StartsWithBracket(TokenText))
|
if (StartsWithBracket(TokenText) || IsReservedWord(InsertText))
|
||||||
{
|
{
|
||||||
Label = WithBracket(Label);
|
Label = WithBracket(Label);
|
||||||
InsertText = WithBracket(InsertText);
|
InsertText = WithBracket(InsertText);
|
||||||
@@ -202,5 +203,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices.Completion
|
|||||||
return text;
|
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