forked from eclipse-che/che
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclipse-che#1287 PHP Language Server
Registers a language server for the PHP editor. Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
- Loading branch information
1 parent
46e006b
commit 46df188
Showing
3 changed files
with
74 additions
and
0 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
71 changes: 71 additions & 0 deletions
71
...java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.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,71 @@ | ||
/******************************************************************************* | ||
* 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.languageserver.server.launcher; | ||
|
||
import io.typefox.lsapi.LanguageDescription; | ||
import io.typefox.lsapi.impl.LanguageDescriptionImpl; | ||
import io.typefox.lsapi.services.json.JsonBasedLanguageServer; | ||
|
||
import com.google.inject.Singleton; | ||
|
||
import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
/** | ||
* @author Evgen Vidolob | ||
* @author Anatolii Bazko | ||
* @author Kaloyan Raev | ||
*/ | ||
@Singleton | ||
public class PhpLanguageServerLauncher extends LanguageServerLauncherTemplate { | ||
|
||
public static final String LANGUAGE_ID = "php"; | ||
public static final String[] EXTENSIONS = new String[] {"php"}; | ||
public static final String[] MIME_TYPES = new String[] {"text/x-php"}; | ||
|
||
private static final LanguageDescriptionImpl description; | ||
|
||
static { | ||
description = new LanguageDescriptionImpl(); | ||
description.setFileExtensions(asList(EXTENSIONS)); | ||
description.setLanguageId(LANGUAGE_ID); | ||
description.setMimeTypes(asList(MIME_TYPES)); | ||
} | ||
|
||
@Override | ||
public LanguageDescription getLanguageDescription() { | ||
return description; | ||
} | ||
|
||
protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) { | ||
JsonBasedLanguageServer languageServer = new JsonBasedLanguageServer(); | ||
languageServer.connect(languageServerProcess.getInputStream(), languageServerProcess.getOutputStream()); | ||
return languageServer; | ||
} | ||
|
||
protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { | ||
Path launchFile = Paths.get(System.getenv("HOME"), "che-agents/ls-php/launch.sh"); | ||
|
||
ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString()); | ||
processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); | ||
processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); | ||
try { | ||
return processBuilder.start(); | ||
} catch (IOException e) { | ||
throw new LanguageServerException("Can't start PHP language server", e); | ||
} | ||
} | ||
} |