Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-2552: Language server module refactoring #2677

Merged
merged 4 commits into from
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 0 additions & 4 deletions assembly/assembly-ide-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-ide</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-machine-ext-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<inherits name="org.eclipse.che.api.workspace.Workspace"/>
<inherits name="org.eclipse.che.api.debug.Debug"/>
<inherits name="org.eclipse.che.api.ssh.Ssh"/>
<inherits name="org.eclipse.che.api.languageserver.LanguageServer"/>

<inherits name="org.eclipse.che.plugin.svn.Subversion"/>

Expand Down
14 changes: 9 additions & 5 deletions assembly/assembly-wsagent-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-git</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
Expand Down Expand Up @@ -146,11 +154,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-shared</artifactId>
<artifactId>che-plugin-json-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
Expand Down
16 changes: 16 additions & 0 deletions plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>io.typefox.lsapi</groupId>
<artifactId>io.typefox.lsapi.services</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
Expand All @@ -48,6 +60,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-csharp-lang-shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher;
import org.eclipse.che.api.project.server.handlers.ProjectHandler;
import org.eclipse.che.api.project.server.type.ProjectTypeDef;
import org.eclipse.che.inject.DynaModule;
import org.eclipse.che.plugin.csharp.ls.CSharpLanguageServerLauncher;
import org.eclipse.che.plugin.csharp.projecttype.CSharpProjectType;
import org.eclipse.che.plugin.csharp.projecttype.CreateNetCoreProjectHandler;

Expand All @@ -31,5 +33,7 @@ protected void configure() {

Multibinder<ProjectHandler> projectHandlersMultibinder = Multibinder.newSetBinder(binder(), ProjectHandler.class);
projectHandlersMultibinder.addBinding().to(CreateNetCoreProjectHandler.class);

Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(CSharpLanguageServerLauncher.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.server.launcher;
package org.eclipse.che.plugin.csharp.ls;

import io.typefox.lsapi.services.json.JsonBasedLanguageServer;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.apache.commons.io.IOUtils;
import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException;
import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.plugin.languageserver.shared.model.impl.LanguageDescriptionImpl;
import org.eclipse.che.api.languageserver.exception.LanguageServerException;
import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate;
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl;
import org.eclipse.che.commons.lang.IoUtil;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
Expand All @@ -33,12 +36,12 @@
@Singleton
public class CSharpLanguageServerLauncher extends LanguageServerLauncherTemplate {

public static final String LANGUAGE_ID = "csharp";
public static final String[] EXTENSIONS = new String[] {"cs", "csx"};
public static final String[] MIME_TYPES = new String[] {"text/x-csharp"};
private static final String LANGUAGE_ID = "csharp";
private static final String[] EXTENSIONS = new String[] {"cs", "csx"};
private static final String[] MIME_TYPES = new String[] {"text/x-csharp"};
private static final LanguageDescriptionImpl description;

public static final LanguageDescriptionImpl description;
private static final String SCRIPT_PATH = "che/ls-csharp/launch.sh";
private final Path launchScript;

static {
description = new LanguageDescriptionImpl();
Expand All @@ -47,12 +50,16 @@ public class CSharpLanguageServerLauncher extends LanguageServerLauncherTemplate
description.setMimeTypes(Arrays.asList(MIME_TYPES));
}

@Inject
public CSharpLanguageServerLauncher() {
launchScript = Paths.get(System.getenv("HOME"), "che/ls-csharp/launch.sh");
}

@Override
protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException {
restoreDependencies(projectPath);
Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH);

ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString());
ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString());
processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE);
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE);

Expand All @@ -70,8 +77,8 @@ private void restoreDependencies(String projectPath) throws LanguageServerExcept
Process process = processBuilder.start();
int resultCode = process.waitFor();
if (resultCode != 0) {
String err = IOUtils.toString(process.getErrorStream());
String in = IOUtils.toString(process.getInputStream());
String err = IoUtil.readStream(process.getErrorStream());
String in = IoUtil.readStream(process.getInputStream());
throw new LanguageServerException("Can't restore dependencies. Error: " + err + ". Output: " + in);
}
} catch (IOException | InterruptedException e) {
Expand All @@ -93,7 +100,6 @@ public LanguageDescription getLanguageDescription() {

@Override
public boolean isAbleToLaunch() {
Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH);
return launchFile.toFile().exists();
return Files.exists(launchScript);
}
}
52 changes: 52 additions & 0 deletions plugins/plugin-json/che-plugin-json-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2012-2016 Codenvy, S.A.
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

-->
<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-plugin-json-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.0.0-M5-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-json-server</artifactId>
<name>Che Plugin :: JSON :: Extension Server</name>
<properties>
<findbugs.failonerror>false</findbugs.failonerror>
</properties>
<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>io.typefox.lsapi</groupId>
<artifactId>io.typefox.lsapi.services</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver-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,29 @@
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* 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
*******************************************************************************/
package org.eclipse.che.plugin.json.inject;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

import org.eclipse.che.inject.DynaModule;
import org.eclipse.che.plugin.json.ls.JsonLanguageServerLauncher;
import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher;

/**
* @author Anatolii Bazko
*/
@DynaModule
public class JsonModule extends AbstractModule {
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(JsonLanguageServerLauncher.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.server.launcher;
package org.eclipse.che.plugin.json.ls;

import io.typefox.lsapi.services.json.JsonBasedLanguageServer;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException;
import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.plugin.languageserver.shared.model.impl.LanguageDescriptionImpl;
import org.eclipse.che.api.languageserver.exception.LanguageServerException;
import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate;
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand All @@ -31,12 +34,12 @@
@Singleton
public class JsonLanguageServerLauncher extends LanguageServerLauncherTemplate {

public static final String LANGUAGE_ID = "json";
public static final String[] EXTENSIONS = new String[] {"json", "bowerrc", "jshintrc", "jscsrc", "eslintrc", "babelrc"};
public static final String[] MIME_TYPES = new String[] {"application/json"};

private static final String LANGUAGE_ID = "json";
private static final String[] EXTENSIONS = new String[] {"json", "bowerrc", "jshintrc", "jscsrc", "eslintrc", "babelrc"};
private static final String[] MIME_TYPES = new String[] {"application/json"};
private static final LanguageDescriptionImpl description;
private static final String SCRIPT_PATH = "che/ls-json/launch.sh";

private final Path launchScript;

static {
description = new LanguageDescriptionImpl();
Expand All @@ -45,15 +48,19 @@ public class JsonLanguageServerLauncher extends LanguageServerLauncherTemplate {
description.setMimeTypes(asList(MIME_TYPES));
}

@Inject
public JsonLanguageServerLauncher() {
launchScript = Paths.get(System.getenv("HOME"), "che/ls-json/launch.sh");
}

@Override
public LanguageDescription getLanguageDescription() {
return description;
}

@Override
public boolean isAbleToLaunch() {
Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH);
return launchFile.toFile().exists();
return Files.exists(launchScript);
}

protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) {
Expand All @@ -63,9 +70,7 @@ protected JsonBasedLanguageServer connectToLanguageServer(Process languageServer
}

protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException {
Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH);

ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString());
ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString());
processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE);
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE);
try {
Expand Down
28 changes: 28 additions & 0 deletions plugins/plugin-json/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2012-2016 Codenvy, S.A.
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

-->
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.0.0-M5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>che-plugin-json-parent</artifactId>
<packaging>pom</packaging>
<name>Che Plugin :: JSON :: Parent</name>
<modules>
<module>che-plugin-json-server</module>
</modules>
</project>
Loading