-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add TypeScript language server (#3145)
* #3119 add TypeScript language server Signed-off-by: Evgen Vidolob <[email protected]>
- Loading branch information
Evgen Vidolob
authored
Dec 8, 2016
1 parent
ab9b094
commit b48fe2d
Showing
19 changed files
with
585 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?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-web-parent</artifactId> | ||
<groupId>org.eclipse.che.plugin</groupId> | ||
<version>5.0.0-M8-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>che-plugin-web-ext-server</artifactId> | ||
<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>javax.inject</groupId> | ||
<artifactId>javax.inject</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> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-commons-inject</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.plugin</groupId> | ||
<artifactId>che-plugin-web-ext-shared</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
35 changes: 35 additions & 0 deletions
35
.../che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/inject/WebModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* 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.web.inject; | ||
|
||
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.type.ProjectTypeDef; | ||
import org.eclipse.che.inject.DynaModule; | ||
import org.eclipse.che.plugin.web.typescript.TSLSLauncher; | ||
import org.eclipse.che.plugin.web.typescript.TypeScriptProjectType; | ||
|
||
/** | ||
* The module that contains configuration of the server side part of the Web plugin | ||
*/ | ||
@DynaModule | ||
public class WebModule extends AbstractModule { | ||
|
||
@Override | ||
protected void configure() { | ||
Multibinder<ProjectTypeDef> projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class); | ||
projectTypeMultibinder.addBinding().to(TypeScriptProjectType.class); | ||
|
||
Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(TSLSLauncher.class); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...ugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/******************************************************************************* | ||
* 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.web.typescript; | ||
|
||
import io.typefox.lsapi.services.LanguageServer; | ||
import io.typefox.lsapi.services.json.JsonBasedLanguageServer; | ||
|
||
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.plugin.web.shared.Constants; | ||
|
||
import javax.inject.Singleton; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
/** | ||
* Launcher for TypeScript Language Server | ||
*/ | ||
@Singleton | ||
public class TSLSLauncher extends LanguageServerLauncherTemplate { | ||
private static final String[] EXTENSIONS = new String[] {Constants.TS_EXT}; | ||
private static final String[] MIME_TYPES = new String[] {Constants.TS_MIME_TYPE}; | ||
private static final LanguageDescriptionImpl description; | ||
|
||
private final Path launchScript; | ||
|
||
public TSLSLauncher() { | ||
launchScript = Paths.get(System.getenv("HOME"), "che/ls-typescript/launch.sh"); | ||
} | ||
|
||
@Override | ||
protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { | ||
ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); | ||
processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); | ||
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); | ||
try { | ||
return processBuilder.start(); | ||
} catch (IOException e) { | ||
throw new LanguageServerException("Can't start TypeScript language server", e); | ||
} | ||
} | ||
|
||
@Override | ||
protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException { | ||
JsonBasedLanguageServer languageServer = new JsonBasedLanguageServer(); | ||
languageServer.connect(languageServerProcess.getInputStream(), languageServerProcess.getOutputStream()); | ||
return languageServer; | ||
} | ||
|
||
@Override | ||
public LanguageDescription getLanguageDescription() { | ||
return description; | ||
} | ||
|
||
@Override | ||
public boolean isAbleToLaunch() { | ||
return Files.exists(launchScript); | ||
} | ||
|
||
static { | ||
description = new LanguageDescriptionImpl(); | ||
description.setFileExtensions(asList(EXTENSIONS)); | ||
description.setLanguageId(Constants.TS_LANG); | ||
description.setMimeTypes(asList(MIME_TYPES)); | ||
description.setHighlightingConfiguration("[\n" + | ||
" {\"include\":\"orion.js\"},\n" + | ||
" {\"match\":\"\\\\b(?:constructor|declare|module)\\\\b\",\"name\" :\"keyword.operator.typescript\"},\n" + | ||
" {\"match\":\"\\\\b(?:any|boolean|number|string)\\\\b\",\"name\" : \"storage.type.typescript\"}\n" + | ||
"]"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TypeScriptProjectType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/******************************************************************************* | ||
* 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.web.typescript; | ||
|
||
import org.eclipse.che.api.project.server.type.ProjectTypeDef; | ||
import org.eclipse.che.plugin.web.shared.Constants; | ||
|
||
/** | ||
* TypeScript project type definition | ||
*/ | ||
public class TypeScriptProjectType extends ProjectTypeDef { | ||
|
||
public TypeScriptProjectType(){ | ||
super(Constants.TS_PROJECT_TYPE_ID, "TypeScript project", true, false, true); | ||
addConstantDefinition(Constants.LANGUAGE, "language", Constants.TS_LANG); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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-web-parent</artifactId> | ||
<groupId>org.eclipse.che.plugin</groupId> | ||
<version>5.0.0-M8-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>che-plugin-web-ext-shared</artifactId> | ||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<outputDirectory>target/classes</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>src/main/java</directory> | ||
</resource> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
</resources> | ||
<testResources> | ||
<testResource> | ||
<directory>src/test/resources</directory> | ||
</testResource> | ||
</testResources> | ||
</build> | ||
</project> |
34 changes: 34 additions & 0 deletions
34
.../che-plugin-web-ext-shared/src/main/java/org/eclipse/che/plugin/web/shared/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* 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.web.shared; | ||
|
||
/** | ||
* Shared constants for Web plugin | ||
*/ | ||
public final class Constants { | ||
|
||
public static final String LANGUAGE = "language"; | ||
|
||
/** TS Project Type ID */ | ||
public static String TS_PROJECT_TYPE_ID = "typescript"; | ||
|
||
/** TS Language */ | ||
public static String TS_LANG = "typescript"; | ||
|
||
/** Default extension for TS files */ | ||
public static String TS_EXT = "ts"; | ||
|
||
/** TypeScript file mime type*/ | ||
public static final String TS_MIME_TYPE = "application/typescript"; | ||
|
||
private Constants() { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...che-plugin-web-ext-shared/src/main/resources/org/eclipse/che/plugin/web/WebShared.gwt.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?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 | ||
--> | ||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN" "http://gwtproject.org/doctype/2.7.0/gwt-module.dtd"> | ||
<module> | ||
<source path="shared"/> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.