From 54042d1361d74cfed740937935909a3a5729ee49 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Tue, 1 Aug 2017 19:41:15 +0200 Subject: [PATCH] Issue #66: Run `dotnet restore` before starting LS Signed-off-by: Mickael Istria --- .../eclipse/acute/tests/TestLSPIntegration.java | 13 ------------- .../acute/OmnisharpStreamConnectionProvider.java | 14 +++++++++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/org.eclipse.acute.tests/src/org/eclipse/acute/tests/TestLSPIntegration.java b/org.eclipse.acute.tests/src/org/eclipse/acute/tests/TestLSPIntegration.java index 53a9a4ad..f32e9dc0 100644 --- a/org.eclipse.acute.tests/src/org/eclipse/acute/tests/TestLSPIntegration.java +++ b/org.eclipse.acute.tests/src/org/eclipse/acute/tests/TestLSPIntegration.java @@ -45,21 +45,9 @@ public void setUp() throws Exception { super.setUp(); } - private void dotnetRestore(IProject project) throws Exception { - String[] command = new String[] {"/bin/bash", "-c", "dotnet restore"}; - if (Platform.getOS().equals(Platform.OS_WIN32)) { - command = new String[] {"cmd", "/c", "dotnet restore"}; - } - ProcessBuilder builder = new ProcessBuilder(command); - builder.directory(project.getLocation().toFile()); - Process dotnetRestoreProcess = builder.start(); - dotnetRestoreProcess.waitFor(); - } - @Test public void testLSFound() throws Exception { IProject project = getProject("basic"); - dotnetRestore(project); IFile csharpSourceFile = project.getFile("test.cs"); LanguageServer languageServer = LanguageServiceAccessor.getLanguageServers(csharpSourceFile, capabilities -> capabilities.getHoverProvider() != null).iterator().next(); String uri = csharpSourceFile.getLocationURI().toString(); @@ -70,7 +58,6 @@ public void testLSFound() throws Exception { @Test public void testLSWorks() throws Exception { IProject project = getProject("basicWithError"); - dotnetRestore(project); IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart editor = null; IFile file = project.getFile("testError.cs"); diff --git a/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java b/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java index 949076b4..56d89151 100644 --- a/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java +++ b/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java @@ -41,10 +41,22 @@ public OmnisharpStreamConnectionProvider() { @Override public void start() throws IOException { + // workaround for https://github.com/OmniSharp/omnisharp-node-client/issues/265 + String[] command = new String[] { "/bin/bash", "-c", "dotnet restore" }; + if (Platform.getOS().equals(Platform.OS_WIN32)) { + command = new String[] { "cmd", "/c", "dotnet restore" }; + } + Process restoreProcess = Runtime.getRuntime().exec(command); + try { + restoreProcess.waitFor(); + } catch (InterruptedException e) { + AcutePlugin.logError(e); + } + String commandLine = System.getenv("OMNISHARP_LANGUAGE_SERVER_COMMAND"); String omnisharpLocation = System.getenv("OMNISHARP_LANGUAGE_SERVER_LOCATION"); if (commandLine != null) { - String[] command = new String[] {"/bin/bash", "-c", commandLine}; + command = new String[] { "/bin/bash", "-c", commandLine }; if (Platform.getOS().equals(Platform.OS_WIN32)) { command = new String[] {"cmd", "/c", commandLine}; }