Removing a lot of redundant async/await wrappers (#1486)

* Removing a lot of redundant async/await wrappers

* Removing kusto changes
This commit is contained in:
Benjamin Russell
2022-06-05 10:26:21 -05:00
committed by GitHub
parent 88a762014d
commit 97a106c575
14 changed files with 899 additions and 1001 deletions

View File

@@ -110,9 +110,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
};
}
private async Task<TextEdit[]> FormatRangeAndReturnEdits(DocumentRangeFormattingParams docFormatParams)
private Task<TextEdit[]> FormatRangeAndReturnEdits(DocumentRangeFormattingParams docFormatParams)
{
return await Task.Factory.StartNew(() =>
return Task.Run(() =>
{
if (ShouldSkipFormatting(docFormatParams))
{
@@ -123,7 +123,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
ScriptFile scriptFile = GetFile(docFormatParams);
if (scriptFile == null)
{
return new TextEdit[0];
return Array.Empty<TextEdit>();
}
TextEdit textEdit = new TextEdit { Range = range };
string text = scriptFile.GetTextInRange(range.ToBufferRange());
@@ -142,9 +142,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
return (LanguageService != null && LanguageService.ShouldSkipNonMssqlFile(docFormatParams.TextDocument.Uri));
}
private async Task<TextEdit[]> FormatAndReturnEdits(DocumentFormattingParams docFormatParams)
{
return await Task.Factory.StartNew(() =>
private Task<TextEdit[]> FormatAndReturnEdits(DocumentFormattingParams docFormatParams)
{
return Task.Factory.StartNew(() =>
{
if (ShouldSkipFormatting(docFormatParams))
{
@@ -155,7 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
if (scriptFile == null
|| scriptFile.FileLines.Count == 0)
{
return new TextEdit[0];
return Array.Empty<TextEdit>();
}
TextEdit textEdit = PrepareEdit(scriptFile);
string text = scriptFile.Contents;
@@ -205,12 +205,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Formatter
if (settings.PlaceSelectStatementReferencesOnNewLine.HasValue) { options.PlaceEachReferenceOnNewLineInQueryStatements = settings.PlaceSelectStatementReferencesOnNewLine.Value; }
if (settings.UseBracketForIdentifiers.HasValue) { options.EncloseIdentifiersInSquareBrackets = settings.UseBracketForIdentifiers.Value; }
options.DatatypeCasing = settings.DatatypeCasing;
options.KeywordCasing = settings.KeywordCasing;
}
}
private ScriptFile GetFile(DocumentFormattingParams docFormatParams)
{
return WorkspaceService.Workspace.GetFile(docFormatParams.TextDocument.Uri);