/// <summary> /// Create a remote code action wrapping a command /// </summary> public RoslynRemoteCodeAction(Document document, LSP.Command command, string title, ILanguageServerClient lspClient) { _document = document ?? throw new ArgumentNullException(nameof(document)); _lspClient = lspClient ?? throw new ArgumentNullException(nameof(lspClient)); _command = command ?? throw new ArgumentNullException(nameof(command)); _title = title; _codeActionCommand = null; _codeActionWorkspaceEdit = null; }
public static Task UnregisterCapability(this ILanguageServerClient mediator, UnregistrationParams @params, CancellationToken cancellationToken = default) { return(mediator.SendRequest(@params, cancellationToken)); }
public Task <ICollaborationService> CreateServiceAsync(CollaborationSession collaborationSession, CancellationToken cancellationToken) { var languageServerGuestService = (ILanguageServerGuestService)collaborationSession.GetService(typeof(ILanguageServerGuestService)); collaborationSession.RemoteServicesChanged += (sender, e) => { // VS will expose a roslyn LSP server. var roslynLspServerProviderName = LanguageServicesUtils.GetLanguageServerProviderServiceName(StringConstants.RoslynProviderName); // Newer versions of VS will expose language specific LSP servers for Roslyn. var languageSpecificLspServerProviderName = LanguageServicesUtils.GetLanguageServerProviderServiceName(LanguageSpecificProviderName); // VSCode will expose a "any" LSP provider and both support roslyn languages. var anyLspServerProviderName = LanguageServicesUtils.GetLanguageServerProviderServiceName(StringConstants.AnyProviderName); // For VS, Preferentially use the language specific server when it's available, otherwise fall back to the generic roslyn server. if (collaborationSession.RemoteServiceNames.Contains(languageSpecificLspServerProviderName)) { ActiveLanguageServerClient = languageServerGuestService.CreateLanguageServerClient(languageSpecificLspServerProviderName); } else if (collaborationSession.RemoteServiceNames.Contains(roslynLspServerProviderName)) { ActiveLanguageServerClient = languageServerGuestService.CreateLanguageServerClient(roslynLspServerProviderName); } else if (collaborationSession.RemoteServiceNames.Contains(anyLspServerProviderName)) { ActiveLanguageServerClient = languageServerGuestService.CreateLanguageServerClient(anyLspServerProviderName); } }; // Register Roslyn supported capabilities languageServerGuestService.RegisterClientMetadata( new string[] { StringConstants.TypeScriptLanguageName }, new LanguageServerClientMetadata( true, JObject.FromObject(new ServerCapabilities { // Uses Roslyn client. DocumentSymbolProvider = true, // Uses LSP SDK client. DocumentLinkProvider = null, RenameProvider = false, DocumentOnTypeFormattingProvider = null, DocumentRangeFormattingProvider = false, DocumentFormattingProvider = false, CodeLensProvider = null, CodeActionProvider = false, ExecuteCommandProvider = null, WorkspaceSymbolProvider = false, DocumentHighlightProvider = false, ReferencesProvider = false, DefinitionProvider = false, SignatureHelpProvider = null, CompletionProvider = null, HoverProvider = false, TextDocumentSync = null, }))); languageServerGuestService.RegisterClientMetadata( new string[] { StringConstants.CSharpLspContentTypeName, StringConstants.VBLspLanguageName }, new LanguageServerClientMetadata( true, JObject.FromObject(new ServerCapabilities { // Uses Roslyn client. DocumentOnTypeFormattingProvider = new DocumentOnTypeFormattingOptions(), DocumentRangeFormattingProvider = true, DocumentFormattingProvider = true, DocumentSymbolProvider = true, CodeActionProvider = true, ExecuteCommandProvider = new ExecuteCommandOptions(), DocumentHighlightProvider = true, ReferencesProvider = true, DefinitionProvider = true, SignatureHelpProvider = new SignatureHelpOptions() { }, CompletionProvider = new CompletionOptions(), ImplementationProvider = true, // Uses LSP SDK client. DocumentLinkProvider = null, RenameProvider = false, CodeLensProvider = null, WorkspaceSymbolProvider = false, HoverProvider = false, TextDocumentSync = null, }))); var lifeTimeService = new RoslynLSPClientLifeTimeService(); lifeTimeService.Disposed += (s, e) => { ActiveLanguageServerClient?.Dispose(); ActiveLanguageServerClient = null; }; return(Task.FromResult <ICollaborationService>(lifeTimeService)); }
public RoslynRemoteCodeActionOperation(Command command, ILanguageServerClient lspClient) { _command = command ?? throw new ArgumentNullException(nameof(command)); _lspClient = lspClient ?? throw new ArgumentNullException(nameof(lspClient)); }
public static async Task RegisterCapability(this ILanguageServerClient mediator, RegistrationParams @params) { await mediator.SendRequest(ClientNames.RegisterCapability, @params); }