Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.wildwebdeveloper;bundle-version="1.0.0",
org.eclipse.jface.text,
org.eclipse.ui.tests.harness,
org.eclipse.ui,
org.eclipse.lsp4e,
org.eclipse.lsp4e;bundle-version="0.16.0",
org.eclipse.wildwebdeveloper.xml;bundle-version="0.1.0",
org.eclipse.wildwebdeveloper.embedder.node;bundle-version="0.2.0",
org.eclipse.lsp4j;bundle-version="0.9.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Red Hat Inc. and others.
* Copyright (c) 2019, 2023 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -12,18 +12,26 @@
*******************************************************************************/
package org.eclipse.wildwebdeveloper.tests;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.text.IDocument;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4j.Hover;
import org.eclipse.lsp4j.HoverParams;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.ServerCapabilities;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.services.LanguageServer;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
Expand Down Expand Up @@ -61,11 +69,14 @@ public void testHTMLinTSXFile() throws Exception {
// didChange
HoverParams params = new HoverParams(new TextDocumentIdentifier(LSPEclipseUtils.toUri(document).toString()),
new Position(0, 18));
Hover hover = LanguageServiceAccessor
.getLanguageServers(document,
capability -> LSPEclipseUtils.hasCapability(capability.getHoverProvider()))
.get().get(0).getTextDocumentService().hover(params).get();

List<LanguageServer> languageServers = new ArrayList<>();
LanguageServers.forDocument(document).withCapability(ServerCapabilities::getHoverProvider)
.collectAll((w, ls) -> CompletableFuture.completedFuture(ls)).thenAccept(languageServers::addAll)
.get(500, TimeUnit.MILLISECONDS);
assertFalse(languageServers.isEmpty());

Hover hover = languageServers.get(0).getTextDocumentService().hover(params).get();
assertTrue(hover.getContents().toString().contains("button"));
}

}
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.xml.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.wildwebdeveloper.xml.feature"
label="%name"
version="1.1.0.qualifier"
version="1.1.1.qualifier"
provider-name="Eclipse Wild Web Developer project"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.xml.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-feature</packaging>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.wildwebdeveloper.xml/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wildwebdeveloper.xml;singleton:=true
Bundle-Version: 1.1.0.qualifier
Bundle-Version: 1.1.1.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Automatic-Module-Name: org.eclipse.wildwebdeveloper.xml
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.tm4e.registry;bundle-version="0.3.0",
org.eclipse.tm4e.ui;bundle-version="0.1.0",
org.eclipse.tm4e.languageconfiguration;bundle-version="0.1.0",
org.eclipse.lsp4e;bundle-version="0.13.4",
org.eclipse.lsp4e;bundle-version="0.16.0",
org.eclipse.lsp4j;bundle-version="0.9.0",
org.eclipse.core.filesystem;bundle-version="1.7.0",
org.eclipse.core.resources;bundle-version="3.12.0",
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper.xml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<packaging>eclipse-plugin</packaging>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2021 Red Hat Inc. and others.
* Copyright (c) 2019, 2023 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

import org.eclipse.core.net.proxy.IProxyData;
Expand All @@ -36,9 +37,9 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
import org.eclipse.lsp4j.DidChangeConfigurationParams;
import org.eclipse.wildwebdeveloper.xml.internal.ui.preferences.XMLPreferenceServerConstants;
Expand Down Expand Up @@ -77,10 +78,10 @@ private static enum CodeLensKind {
@SuppressWarnings("rawtypes")
DidChangeConfigurationParams params = new DidChangeConfigurationParams(
Collections.singletonMap(XML_KEY, ((Map) config.get(SETTINGS_KEY)).get(XML_KEY)));
LanguageServiceAccessor.getActiveLanguageServers(null).stream()
.filter(server -> lemminxDefinition
.equals(LanguageServiceAccessor.resolveServerDefinition(server).get()))
.forEach(ls -> ls.getWorkspaceService().didChangeConfiguration(params));

LanguageServers.forProject(null).withPreferredServer(lemminxDefinition).excludeInactive()
.collectAll((w, ls) -> CompletableFuture.completedFuture(ls)).thenAccept(
lss -> lss.stream().forEach(ls -> ls.getWorkspaceService().didChangeConfiguration(params)));
});
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
/*******************************************************************************
* Copyright (c) 2020, 2923 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Alex Boyko - initial implementation
*******************************************************************************/
package org.eclipse.wildwebdeveloper.xml.internal;

import java.util.concurrent.CompletableFuture;

