Skip to content

Commit

Permalink
#1794 remove all 'test-ls' profile, use system variable to determine …
Browse files Browse the repository at this point in the history
…is test LS enabled

Signed-off-by: Yevhen Vydolob <evidolob@codenvy.com>
  • Loading branch information
Yevhen Vydolob committed Aug 22, 2017
1 parent 77ffb9a commit 952ddd6
Show file tree
Hide file tree
Showing 34 changed files with 722 additions and 756 deletions.
9 changes: 1 addition & 8 deletions agents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
<module>ls-python</module>
<module>ls-typescript</module>
<module>ls-csharp</module>
<module>test-ls</module>
</modules>
<profiles>
<profile>
<id>test-ls</id>
<modules>
<module>test-ls</module>
</modules>
</profile>
</profiles>
</project>
6 changes: 3 additions & 3 deletions agents/test-ls/pom.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2017 Codenvy, S.A.
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:
Codenvy, S.A. - initial API and implementation
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.16.0-SNAPSHOT</version>
<version>5.17.0-SNAPSHOT</version>
</parent>
<artifactId>test-ls-agent</artifactId>
<name>Test Language Server Agent</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
/*
* 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:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
* Red Hat, Inc. - initial API and implementation
*/

package org.eclipse.che.api.agent; import com.google.inject.Inject;
import com.google.inject.Singleton;
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;

import java.io.IOException;

/**
* 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";
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);
}
@Inject
public TestLSAgent() throws IOException {
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
/*
* 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:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
* 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() {
Multibinder<Agent> agents = Multibinder.newSetBinder(binder(), Agent.class);
agents.addBinding().to(TestLSAgent.class);
@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
@@ -1,12 +1,12 @@
#
# Copyright (c) 2012-2017 Codenvy, S.A.
# 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:
# Codenvy, S.A. - initial API and implementation
# Red Hat, Inc. - initial API and implementation
#

unset PACKAGES
Expand Down
15 changes: 4 additions & 11 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 Expand Up @@ -166,15 +170,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>test-ls</id>
<dependencies>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-test-ls-server</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
15 changes: 4 additions & 11 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 Expand Up @@ -344,15 +348,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>test-ls</id>
<dependencies>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>test-ls-agent</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class RequestHandlerManager {

private final Map<String, Category> methodToCategory = new ConcurrentHashMap<>();
private final Map<String, OneToOneHandler> oneToOneHandlers = new ConcurrentHashMap<>();
private final Map<String, OneToPromiseOneHandler> oneToPromiseOneHandlers = new ConcurrentHashMap<>();
private final Map<String, OneToPromiseOneHandler> oneToPromiseOneHandlers =
new ConcurrentHashMap<>();
private final Map<String, OneToManyHandler> oneToManyHandlers = new ConcurrentHashMap<>();
private final Map<String, OneToNoneHandler> oneToNoneHandlers = new ConcurrentHashMap<>();
private final Map<String, ManyToOneHandler> manyToOneHandlers = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -79,16 +80,19 @@ public synchronized <P, R> void registerOneToOne(
oneToOneHandlers.put(method, new OneToOneHandler<>(pClass, rClass, biFunction));
}

public synchronized <P, R> void registerOneToPromiseOne(String method, Class<P> pClass, Class<R> rClass,
BiFunction<String, P, JsonRpcPromise<R>> function) {
mustNotBeRegistered(method);
methodToCategory.put(method, Category.ONE_TO_PROMISE_ONE);
oneToPromiseOneHandlers.put(method, new OneToPromiseOneHandler<>(pClass, rClass, function));
}
public synchronized <P, R> void registerOneToPromiseOne(
String method,
Class<P> pClass,
Class<R> rClass,
BiFunction<String, P, JsonRpcPromise<R>> function) {
mustNotBeRegistered(method);
methodToCategory.put(method, Category.ONE_TO_PROMISE_ONE);
oneToPromiseOneHandlers.put(method, new OneToPromiseOneHandler<>(pClass, rClass, function));
}

public synchronized <P, R> void registerOneToMany(String method, Class<P> pClass, Class<R> rClass,
BiFunction<String, P, List<R>> biFunction) {
mustNotBeRegistered(method);
public synchronized <P, R> void registerOneToMany(
String method, Class<P> pClass, Class<R> rClass, BiFunction<String, P, List<R>> biFunction) {
mustNotBeRegistered(method);

methodToCategory.put(method, Category.ONE_TO_MANY);
oneToManyHandlers.put(method, new OneToManyHandler<>(pClass, rClass, biFunction));
Expand Down Expand Up @@ -281,15 +285,17 @@ private void transmitMany(String endpointId, String id, List<?> result) {
String message = marshaller.marshall(jsonRpcResponse);
transmitter.transmit(endpointId, message);
}
private void transmitPromiseOne(String endpointId, String requestId, JsonRpcPromise<Object> promise) {
promise.onSuccess(result -> transmitOne(endpointId, requestId, result));
promise.onFailure(jsonRpcError -> {
JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(requestId, null, jsonRpcError);
String message = marshaller.marshall(jsonRpcResponse);
transmitter.transmit(endpointId, message);
});
}

private void transmitPromiseOne(
String endpointId, String requestId, JsonRpcPromise<Object> promise) {
promise.onSuccess(result -> transmitOne(endpointId, requestId, result));
promise.onFailure(
jsonRpcError -> {
JsonRpcResponse jsonRpcResponse = new JsonRpcResponse(requestId, null, jsonRpcError);
String message = marshaller.marshall(jsonRpcResponse);
transmitter.transmit(endpointId, message);
});
}

public enum Category {
ONE_TO_ONE,
Expand Down Expand Up @@ -321,27 +327,28 @@ private R handle(String endpointId, JsonRpcParams params) {
}
}

private class OneToPromiseOneHandler<P, R> {
final private Class<P> pClass;
final private Class<R> rClass;
private BiFunction<String, P, JsonRpcPromise<R>> function;

private OneToPromiseOneHandler(Class<P> pClass, Class<R> rClass, BiFunction<String, P, JsonRpcPromise<R>> function) {
this.pClass = pClass;
this.rClass = rClass;
this.function = function;
}

private JsonRpcPromise<R> handle(String endpointId, JsonRpcParams params) {
P dto = dtoComposer.composeOne(params, pClass);
return function.apply(endpointId, dto);
}
private class OneToPromiseOneHandler<P, R> {
private final Class<P> pClass;
private final Class<R> rClass;
private BiFunction<String, P, JsonRpcPromise<R>> function;

private OneToPromiseOneHandler(
Class<P> pClass, Class<R> rClass, BiFunction<String, P, JsonRpcPromise<R>> function) {
this.pClass = pClass;
this.rClass = rClass;
this.function = function;
}

private class OneToManyHandler<P, R> {
final private Class<P> pClass;
final private Class<R> rClass;
final private BiFunction<String, P, List<R>> biFunction;
private JsonRpcPromise<R> handle(String endpointId, JsonRpcParams params) {
P dto = dtoComposer.composeOne(params, pClass);
return function.apply(endpointId, dto);
}
}

private class OneToManyHandler<P, R> {
private final Class<P> pClass;
private final Class<R> rClass;
private final BiFunction<String, P, List<R>> biFunction;

private OneToManyHandler(
Class<P> pClass, Class<R> rClass, BiFunction<String, P, List<R>> biFunction) {
Expand Down
Loading

0 comments on commit 952ddd6

Please sign in to comment.