mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-30 17:24:37 -05:00
Add LanguageFlavorNotification handling and refactor LanguageService (#375)
* Add LanguageFlavorNotification handling and refactor LanguageService - Added new notification handler for language flavor changed - Refactored the LanguageService so that it no longer relies on so many intertwined static calls, which meant it was impossible to test without modifying the static instance. This will help with test reliability in the future, and prep for replacing the instance with a service provider. * Skip if not an MSSQL doc and add test * Handle definition requests * Fix diagnostics handling
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
{
|
||||
@@ -46,6 +49,29 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send the diagnostic results back to the host application
|
||||
/// </summary>
|
||||
/// <param name="scriptFile"></param>
|
||||
/// <param name="semanticMarkers"></param>
|
||||
/// <param name="eventContext"></param>
|
||||
internal static async Task ClearScriptDiagnostics(
|
||||
string uri,
|
||||
EventContext eventContext)
|
||||
{
|
||||
Validate.IsNotNullOrEmptyString(nameof(uri), uri);
|
||||
Validate.IsNotNull(nameof(eventContext), eventContext);
|
||||
// Always send syntax and semantic errors. We want to
|
||||
// make sure no out-of-date markers are being displayed.
|
||||
await eventContext.SendEvent(
|
||||
PublishDiagnosticsNotification.Type,
|
||||
new PublishDiagnosticsNotification
|
||||
{
|
||||
Uri = uri,
|
||||
Diagnostics = Array.Empty<Diagnostic>()
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a ScriptFileMarker to a Diagnostic that is Language Service compatible
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user