From ee62aa259c29c3119075b73c625582ec8327dbaf Mon Sep 17 00:00:00 2001 From: Victor Rubezhny Date: Wed, 21 Jun 2023 00:18:20 +0200 Subject: [PATCH] Lemminx prepareRename/Rename Server Capabilities are not supported by LSP4E #1551 Fixes: #1551 --- .../capabilities/ServerCapabilitiesInitializer.java | 7 +++++-- .../settings/capabilities/XMLCapabilitiesTest.java | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/settings/capabilities/ServerCapabilitiesInitializer.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/settings/capabilities/ServerCapabilitiesInitializer.java index 9e70e742a..79652991c 100644 --- a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/settings/capabilities/ServerCapabilitiesInitializer.java +++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/settings/capabilities/ServerCapabilitiesInitializer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Red Hat, Inc. and others. + * Copyright (c) 2018, 2023 Red Hat, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_CODELENS_OPTIONS; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_COMPLETION_OPTIONS; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_LINK_OPTIONS; +import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_RENAME_OPTIONS; import org.eclipse.lsp4j.ServerCapabilities; import org.eclipse.lsp4j.TextDocumentSyncKind; @@ -53,7 +54,6 @@ public static ServerCapabilities getNonDynamicServerCapabilities(ClientCapabilit serverCapabilities.setDocumentRangeFormattingProvider( !clientCapabilities.isRangeFormattingDynamicRegistrationSupported()); serverCapabilities.setHoverProvider(!clientCapabilities.isHoverDynamicRegistered()); - serverCapabilities.setRenameProvider(!clientCapabilities.isRenameDynamicRegistrationSupported()); serverCapabilities.setFoldingRangeProvider(!clientCapabilities.isRangeFoldingDynamicRegistrationSupported()); serverCapabilities.setDefinitionProvider(!clientCapabilities.isDefinitionDynamicRegistered()); serverCapabilities.setTypeDefinitionProvider(!clientCapabilities.isTypeDefinitionDynamicRegistered()); @@ -80,6 +80,9 @@ public static ServerCapabilities getNonDynamicServerCapabilities(ClientCapabilit if (!clientCapabilities.isCodeActionDynamicRegistered()) { serverCapabilities.setCodeActionProvider(DEFAULT_CODEACTION_OPTIONS); } + if (!clientCapabilities.isRenameDynamicRegistrationSupported()) { + serverCapabilities.setRenameProvider(DEFAULT_RENAME_OPTIONS); + } return serverCapabilities; } } \ No newline at end of file diff --git a/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/settings/capabilities/XMLCapabilitiesTest.java b/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/settings/capabilities/XMLCapabilitiesTest.java index 5f4fb83ae..66c8c24f4 100644 --- a/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/settings/capabilities/XMLCapabilitiesTest.java +++ b/org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/settings/capabilities/XMLCapabilitiesTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 Red Hat, Inc. and others. + * Copyright (c) 2018, 2023 Red Hat, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -16,6 +16,7 @@ import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_CODEACTION_OPTIONS; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_COMPLETION_OPTIONS; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_LINK_OPTIONS; +import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DEFAULT_RENAME_OPTIONS; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.DOCUMENT_SYMBOL_ID; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.FORMATTING_ID; import static org.eclipse.lemminx.settings.capabilities.ServerCapabilitiesConstants.FORMATTING_RANGE_ID; @@ -91,11 +92,11 @@ public void testAllDynamicCapabilities() { assertEquals(FALSE, serverCapabilities.getDocumentSymbolProvider()); assertEquals(FALSE, serverCapabilities.getHoverProvider()); assertEquals(FALSE, serverCapabilities.getDocumentHighlightProvider()); - assertEquals(FALSE, serverCapabilities.getRenameProvider()); assertEquals(FALSE, serverCapabilities.getFoldingRangeProvider()); assertEquals(null, serverCapabilities.getCodeActionProvider()); assertEquals(null, serverCapabilities.getCompletionProvider()); assertEquals(null, serverCapabilities.getDocumentLinkProvider()); + assertEquals(null, serverCapabilities.getRenameProvider()); } @Test @@ -112,11 +113,11 @@ public void testNoDynamicCapabilities() { assertEquals(TRUE, serverCapabilities.getDocumentSymbolProvider()); assertEquals(TRUE, serverCapabilities.getHoverProvider()); assertEquals(TRUE, serverCapabilities.getDocumentHighlightProvider()); - assertEquals(TRUE, serverCapabilities.getRenameProvider()); assertEquals(TRUE, serverCapabilities.getFoldingRangeProvider()); assertEquals(Either.forRight(DEFAULT_CODEACTION_OPTIONS), serverCapabilities.getCodeActionProvider()); assertEquals(DEFAULT_COMPLETION_OPTIONS, serverCapabilities.getCompletionProvider()); assertEquals(DEFAULT_LINK_OPTIONS, serverCapabilities.getDocumentLinkProvider()); + assertEquals(Either.forRight(DEFAULT_RENAME_OPTIONS), serverCapabilities.getRenameProvider()); } @Test @@ -155,11 +156,11 @@ public void testBothCapabilityTypes() { assertEquals(FALSE, serverCapabilities.getDocumentSymbolProvider()); assertEquals(TRUE, serverCapabilities.getHoverProvider()); assertEquals(TRUE, serverCapabilities.getDocumentHighlightProvider()); - assertEquals(TRUE, serverCapabilities.getRenameProvider()); assertEquals(TRUE, serverCapabilities.getFoldingRangeProvider()); assertEquals(Either.forRight(DEFAULT_CODEACTION_OPTIONS), serverCapabilities.getCodeActionProvider()); assertEquals(null, serverCapabilities.getCompletionProvider()); assertEquals(DEFAULT_LINK_OPTIONS, serverCapabilities.getDocumentLinkProvider()); + assertEquals(Either.forRight(DEFAULT_RENAME_OPTIONS), serverCapabilities.getRenameProvider()); } @Test