-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
add TypeScript language server #3145
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 LANGUAGE_ID = "typescript"; | ||
private static final String[] EXTENSIONS = new String[] {"ts"}; | ||
private static final String[] MIME_TYPES = new String[] {"application/typescript"}; | ||
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(LANGUAGE_ID); | ||
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> |
31 changes: 31 additions & 0 deletions
31
.../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,31 @@ | ||
/******************************************************************************* | ||
* 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; | ||
|
||
/** | ||
* | ||
*/ | ||
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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that this constant is never used so may be remove it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now it's used |
||
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty javadoc