Skip to content

Commit

Permalink
Issue #66: Run dotnet restore before starting LS
Browse files Browse the repository at this point in the history
Signed-off-by: Mickael Istria <[email protected]>
  • Loading branch information
mickaelistria committed Aug 1, 2017
1 parent 80fa800 commit 54042d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
Expand Down

0 comments on commit 54042d1

Please sign in to comment.