[POM-leading for DSLs] Dynamic capabilities#1117
Conversation
222849f to
43787d2
Compare
1. Set document selectors for capabilities, such that capabilities can only be triggered on documents that support them. Especially useful when registering multiple languages. 2. Dynamically register semantic highlighting capability (to test the former change, and make a start with registering all capabilities dynamically). 3. Instead of toggling the language for open editors, request a refresh of the open editors via LSP. This prevents races where requests can come in while the file is 'closed'. This PR is a preparation to easily enable #1117.
2fdc776 to
45b8638
Compare
f001c98 to
52aeaaa
Compare
52aeaaa to
76aeb65
Compare
76aeb65 to
62ffc76
Compare
This reverts commit 2f5646c.
…010-pom-leading-for-dsls/1079-dynamic-capabilities
DavyLandman
left a comment
There was a problem hiding this comment.
Looks nice! Just some small points.
| public class CompletableFutureUtils { | ||
| private CompletableFutureUtils() {/* hidden */ } | ||
|
|
||
| public static final CompletableFuture<Void> NOOP = CompletableFuture.completedFuture(null); |
There was a problem hiding this comment.
while this is nice, it has no exec bound to it? isn't that a problem?
|
|
||
| private CompletableFuture<Void> registerCapability(Registration r) { | ||
| var c = currentRegistrations.computeIfAbsent(r.getMethod(), k -> new CopyOnWriteArraySet<>()); | ||
| // Lock on the registrations for this method for a moment |
There was a problem hiding this comment.
can we explain why we lock? who else might be doing this registration?
and why we lock for so long?
My concern is that the exceptionally handler that manipulates c is executed outside the lock (and not relocking).
| return client.unregisterCapability(new UnregistrationParams(List.of(u))) | ||
| .exceptionally(t -> { | ||
| logger.error("Exception while unregistering {} ({})", u.getMethod(), u, t); | ||
| c.addAll(cs); |
There was a problem hiding this comment.
same here, no lock here, is that fine? and if so, let's explain why.
| set[LanguageService] testingLanguageServerSlowSummary() = testingLanguageServerSlowSummary(false); | ||
| set[LanguageService] testingLanguageServerSlowSummaryWithRecovery() = testingLanguageServerSlowSummary(true); | ||
|
|
||
| void register(bool errorRecovery=false) { |
There was a problem hiding this comment.
why is the default switched?
There was a problem hiding this comment.
Because I wanted error recovery enabled in the mixed DSL tests, and the JSON server has it enabled by default. I figured it doesn't hurt - the DSL test explicitly set the value anyway, and for user testing error recovery is useful as well.
The alternative is to set it explicitly in the mixed DSL tests, and add this flag to the JSON testing server (or accept a warning for an unknown keyword argument).
…010-pom-leading-for-dsls/1079-dynamic-capabilities
|



Implement dynamic capabilities for POM-leading servers.
Closes #1079.