Skip to content

Commit

Permalink
Add implementation for 'Show message request' LS feature (eclipse-che…
Browse files Browse the repository at this point in the history
…#5860)

* eclipse-che#1794 implement 'ShowMessageRequest'
  • Loading branch information
evidolob authored Sep 4, 2017
1 parent 1f27537 commit 2e798d6
Show file tree
Hide file tree
Showing 37 changed files with 1,392 additions and 13 deletions.
1 change: 1 addition & 0 deletions agents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
<module>ls-python</module>
<module>ls-typescript</module>
<module>ls-csharp</module>
<module>test-ls</module>
</modules>
</project>
41 changes: 41 additions & 0 deletions agents/test-ls/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2017 Red Hat, Inc.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-agents-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>5.18.0-SNAPSHOT</version>
</parent>
<artifactId>test-ls-agent</artifactId>
<name>Test Language Server Agent</name>
<dependencies>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2012-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

package org.eclipse.che.api.agent;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import org.eclipse.che.api.agent.shared.model.Agent;
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;

/**
* Test Language server agent.
*
* @see Agent
*/
@Singleton
public class TestLSAgent extends BasicAgent {
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.test.ls.json";
private static final String AGENT_SCRIPT = "org.eclipse.che.test.ls.script.sh";

@Inject
public TestLSAgent() throws IOException {
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2012-2017 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/

package org.eclipse.che.api.agent;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import org.eclipse.che.api.agent.shared.model.Agent;
import org.eclipse.che.inject.DynaModule;

/** Test language server module */
@DynaModule
public class TestLSModule extends AbstractModule {
@Override
protected void configure() {

if (System.getProperty("test_language_server_enabled") != null) {
Multibinder<Agent> agents = Multibinder.newSetBinder(binder(), Agent.class);
agents.addBinding().to(TestLSAgent.class);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "org.eclipse.che.test.ls",
"name": "Simple Test language server",
"description": "Test LS",
"dependencies": [],
"properties": {}
}
170 changes: 170 additions & 0 deletions agents/test-ls/src/main/resources/org.eclipse.che.test.ls.script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#
# Copyright (c) 2012-2017 Red Hat, Inc.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

unset PACKAGES
unset SUDO
command -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" tar"; }
command -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" curl"; }
test "$(id -u)" = 0 || SUDO="sudo -E"

AGENT_BINARIES_URI=https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.test.binaries
CHE_DIR=$HOME/che
LS_DIR=${CHE_DIR}/test-ls
LS_LAUNCHER=${LS_DIR}/launch.sh

if [ -f /etc/centos-release ]; then
FILE="/etc/centos-release"
LINUX_TYPE=$(cat $FILE | awk '{print $1}')
elif [ -f /etc/redhat-release ]; then
FILE="/etc/redhat-release"
LINUX_TYPE=$(cat $FILE | cut -c 1-8)
else
FILE="/etc/os-release"
LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')
LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)
fi

MACHINE_TYPE=$(uname -m)

mkdir -p ${CHE_DIR}
mkdir -p ${LS_DIR}

########################
### Install packages ###
########################

# Red Hat Enterprise Linux 7
############################
if echo ${LINUX_TYPE} | grep -qi "rhel"; then
test "${PACKAGES}" = "" || {
${SUDO} yum install ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;
${SUDO} yum -y install nodejs;
}

# Red Hat Enterprise Linux 6
############################
elif echo ${LINUX_TYPE} | grep -qi "Red Hat"; then
test "${PACKAGES}" = "" || {
${SUDO} yum install ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;
${SUDO} yum -y install nodejs;
}


# Ubuntu 14.04 16.04 / Linux Mint 17
####################################
elif echo ${LINUX_TYPE} | grep -qi "ubuntu"; then
test "${PACKAGES}" = "" || {
${SUDO} apt-get update;
${SUDO} apt-get -y install ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
{
curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} bash -;
};

${SUDO} apt-get update;
${SUDO} apt-get install -y nodejs;
}


# Debian 8
##########
elif echo ${LINUX_TYPE} | grep -qi "debian"; then
test "${PACKAGES}" = "" || {
${SUDO} apt-get update;
${SUDO} apt-get -y install ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
{
curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} bash -;
};

${SUDO} apt-get update;
${SUDO} apt-get install -y nodejs;
}

# Fedora 23
###########
elif echo ${LINUX_TYPE} | grep -qi "fedora"; then
command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" procps-ng"; }
test "${PACKAGES}" = "" || {
${SUDO} dnf -y install ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;
${SUDO} dnf -y install nodejs;
}


# CentOS 7.1 & Oracle Linux 7.1
###############################
elif echo ${LINUX_TYPE} | grep -qi "centos"; then
test "${PACKAGES}" = "" || {
${SUDO} yum -y install ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;
${SUDO} yum -y install nodejs;
}

# openSUSE 13.2
###############
elif echo ${LINUX_TYPE} | grep -qi "opensuse"; then
test "${PACKAGES}" = "" || {
${SUDO} zypper install -y ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
${SUDO} zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/ Node.js
${SUDO} zypper in nodejs
}

# Alpine 3.3
############
elif echo ${LINUX_TYPE} | grep -qi "alpine"; then
test "${PACKAGES}" = "" || {
${SUDO} apk update
${SUDO} apk add ${PACKAGES};
}

command -v nodejs >/dev/null 2>&1 || {
${SUDO} apk update
${SUDO} apk add nodejs;
}

else
>&2 echo "Unrecognized Linux Type"
>&2 cat $FILE
exit 1
fi


#######################
### Install Test LS ###
#######################

curl -s ${AGENT_BINARIES_URI} | tar xzf - -C ${LS_DIR}

touch ${LS_LAUNCHER}
chmod +x ${LS_LAUNCHER}
echo "${LS_DIR}/test-ls/server.sh" > ${LS_LAUNCHER}
4 changes: 4 additions & 0 deletions assembly/assembly-wsagent-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-svn-ext-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-test-ls-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-testing-classpath</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions assembly/assembly-wsmaster-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
<groupId>org.eclipse.che</groupId>
<artifactId>terminal-agent</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>test-ls-agent</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>unison-agent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public class JsonRpcPromise<R> {
private BiConsumer<String, JsonRpcError> failureConsumer;
private Runnable timeoutRunnable;

Optional<BiConsumer<String, R>> getSuccessConsumer() {
public Optional<BiConsumer<String, R>> getSuccessConsumer() {
return Optional.ofNullable(successConsumer);
}

Optional<BiConsumer<String, JsonRpcError>> getFailureConsumer() {
public Optional<BiConsumer<String, JsonRpcError>> getFailureConsumer() {
return Optional.ofNullable(failureConsumer);
}

Expand Down
Loading

0 comments on commit 2e798d6

Please sign in to comment.