diff --git a/build.gradle.kts b/build.gradle.kts index d43497a96e1..b16f456e417 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -71,7 +71,7 @@ dependencies { exclude("org.antlr", "antlr-runtime") exclude("org.glassfish", "javax.json") } - api("com.github.1c-syntax", "utils", "0.3.3") + api("com.github.1c-syntax", "utils", "0.3.4") api("com.github.1c-syntax", "mdclasses", "0.9.2") // JLanguageTool diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java index cc31bc80dc1..c2e8d5a3e16 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/BSLLanguageServer.java @@ -74,7 +74,6 @@ public class BSLLanguageServer implements LanguageServer, ProtocolExtension { private final BSLWorkspaceService workspaceService; private final ServerContext context; private final ServerInfo serverInfo; - private final DocumentSelector documentSelector; private boolean shutdownWasCalled; @Override @@ -83,7 +82,7 @@ public CompletableFuture initialize(InitializeParams params) { setConfigurationRoot(params); CompletableFuture.runAsync(context::populateContext); - ServerCapabilities capabilities = new ServerCapabilities(); + var capabilities = new ServerCapabilities(); capabilities.setTextDocumentSync(getTextDocumentSyncOptions()); capabilities.setDocumentRangeFormattingProvider(getDocumentRangeFormattingProvider()); capabilities.setDocumentFormattingProvider(getDocumentFormattingProvider()); @@ -100,7 +99,7 @@ public CompletableFuture initialize(InitializeParams params) { capabilities.setSelectionRangeProvider(getSelectionRangeProvider()); capabilities.setColorProvider(getColorProvider()); - InitializeResult result = new InitializeResult(capabilities, serverInfo); + var result = new InitializeResult(capabilities, serverInfo); return CompletableFuture.completedFuture(result); } @@ -161,14 +160,14 @@ public WorkspaceService getWorkspaceService() { } private static TextDocumentSyncOptions getTextDocumentSyncOptions() { - TextDocumentSyncOptions textDocumentSync = new TextDocumentSyncOptions(); + var textDocumentSync = new TextDocumentSyncOptions(); textDocumentSync.setOpenClose(Boolean.TRUE); textDocumentSync.setChange(TextDocumentSyncKind.Full); textDocumentSync.setWillSave(Boolean.FALSE); textDocumentSync.setWillSaveWaitUntil(Boolean.FALSE); - SaveOptions save = new SaveOptions(); + var save = new SaveOptions(); save.setIncludeText(Boolean.FALSE); textDocumentSync.setSave(save); @@ -198,10 +197,9 @@ private static DocumentSymbolOptions getDocumentSymbolProvider() { return documentSymbolOptions; } - private FoldingRangeProviderOptions getFoldingRangeProvider() { + private static FoldingRangeProviderOptions getFoldingRangeProvider() { var foldingRangeProviderOptions = new FoldingRangeProviderOptions(); foldingRangeProviderOptions.setWorkDoneProgress(Boolean.FALSE); - foldingRangeProviderOptions.setDocumentSelector(documentSelector.asList()); return foldingRangeProviderOptions; } @@ -249,10 +247,9 @@ private static ReferenceOptions getReferencesProvider() { return referenceOptions; } - private CallHierarchyRegistrationOptions getCallHierarchyProvider() { + private static CallHierarchyRegistrationOptions getCallHierarchyProvider() { var callHierarchyRegistrationOptions = new CallHierarchyRegistrationOptions(); callHierarchyRegistrationOptions.setWorkDoneProgress(Boolean.FALSE); - callHierarchyRegistrationOptions.setDocumentSelector(documentSelector.asList()); return callHierarchyRegistrationOptions; } @@ -262,17 +259,15 @@ private static WorkspaceSymbolOptions getWorkspaceProvider() { return workspaceSymbolOptions; } - private SelectionRangeRegistrationOptions getSelectionRangeProvider() { + private static SelectionRangeRegistrationOptions getSelectionRangeProvider() { var selectionRangeRegistrationOptions = new SelectionRangeRegistrationOptions(); selectionRangeRegistrationOptions.setWorkDoneProgress(Boolean.FALSE); - selectionRangeRegistrationOptions.setDocumentSelector(documentSelector.asList()); return selectionRangeRegistrationOptions; } - private ColorProviderOptions getColorProvider() { + private static ColorProviderOptions getColorProvider() { var colorProviderOptions = new ColorProviderOptions(); colorProviderOptions.setWorkDoneProgress(Boolean.FALSE); - colorProviderOptions.setDocumentSelector(documentSelector.asList()); return colorProviderOptions; } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/DocumentSelector.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/DocumentSelector.java deleted file mode 100644 index 7931cd05a9e..00000000000 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/DocumentSelector.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is a part of BSL Language Server. - * - * Copyright (c) 2018-2021 - * Alexey Sosnoviy , Nikita Gryzlov 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; - -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.eclipse.lsp4j.DocumentFilter; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -/** - * Информация о том, документы каких типов (языков, расширений, схем) может обрабатывать Language Server. - */ -@Component -@ToString -@EqualsAndHashCode -public class DocumentSelector { - private final List documentFilters; - - public DocumentSelector() { - var documentFilter = new DocumentFilter(); - documentFilter.setLanguage("bsl"); - - documentFilters = List.of(documentFilter); - } - - /** - * @return Список фильтров документов. - */ - public List asList() { - return new ArrayList<>(documentFilters); - } -}