import org.eclipse.jface.text.IDocument;
import org.eclipse.lsp4e.LanguageClientImpl;
import org.eclipse.lsp4e.command.CommandExecutor;
import org.eclipse.lsp4j.Command;
Expand All @@ -10,11 +23,12 @@
@SuppressWarnings("restriction")
public class XmlLanguageClientImpl extends LanguageClientImpl implements XMLLanguageClient{

@Override
public CompletableFuture<Object> executeClientCommand(ExecuteCommandParams params) {
Command cmd = new Command();
cmd.setCommand(params.getCommand());
cmd.setArguments(params.getArguments());
return CommandExecutor.executeCommand(cmd, null, null);
return CommandExecutor.executeCommandClientSide(cmd, (IDocument)null);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 Red Hat Inc. and others.
* Copyright (c) 2022 2023 Red Hat Inc. and others.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -15,14 +15,15 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4e.command.LSPCommandHandler;
import org.eclipse.lsp4j.Command;
import org.eclipse.lsp4j.ExecuteCommandOptions;
Expand Down Expand Up @@ -87,22 +88,28 @@ public Object execute(ExecutionEvent event, Command command, IPath path) throws
}

private static CompletableFuture<Object> executeServerCommand(String commandId, Object... params) throws Exception {
List<LanguageServer> commandHandlers = LanguageServiceAccessor
.getActiveLanguageServers(handlesCommand(commandId));
if (commandHandlers != null) {
if (commandHandlers.size() == 1) {
LanguageServer handler = commandHandlers.get(0);
return handler.getWorkspaceService()
.executeCommand(new ExecuteCommandParams(commandId, Arrays.asList(params)));
} else if (commandHandlers.size() > 1) {
throw new IllegalStateException(
"Multiple language servers have registered to handle command '" + commandId + "'");
}
List<LanguageServer> commandHandlers = new ArrayList<>();
LanguageServers.forProject(null).withCapability(serverCapabilities -> {
ExecuteCommandOptions executeCommandProvider = serverCapabilities.getExecuteCommandProvider();
return Either.forLeft(executeCommandProvider != null ?
executeCommandProvider.getCommands().contains(commandId) : false);
}).excludeInactive().collectAll((w, ls) -> CompletableFuture.completedFuture(ls))
.thenAccept(commandHandlers::addAll).get(100, TimeUnit.MILLISECONDS);

if (commandHandlers.size() == 1) {
LanguageServer handler = commandHandlers.get(0);
return handler.getWorkspaceService()
.executeCommand(new ExecuteCommandParams(commandId, Arrays.asList(params)));
} else if (commandHandlers.size() > 1) {
throw new IllegalStateException(
"Multiple language servers have registered to handle command '" + commandId + "'");
}

throw new UnsupportedOperationException(
"No language server has registered to handle command '" + commandId + "'");
}

// TODO: not used - a subject to remove
private static Predicate<ServerCapabilities> handlesCommand(String commandId) {
return (serverCaps) -> {
ExecuteCommandOptions executeCommandProvider = serverCaps.getExecuteCommandProvider();
Expand All @@ -112,5 +119,4 @@ private static Predicate<ServerCapabilities> handlesCommand(String commandId) {
return false;
};
}

}
2 changes: 1 addition & 1 deletion org.eclipse.wildwebdeveloper/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Bundle-Version: 1.0.8.qualifier
Bundle-Activator: org.eclipse.wildwebdeveloper.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.lsp4e;bundle-version="0.13.6",
org.eclipse.lsp4e;bundle-version="0.16.0",
org.eclipse.lsp4j.jsonrpc;bundle-version="0.12.0",
org.eclipse.lsp4j;bundle-version="0.12.0",
org.eclipse.tm4e.registry;bundle-version="0.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016 Rogue Wave Software Inc. and others.
* Copyright (c) 2016, 2023 Rogue Wave Software Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
Expand All @@ -34,9 +35,9 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.jsonrpc.messages.Message;
Expand Down Expand Up @@ -66,10 +67,9 @@ public void propertyChange(PropertyChangeEvent event) {
if (SchemaAssociationsPreferenceInitializer.SCHEMA_ASSOCIATIONS_PREFERENCE.equals(event.getProperty())) {
Map<String, List<String>> associations = getSchemaAssociations();

LanguageServiceAccessor.getActiveLanguageServers(null).stream()
.filter(server -> JSON_LS_DEFINITION
.equals(LanguageServiceAccessor.resolveServerDefinition(server).get()))
.forEach(ls -> ((JSonLanguageServerInterface) ls).sendJSonchemaAssociations(associations));
LanguageServers.forProject(null).withPreferredServer(JSON_LS_DEFINITION).excludeInactive()
.collectAll((w, ls) -> CompletableFuture.completedFuture(ls)).thenAccept(
lss -> lss.stream().forEach(ls -> ((JSonLanguageServerInterface) ls).sendJSonchemaAssociations(associations)));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 Red Hat Inc. and others.
* Copyright (c) 2022, 2023 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -18,13 +18,14 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.lsp4e.LanguageServers;
import org.eclipse.lsp4e.LanguageServersRegistry;
import org.eclipse.lsp4e.LanguageServersRegistry.LanguageServerDefinition;
import org.eclipse.lsp4e.LanguageServiceAccessor;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
import org.eclipse.lsp4j.DidChangeConfigurationParams;
import org.eclipse.lsp4j.services.WorkspaceService;
Expand Down Expand Up @@ -160,10 +161,10 @@ public void propertyChange(PropertyChangeEvent event) {
LanguageServerDefinition languageServerDefinition = getLanguageServerDefinition();
@SuppressWarnings("rawtypes")
DidChangeConfigurationParams params = new DidChangeConfigurationParams(createSettings());
LanguageServiceAccessor.getActiveLanguageServers(null).stream()
.filter(server -> languageServerDefinition
.equals(LanguageServiceAccessor.resolveServerDefinition(server).get()))
.forEach(ls -> ls.getWorkspaceService().didChangeConfiguration(params));

LanguageServers.forProject(null).withPreferredServer(languageServerDefinition).excludeInactive()
.collectAll((w, ls) -> CompletableFuture.completedFuture(ls)).thenAccept(
lss -> lss.stream().forEach(ls -> ls.getWorkspaceService().didChangeConfiguration(params)));
}
}

Expand Down