Repository navigation
Support "Always Up" language servers - #289
Conversation
|
@martinlippert added some time ago https://github.com/eclipse/lsp4e/blob/master/org.eclipse.lsp4e/schema/languageServer.exsd#L145 . Setting this lastDocumentDisconnectedTimeout to Integer.MAX_VALUE should achieve good enough results already, with an uptime of 68 years. |
|
I actually think that keeping the language server running for a longer time (like Integer.MAX_VALUE) is only one part of the question. I think the other part (when to startup the language server) also requires some discussion. The PR from @BoykoAlex allows you to basically startup the language server at IDE startup time, independent of any project contents in your workspace. While I can see this could be useful, I think it would also be good to maybe have some kind of API on the extension that can decide when to start the language server, e.g.:
WDYT? |
|
I think from LSP4E perspective, we could adopt the proposed idea as it's not too intrusive. Or maybe, just have LSP4E providing an <extension point="org.eclipse.ui.startup">
<startup class="org.eclipse.lsp4e.LSStartup:org.eclipse.corrosion.rls"/>
</extension>? About allowing multiple strategies, including not yet identified one, I believe it can become too custom to be worth being standardized in LSP4E. Consumers of LSP4E would IMO be more efficient at implementing whichever hook or listener they want by themselves and trigger the LS startup. Maybe we need a bit more API for it to be easy though. |
|
I also use https://github.com/eclipse/lsp4e/blob/master/org.eclipse.lsp4e/schema/languageServer.exsd#L145 as a poor man solution, if there is an option to start the LS on startup or something more configurable, that would be a good addition. The proposed extension point would be just what we need if we combine with the Integer.MAX_VALUE to keep the server running, which we already use |
|
Reading the above, perhaps, all LSP4E needs is public |
|
I imagine you can already achieve a startup in your code with a combination like var definition = LanguageServerRegistry.getInstance().getDefinition(languageServerId);
var dummyFile = File.createTempFile("initLS", "someExtension");
var fileBufferManager = FileBuffersPlugin.getFileBufferManager();
var dummyDocument = fileBufferManager.getFileBufferManager().createEmptyDocument(new Path(dummyFile.getAbsolutePath()), LocationKind.LOCATION);
getInitializedLanguageServer(dummyDocument, definition, cap -> true) // actually starts the LS
.thenRun(() -> {
fileBufferManager.disconnect(dummyFile.getAbsolutePath(), LocationKind.LOCATION, null);
dummyFile.delete();
});But a shorter API such as |
|
@mickaelistria I'd stop at your proposal: Let us work out things on our side and if this is all we need (which is very likely) then I'll change this PR accordingly and prepare it to be merged. |
mickaelistria
left a comment
There was a problem hiding this comment.
Looks good. Please mark as "Ready for review" if this is ready to be merged on your end as well.
| startStopTimer(); | ||
| } else { | ||
| stop(); | ||
| if (!this.serverDefinition.alwaysUp) { |
There was a problem hiding this comment.
We already can set the timeout to a extremely high number, which would do the same, so I think we do not need this. Having an org.eclipse.lsp4e.LSStartup extension factory as proposed by @mickaelistria looks enough to me. Otherwise we have flags with overlapping concerns, which I think we do not yet need.
There was a problem hiding this comment.
Switched to a solution where we just have the method for starting the language server
| </enabledWhen> | ||
| </reconciler> | ||
| </extension> | ||
| </extension> |
There was a problem hiding this comment.
It would be good to remove this file form the commit.
| synchronized (startedServers) { | ||
| LanguageServerWrapper wrapper = startedServers.stream().filter(w -> w.serverDefinition == serverDefinition).findFirst().orElse(null); | ||
| if (wrapper == null) { | ||
| wrapper = new LanguageServerWrapper(serverDefinition, null); |
There was a problem hiding this comment.
This looks good to me and I would be happy to merge, but I was wondering if we could do better than orElse(null). Could we not just use new LanguageServerWrapper(serverDefinition, null) in the orElse() above and then just call startedServers.add(wrapper), the startedServers is a set so even if the wrapper is already in it, nothing bad should happen. If we want to avoid the add when the value was already present, we could use orElseGet().
What do you think about that?
There was a problem hiding this comment.
Sure, cleaning up as suggested above looks like a good idea
| } | ||
| } | ||
|
|
||
| public static LanguageServerWrapper startLanguageServer(@NonNull LanguageServerDefinition serverDefinition) throws IOException { |
There was a problem hiding this comment.
add @NonNull to the return value?
|
@BoykoAlex when it's ready to be merged, please click "Ready for review". |
|
@mickaelistria @rubenporras do you know what i can do with |
|
Hi @BoykoAlex, I do not know this API very well, but we have testers that override this method and then something like does it bring you further? |
|
@mickaelistria thank you - I'll give it a try... Was roaming yesterday through lsp4e code and after looking at https://github.com/eclipse/lsp4e/blob/dd39ca0db5e6abd3cb5f59a3e63cf6b2e1a20d46/org.eclipse.lsp4e/src/org/eclipse/lsp4e/enablement/EnablementTester.java#L61 I've decided that evaluation context is just instance of |
|
Ready to merge this one. I'll move |
|
@mickaelistria , ok to merge? |
|
Yes, let's just ensure we have a green CI build before merging (the last build had some rare but random test failure, let's just verify it's not persistent) |
|
Thanks! |
Draft implementation of "alwaysUp" attribute for language server extension point.