From 8479470710e4f359f8fb4214daa82c0a7c8eee3d Mon Sep 17 00:00:00 2001 From: Karsten Thoms Date: Tue, 23 May 2017 00:41:21 +0200 Subject: [PATCH] Changed detection of server directory Signed-off-by: Karsten Thoms --- .../org/eclipse/lsp4e/php/PHPLanguageServer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/org.eclipse.lsp4e.php/src/org/eclipse/lsp4e/php/PHPLanguageServer.java b/org.eclipse.lsp4e.php/src/org/eclipse/lsp4e/php/PHPLanguageServer.java index 693aa51..9d4e6e2 100644 --- a/org.eclipse.lsp4e.php/src/org/eclipse/lsp4e/php/PHPLanguageServer.java +++ b/org.eclipse.lsp4e.php/src/org/eclipse/lsp4e/php/PHPLanguageServer.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -35,12 +36,21 @@ public PHPLanguageServer() { commands.add("php"); Bundle bundle = Activator.getContext().getBundle(); Path workingDir = Path.EMPTY; + URL serverUrl = bundle.getEntry("/server"); + if (serverUrl == null) { + // in development mode the server is copied to the target directory + serverUrl = bundle.getEntry("/target/server"); + } + if (serverUrl == null) { + throw new IllegalStateException ("Language server is not available in bundle "+bundle.getSymbolicName()+"."); + } try { - workingDir = new Path(FileLocator.toFileURL(FileLocator.find(bundle, new Path("server"), null)).getPath()); - commands.add(workingDir.append("/bin/php-language-server.php").toOSString()); + workingDir = new Path(FileLocator.toFileURL(serverUrl).getPath()); } catch (IOException e) { LanguageServerPlugin.logError(e); } + commands.add(workingDir.append("/bin/php-language-server.php").toOSString()); + if (Platform.getOS().equals(Platform.OS_WIN32)) { commands.add("--tcp=127.0.0.1:" + CONNECTION_PORT); provider = new SocketStreamConnectionProvider(commands, workingDir.toOSString(), CONNECTION_PORT);