Skip to content

Commit

Permalink
Вынос описания расширений протокола в отдельный интерфейс
Browse files Browse the repository at this point in the history
  • Loading branch information
nixel2007 committed Sep 14, 2020
1 parent 4002504 commit e86c0ec
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github._1c_syntax.bsl.languageserver.configuration.LanguageServerConfiguration;
import com.github._1c_syntax.bsl.languageserver.context.ServerContext;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.DiagnosticParams;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.ProtocolExtension;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.lsp4j.CodeLensOptions;
Expand All @@ -33,7 +34,6 @@
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.ServerCapabilities;
import org.eclipse.lsp4j.TextDocumentSyncKind;
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.lsp4j.services.TextDocumentService;
import org.eclipse.lsp4j.services.WorkspaceService;
Expand All @@ -50,7 +50,7 @@
@Slf4j
@Component
@RequiredArgsConstructor
public class BSLLanguageServer implements LanguageServer {
public class BSLLanguageServer implements LanguageServer, ProtocolExtension {

private final LanguageServerConfiguration configuration;
private final BSLTextDocumentService textDocumentService;
Expand Down Expand Up @@ -114,14 +114,15 @@ public void exit() {
}

/**
* {@inheritDoc}
* <p>
* См. {@link BSLTextDocumentService#diagnostics(DiagnosticParams)}
* @param params Параметры запроса.
* @return Список диагностик.
*/
@JsonRequest(
value = "textDocument/x-diagnostics",
useSegment = false
)
// @JsonRequest(
// value = "textDocument/x-diagnostics",
// useSegment = false
// )
@Override
public CompletableFuture<List<Diagnostic>> diagnostics(DiagnosticParams params) {
return textDocumentService.diagnostics(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.github._1c_syntax.bsl.languageserver.context.DocumentContext;
import com.github._1c_syntax.bsl.languageserver.context.ServerContext;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.DiagnosticParams;
import com.github._1c_syntax.bsl.languageserver.jsonrpc.ProtocolExtension;
import com.github._1c_syntax.bsl.languageserver.providers.CodeActionProvider;
import com.github._1c_syntax.bsl.languageserver.providers.CodeLensProvider;
import com.github._1c_syntax.bsl.languageserver.providers.DiagnosticProvider;
Expand Down Expand Up @@ -88,7 +89,7 @@

@Component
@RequiredArgsConstructor
public class BSLTextDocumentService implements TextDocumentService, LanguageClientAware {
public class BSLTextDocumentService implements TextDocumentService, LanguageClientAware, ProtocolExtension {

private final ServerContext context;
private final LanguageServerConfiguration configuration;
Expand Down Expand Up @@ -292,15 +293,7 @@ public CompletableFuture<List<DocumentLink>> documentLink(DocumentLinkParams par
return CompletableFuture.supplyAsync(() -> documentLinkProvider.getDocumentLinks(documentContext));
}

/**
* Обработка нестандартного запроса <code>textDocument/x-diagnostics</code>.
* Позволяет получить список диагностик документа.
* <br>
* См. {@link BSLLanguageServer#diagnostics(DiagnosticParams)}
*
* @param params Параметры запроса.
* @return Список диагностик.
*/
@Override
public CompletableFuture<List<Diagnostic>> diagnostics(DiagnosticParams params) {
DocumentContext documentContext = context.getDocument(params.getTextDocument().getUri());
if (documentContext == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is a part of BSL Language Server.
*
* Copyright © 2018-2020
* Alexey Sosnoviy <[email protected]>, Nikita Gryzlov <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* BSL Language Server is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* BSL Language Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with BSL Language Server.
*/
package com.github._1c_syntax.bsl.languageserver.jsonrpc;

import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public interface ProtocolExtension {

/**
* @param params Параметры запроса.
* @return Список диагностик.
*/
@JsonRequest(
value = "textDocument/x-diagnostics",
useSegment = false
)
CompletableFuture<List<Diagnostic>> diagnostics(DiagnosticParams params);

}

0 comments on commit e86c0ec

Please sign in to comment.