[POM-leading for DSLs] Routing to dedicated remote language servers#1069
Conversation
…ing-for-dsls-redo
7bf6060 to
017ab39
Compare
683fef2 to
6ee7eca
Compare
8e1ed67 to
b434ff4
Compare
| } | ||
|
|
||
| public SemanticTokensWithRegistrationOptions options() { | ||
| public static SemanticTokensWithRegistrationOptions options() { |
There was a problem hiding this comment.
This change allows us to make ParametricTextDocumentService::setStaticServerCapabilities static as well and re-use it in the new RoutingTextDocumentService
|
|
||
| RascalWorkspaceService(ExecutorService exec, IBaseTextDocumentService documentService) { | ||
| super(exec, documentService); | ||
| RascalWorkspaceService(ExecutorService exec) { |
There was a problem hiding this comment.
This argument is replaced by a pair function
b434ff4 to
6f475fe
Compare
600df56 to
3ed29d4
Compare
3ed29d4 to
2b01979
Compare
|
| , "-cp", classPath | ||
| , "org.rascalmpl.vscode.lsp.parametric.ParametricLanguageServer" | ||
| , "--exitWhenEmpty" | ||
| // , new GsonBuilder().create().toJson(lang, LanguageParameter.class).replace("\"", "\\\"") // escape JSON string on command line |
There was a problem hiding this comment.
It would be nice you use the dedicated language feature of the parametric LSP here, but then we should also probably swallow the registerLanguage call that triggered this, as otherwise, we are registering twice and wasting resources.
DavyLandman
left a comment
There was a problem hiding this comment.
I think this is heading in the right direction. But it's not ready yet.
| private final Map<String, String> languagesByExtension = new ConcurrentHashMap<>(); | ||
| // NOTE | ||
| // 1. This map should only contains running server processes. | ||
| // 2. Upon removal from this map, the process should be killed to avoid resource leaks. |
There was a problem hiding this comment.
we should also register a shutdown hook to always close our child processes.
| } | ||
|
|
||
| public CompletableFuture<IBaseLanguageServerExtensions> route(String extension) { | ||
| return safeLanguage(extension).map(this::languageByName).orElseThrow(() -> { |
There was a problem hiding this comment.
this exception is thrown in the context of route not in the context of the completable future, so that might be not so nice.
Same is true for the safeLanguage exception.
| } | ||
|
|
||
| private static String classPath(LanguageParameter lang) { | ||
| var separator = System.getProperty("path.separator"); |
There was a problem hiding this comment.
let's use File.pathSeparator instead. (this maybe negates the need for this).
| } catch (IOException e) { | ||
| logger.error("Error while parsing path config {}", lang.getPathConfig(), e); | ||
| logger.warn("Could not compute class path for {}; falling back to class path of routing server", lang.getName()); | ||
| return System.getProperty("java.class.path"); |
There was a problem hiding this comment.
I'm not sure if we should have a fallback like this. It can lead to all kinds of down stream errors that a user didn't suspect, all because of like some parse error in the pom.xml that wasn't reported to the user as a breaking error.
| // Check if we are in Rascal-LSP | ||
| var classPath = new StringBuilder(); | ||
| if (isRascalLspProject(rootProject)) { | ||
| classPath.append(separator); |
There was a problem hiding this comment.
Maybe we should collect all entries in a list, and then at the end join them with the path sep as element seperator?
so that he final substring can also be skipped.
| @SuppressWarnings("unused") | ||
| private final ExecutorService exec; |
There was a problem hiding this comment.
why keep it around if we don't use it?
| this.parentServer = server; | ||
| } | ||
|
|
||
| private ActualRoutingLanguageServer availableServer() { |
There was a problem hiding this comment.
I don't understand this extra edge, why do we need to loop back to the server? I've had this same question when reading this PR, I don't like all these cycles, so can we do without?
| .thenCompose(s -> s.getWorkspaceService().executeCommand(commandParams)); | ||
| } | ||
|
|
||
| return CompletableFutureUtils.completedFuture(commandParams.getCommand() + " was ignored.", getExecutor()); |
There was a problem hiding this comment.
can we say why it was ignored?
| @JsonDelegate | ||
| IBaseTextDocumentService getIBaseTextDocumentService(); |
There was a problem hiding this comment.
Why this extension? can we add a comment? I don't see how the IBaseTextDocumentService could ever be serialized over json?
| try { | ||
| root = resolveLocation(|project://rascal-lsp|); | ||
| } catch SchemeNotSupported(_): { | ||
| root = resolveLocation(|cwd:///../../../rascal-lsp|); |
There was a problem hiding this comment.
let's add a comment to explain why we're doing this.



This PR is the first of a series. gradually implementing POM-leading behavior in DSLs/the parametric server.
This PR introduces a routing language server, which delegates incoming LSP requests to the appropriate parametric language server, dedicated to a single language. A dedicated server is started upon initial language registration.
Closes #1076