Some fixes to accomodate windows

This commit is contained in:
kdvolder
2017-12-11 16:00:19 -08:00
parent b51e2fa0da
commit 22e8ba80ba
9 changed files with 52 additions and 21 deletions

View File

@@ -39,7 +39,7 @@ public class SpringBootJavaLanguageServer extends STS4LanguageServerProcessStrea
commands.add("-Dlsp.completions.indentation.enable=true");
commands.add("-Xmx1024m");
commands.add("-cp");
commands.add(getToolsJAR() + ":" + getLanguageServerJARLocation());
commands.add(getToolsJAR() + File.pathSeparator + getLanguageServerJARLocation());
commands.add("org.springframework.boot.loader.JarLauncher");
String workingDir = getWorkingDirLocation();

View File

@@ -20,14 +20,8 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>

View File

@@ -25,7 +25,9 @@ public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
String serverName = "boot-java-language-server";
LogRedirect.redirectToFile(serverName);
if (!System.getProperty(LaunguageServerApp.STANDALONE_STARTUP, "false").equals("true")) {
LogRedirect.redirectToFile(serverName);
}
LaunguageServerApp.start(serverName, () -> {
SimpleLanguageServer server = new BootJavaLanguageServer(
BootJavaLanguageServerParams.createDefault()

View File

@@ -58,6 +58,7 @@ import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserve
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
import org.springframework.ide.vscode.commons.util.Log;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.util.UriUtil;
import org.springframework.ide.vscode.commons.util.text.LanguageId;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
@@ -329,7 +330,7 @@ public class SpringIndexer {
FileASTRequestor requestor = new FileASTRequestor() {
@Override
public void acceptAST(String sourceFilePath, CompilationUnit cu) {
String docURI = "file://" + sourceFilePath;
String docURI = UriUtil.toUri(new File(sourceFilePath)).toString();
AtomicReference<TextDocument> docRef = new AtomicReference<>();
scanAST(cu, docURI, docRef, null);
}

View File

@@ -15,11 +15,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
@@ -30,6 +25,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.springframework.ide.eclipse.core.springnature</nature>

View File

@@ -35,7 +35,8 @@
<artifactId>tools</artifactId>
<version>1.8.0</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
<systemPath>C:\Program Files\Java\jdk1.8.0_144\lib\tools.jar</systemPath>
<!-- <systemPath>${java.home}/../lib/tools.jar</systemPath> -->
</dependency>
<dependency>
<artifactId>commons-util</artifactId>

View File

@@ -56,7 +56,7 @@ import org.springframework.ide.vscode.commons.util.Log;
public abstract class LaunguageServerApp {
public static final String STS4_LANGUAGESERVER_NAME = "sts4.languageserver.name";
private static final String STANDALONE_STARTUP = "standalone-startup";
public static final String STANDALONE_STARTUP = "standalone-startup";
private static final int SERVER_STANDALONE_PORT = 5007;
public static void start(String name, Provider<SimpleLanguageServer> languageServerFactory) throws IOException, InterruptedException {

View File

@@ -10,7 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.commons.languageserver.util;
import java.nio.file.Path;
import java.net.URI;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
@@ -182,13 +182,18 @@ public abstract class SimpleLanguageServer implements Sts4LanguageServer, Langua
this.getWorkspaceService().setWorkspaceFolders(workspaceFolders);
}
else {
String rootPath = params.getRootPath();
if (rootPath==null) {
String rootUri = params.getRootUri();
if (rootUri==null) {
Log.debug("workspaceRoot NOT SET");
} else {
List<WorkspaceFolder> singleRootFolder = new ArrayList<>();
Path path = Paths.get(rootPath);
singleRootFolder.add(new WorkspaceFolder(path.toUri().toString(), path.getFileName().toString()));
String name;
try {
name = Paths.get(new URI(rootUri).getPath()).getFileName().toString();
} catch (Exception e) {
name = "";
}
singleRootFolder.add(new WorkspaceFolder(rootUri, name));
this.getWorkspaceService().setWorkspaceFolders(singleRootFolder);
}
}

View File

@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 Pivotal, Inc.
* 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:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.util;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
public class UriUtil {
public static URI toUri(File file) {
try {
return new URI("file", "", file.getAbsoluteFile().toURI().getPath(), null); //$NON-NLS-1$ //$NON-NLS-2$
} catch (URISyntaxException e) {
Log.log(e);
return file.getAbsoluteFile().toURI();
}
}
}