Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch liveshare to use LSP pull diagnostics and cleanup server name usages #57596

Merged
merged 7 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ internal abstract partial class AbstractInProcLanguageClient : ILanguageClient,
private readonly IThreadingContext _threadingContext;
private readonly ILspLoggerFactory _lspLoggerFactory;

/// <summary>
/// Legacy support for LSP push diagnostics.
/// </summary>
private readonly IDiagnosticService? _diagnosticService;
private readonly IAsynchronousOperationListenerProvider _listenerProvider;
private readonly AbstractRequestDispatcherFactory _requestDispatcherFactory;
private readonly LspWorkspaceRegistrationService _lspWorkspaceRegistrationService;
Expand All @@ -46,7 +42,12 @@ internal abstract partial class AbstractInProcLanguageClient : ILanguageClient,
/// <summary>
/// Gets the name of the language client (displayed to the user).
/// </summary>
public abstract string Name { get; }
public string Name => ServerKind.ToUserVisibleString();

/// <summary>
/// An enum representing this server instance.
/// </summary>
public abstract WellKnownLspServerKinds ServerKind { get; }

/// <summary>
/// The set of languages that this LSP server supports and can return results for.
Expand Down Expand Up @@ -82,7 +83,6 @@ public event AsyncEventHandler<EventArgs>? StopAsync { add { } remove { } }
public AbstractInProcLanguageClient(
AbstractRequestDispatcherFactory requestDispatcherFactory,
IGlobalOptionService globalOptions,
IDiagnosticService? diagnosticService,
IAsynchronousOperationListenerProvider listenerProvider,
LspWorkspaceRegistrationService lspWorkspaceRegistrationService,
ILspLoggerFactory lspLoggerFactory,
Expand All @@ -91,7 +91,6 @@ public AbstractInProcLanguageClient(
{
_requestDispatcherFactory = requestDispatcherFactory;
GlobalOptions = globalOptions;
_diagnosticService = diagnosticService;
_listenerProvider = listenerProvider;
_lspWorkspaceRegistrationService = lspWorkspaceRegistrationService;
_diagnosticsClientName = diagnosticsClientName;
Expand Down Expand Up @@ -207,11 +206,9 @@ public ILanguageServerTarget Create(
GlobalOptions,
_listenerProvider,
logger,
_diagnosticService,
SupportedLanguages,
clientName: _diagnosticsClientName,
userVisibleServerName: this.Name,
telemetryServerTypeName: this.GetType().Name);
ServerKind);
}

public abstract ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ public AlwaysActivateInProcLanguageClient(
DefaultCapabilitiesProvider defaultCapabilitiesProvider,
ILspLoggerFactory lspLoggerFactory,
IThreadingContext threadingContext)
: base(csharpVBRequestDispatcherFactory, globalOptions, diagnosticService: null, listenerProvider, lspWorkspaceRegistrationService, lspLoggerFactory, threadingContext, diagnosticsClientName: null)
: base(csharpVBRequestDispatcherFactory, globalOptions, listenerProvider, lspWorkspaceRegistrationService, lspLoggerFactory, threadingContext, diagnosticsClientName: null)
{
_defaultCapabilitiesProvider = defaultCapabilitiesProvider;
}

protected override ImmutableArray<string> SupportedLanguages => ProtocolConstants.RoslynLspLanguages;

public override string Name => CSharpVisualBasicLanguageServerFactory.UserVisibleName;

public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
{
var serverCapabilities = new VSInternalServerCapabilities();
Expand Down Expand Up @@ -106,5 +104,7 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa
/// as the failure is not catastrophic.
/// </summary>
public override bool ShowNotificationOnInitializeFailed => GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode);

public override WellKnownLspServerKinds ServerKind => WellKnownLspServerKinds.AlwaysActiveLspServer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public CodeActionsHandlerProvider(
_threadingContext = threadingContext;
}

public override ImmutableArray<IRequestHandler> CreateRequestHandlers()
public override ImmutableArray<IRequestHandler> CreateRequestHandlers(WellKnownLspServerKinds serverKind)
{
var codeActionsCache = new CodeActionsCache();
return ImmutableArray.Create<IRequestHandler>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public CompletionHandlerProvider(
_completionProviders = completionProviders;
}

public override ImmutableArray<IRequestHandler> CreateRequestHandlers()
public override ImmutableArray<IRequestHandler> CreateRequestHandlers(WellKnownLspServerKinds serverKind)
{
var completionListCache = new CompletionListCache();
return ImmutableArray.Create<IRequestHandler>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@ internal class LiveShareInProcLanguageClient : AbstractInProcLanguageClient
public LiveShareInProcLanguageClient(
RequestDispatcherFactory csharpVBRequestDispatcherFactory,
IGlobalOptionService globalOptions,
IDiagnosticService diagnosticService,
IAsynchronousOperationListenerProvider listenerProvider,
LspWorkspaceRegistrationService lspWorkspaceRegistrationService,
DefaultCapabilitiesProvider defaultCapabilitiesProvider,
ILspLoggerFactory lspLoggerFactory,
IThreadingContext threadingContext)
: base(csharpVBRequestDispatcherFactory, globalOptions, diagnosticService, listenerProvider, lspWorkspaceRegistrationService, lspLoggerFactory, threadingContext, diagnosticsClientName: null)
: base(csharpVBRequestDispatcherFactory, globalOptions, listenerProvider, lspWorkspaceRegistrationService, lspLoggerFactory, threadingContext, diagnosticsClientName: null)
{
_defaultCapabilitiesProvider = defaultCapabilitiesProvider;
}

protected override ImmutableArray<string> SupportedLanguages => ProtocolConstants.RoslynLspLanguages;

public override string Name => "Live Share C#/Visual Basic Language Server Client";

public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
{
var isLspEditorEnabled = GlobalOptions.GetOption(LspOptions.LspEditorFeatureFlag);
Expand Down Expand Up @@ -76,12 +73,23 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa
defaultCapabilities.SemanticTokensOptions = null;
}

// When the lsp pull diagnostics feature flag is enabled we do not advertise pull diagnostics capabilities from here
// as the AlwaysActivateInProcLanguageClient will provide pull diagnostics both locally and remote.
var isPullDiagnosticsEnabled = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode);
if (!isPullDiagnosticsEnabled)
{
// Pull diagnostics isn't enabled, let the live share server provide pull diagnostics.
((VSInternalServerCapabilities)defaultCapabilities).SupportsDiagnosticRequests = true;
}

return defaultCapabilities;
}

/// <summary>
/// Failures are catastrophic as liveshare guests will not have language features without this server.
/// </summary>
public override bool ShowNotificationOnInitializeFailed => true;

public override WellKnownLspServerKinds ServerKind => WellKnownLspServerKinds.LiveShareLspServer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,17 @@ internal class RazorInProcLanguageClient : AbstractInProcLanguageClient

protected override ImmutableArray<string> SupportedLanguages => ProtocolConstants.RoslynLspLanguages;

/// <summary>
/// Gets the name of the language client (displayed in yellow bars).
/// </summary>
public override string Name => "Razor C# Language Server Client";

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public RazorInProcLanguageClient(
RequestDispatcherFactory csharpVBRequestDispatcherFactory,
IGlobalOptionService globalOptions,
IDiagnosticService diagnosticService,
IAsynchronousOperationListenerProvider listenerProvider,
LspWorkspaceRegistrationService lspWorkspaceRegistrationService,
DefaultCapabilitiesProvider defaultCapabilitiesProvider,
IThreadingContext threadingContext,
ILspLoggerFactory lspLoggerFactory)
: base(csharpVBRequestDispatcherFactory, globalOptions, diagnosticService, listenerProvider, lspWorkspaceRegistrationService, lspLoggerFactory, threadingContext, ClientName)
: base(csharpVBRequestDispatcherFactory, globalOptions, listenerProvider, lspWorkspaceRegistrationService, lspLoggerFactory, threadingContext, ClientName)
{
_defaultCapabilitiesProvider = defaultCapabilitiesProvider;
}
Expand All @@ -73,7 +67,7 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa

if (capabilities is VSInternalServerCapabilities vsServerCapabilities)
{
vsServerCapabilities.SupportsDiagnosticRequests = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.RazorDiagnosticMode);
vsServerCapabilities.SupportsDiagnosticRequests = true;
return vsServerCapabilities;
}

Expand All @@ -84,5 +78,7 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa
/// If the razor server is activated then any failures are catastrophic as no razor c# features will work.
/// </summary>
public override bool ShowNotificationOnInitializeFailed => true;

public override WellKnownLspServerKinds ServerKind => WellKnownLspServerKinds.RazorLspServer;
}
}
Loading