Skip to content

Commit

Permalink
Schema cache directory should be configurable
Browse files Browse the repository at this point in the history
Fixes eclipse-lemminx#222

Signed-off-by: Nikolas Komonen <[email protected]>
  • Loading branch information
NikolasKomonen committed Apr 2, 2019
1 parent 867b3ad commit b382345
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import static org.eclipse.lsp4j.jsonrpc.CompletableFutures.computeAsync;
import static org.eclipse.lsp4xml.utils.VersionHelper.getVersion;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -44,11 +48,13 @@
import org.eclipse.lsp4xml.settings.AllXMLSettings;
import org.eclipse.lsp4xml.settings.InitializationOptionsSettings;
import org.eclipse.lsp4xml.settings.LogsSettings;
import org.eclipse.lsp4xml.settings.ServerSettings;
import org.eclipse.lsp4xml.settings.XMLGeneralClientSettings;
import org.eclipse.lsp4xml.settings.XMLExperimentalCapabilities;
import org.eclipse.lsp4xml.settings.XMLFormattingOptions;
import org.eclipse.lsp4xml.settings.capabilities.ServerCapabilitiesInitializer;
import org.eclipse.lsp4xml.settings.capabilities.XMLCapabilityManager;
import org.eclipse.lsp4xml.utils.FilesUtils;

/**
* XML language server.
Expand Down Expand Up @@ -135,6 +141,18 @@ public void updateSettings(Object initializationOptionsSettings) {
if (newCompletions != null) {
xmlTextDocumentService.updateCompletionSettings(newCompletions);
}

ServerSettings serverSettings = xmlClientSettings.getServer();
if(serverSettings != null) {
String workDir = serverSettings.getWorkDir();

Path p = new File(workDir).toPath();
if(Files.isDirectory(p, LinkOption.NOFOLLOW_LINKS)) {
if(workDir != null && System.getProperty(FilesUtils.LSP4XML_WORKDIR_KEY).equals(workDir) == false) {
System.setProperty(FilesUtils.LSP4XML_WORKDIR_KEY, workDir);
}
}
}

// Experimental capabilities
XMLExperimentalCapabilities experimental = xmlClientSettings.getExperimental();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2019 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/

package org.eclipse.lsp4xml.settings;

import org.eclipse.lsp4xml.utils.JSONUtility;

/**
* ServerSettings
*/
public class ServerSettings {

private String workDir;


/**
* @return the workDir
*/
public String getWorkDir() {
return workDir;
}

/**
* @param workDir the workDir to set
*/
public void setWorkDir(String workDir) {
this.workDir = workDir;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class XMLGeneralClientSettings {

private CompletionSettings completion;

private ServerSettings server;

public void setLogs(LogsSettings logs) {
this.logs = logs;
}
Expand Down Expand Up @@ -78,6 +80,20 @@ public CompletionSettings getCompletion() {
return completion;
}

/**
* @return the server
*/
public ServerSettings getServer() {
return server;
}

/**
* @param server the server to set
*/
public void setServer(ServerSettings server) {
this.server = server;
}

public static XMLGeneralClientSettings getGeneralXMLSettings(Object initializationOptionsSettings) {
return JSONUtility.toModel(initializationOptionsSettings, XMLGeneralClientSettings.class);
}
Expand Down

0 comments on commit b382345

Please sign in to comment.