Fix multi-root initialization in SimpleWorkspaceService
This commit is contained in:
@@ -70,6 +70,9 @@ import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
@@ -233,6 +236,7 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
|
||||
if (ih!=null){
|
||||
ih.accept(params);
|
||||
}
|
||||
Log.info("IntializeResult = {}");
|
||||
return CompletableFuture.completedFuture(result);
|
||||
}
|
||||
|
||||
@@ -251,23 +255,23 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
|
||||
List<WorkspaceFolder> initialFolders = new ArrayList<>();
|
||||
|
||||
Object initOptions = params.getInitializationOptions();
|
||||
if (initOptions != null && initOptions instanceof Map) {
|
||||
Map<?, ?> initializationOptions = (Map<?, ?>) initOptions;
|
||||
Object folders = initializationOptions.get("workspaceFolders");
|
||||
if (folders != null && folders instanceof List) {
|
||||
List<?> workspaceFolders = (List<?>) folders;
|
||||
for (Object object : workspaceFolders) {
|
||||
String folderPath = object.toString();
|
||||
if (initOptions != null && initOptions instanceof JsonObject) {
|
||||
JsonObject initializationOptions = (JsonObject) initOptions;
|
||||
JsonElement folders = initializationOptions.get("workspaceFolders");
|
||||
if (folders != null && folders instanceof JsonArray) {
|
||||
JsonArray workspaceFolders = (JsonArray) folders;
|
||||
for (JsonElement object : workspaceFolders) {
|
||||
String folderUri = object.getAsString();
|
||||
String folderName = null;
|
||||
|
||||
int folderNameStart = folderPath.lastIndexOf("/");
|
||||
int folderNameStart = folderUri.lastIndexOf("/");
|
||||
if (folderNameStart > 0) {
|
||||
folderName = folderPath.substring(folderPath.lastIndexOf("/") + 1);
|
||||
folderName = folderUri.substring(folderUri.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
WorkspaceFolder folder = new WorkspaceFolder();
|
||||
folder.setName(folderName);
|
||||
folder.setUri(object.toString());
|
||||
folder.setUri(folderUri);
|
||||
|
||||
initialFolders.add(folder);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.eclipse.lsp4j.WorkspaceFoldersChangeEvent;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
@@ -36,6 +38,8 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
public class SimpleWorkspaceService implements WorkspaceService {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(SimpleWorkspaceService.class);
|
||||
|
||||
private SimpleLanguageServer server;
|
||||
private Set<WorkspaceFolder> workspaceRoots = new HashSet<>();
|
||||
|
||||
@@ -160,7 +164,7 @@ public class SimpleWorkspaceService implements WorkspaceService {
|
||||
public synchronized void setWorkspaceFolders(List<WorkspaceFolder> workspaceFolders) {
|
||||
workspaceRoots = new HashSet<>();
|
||||
workspaceRoots.addAll(workspaceFolders);
|
||||
log.debug("workspaceFolders = {}", workspaceFolders);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#org.slf4j.simpleLogger.log.org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService=debug
|
||||
Reference in New Issue
Block a user