Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2201.12.x] Add a notification to publish artifacts to the client #43963

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @since 2201.1.1
*/
public class EventSyncPubSubHolder {

private static final LanguageServerContext.Key<EventSyncPubSubHolder> SUBSCRIBERS_HOLDER_KEY =
new LanguageServerContext.Key<>();
private static final Map<EventKind, EventPublisher> publisherMap = new HashMap<>();
Expand All @@ -56,8 +57,8 @@ private void initialize(LSClientLogger lsClientLogger) {

ServiceLoader<EventPublisher> publishers = ServiceLoader.load(EventPublisher.class);
publishers.forEach(eventPublisher -> {
for (EventSubscriber eventSubscriber: eventSubscribersMap.get(eventPublisher.getKind())) {
publisherMap.put(eventPublisher.getKind(), eventPublisher);
publisherMap.put(eventPublisher.getKind(), eventPublisher);
for (EventSubscriber eventSubscriber : eventSubscribersMap.get(eventPublisher.getKind())) {
eventPublisher.subscribe(eventSubscriber);
lsClientLogger.logTrace(String.format("%s subscribed to %s", eventSubscriber.getName(),
eventPublisher.getName()));
Expand All @@ -73,9 +74,13 @@ private void initialize(LSClientLogger lsClientLogger) {
public static EventSyncPubSubHolder getInstance(LanguageServerContext serverContext) {
EventSyncPubSubHolder subscribersHolder = serverContext.get(SUBSCRIBERS_HOLDER_KEY);
if (subscribersHolder == null) {
subscribersHolder = new EventSyncPubSubHolder(serverContext);
synchronized (SUBSCRIBERS_HOLDER_KEY) {
subscribersHolder = serverContext.get(SUBSCRIBERS_HOLDER_KEY);
if (subscribersHolder == null) {
subscribersHolder = new EventSyncPubSubHolder(serverContext);
}
}
}

return subscribersHolder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void publish(ExtendedLanguageClient client, LanguageServerContext serverC
Executor delayedExecutor = CompletableFuture.delayedExecutor(DIAGNOSTIC_DELAY, TimeUnit.SECONDS);
CompletableFuture<Boolean> scheduledFuture = CompletableFuture.supplyAsync(() -> true, delayedExecutor);
latestScheduled = scheduledFuture;
scheduledFuture.thenAcceptAsync(aBoolean ->
subscribers.forEach(subscriber -> subscriber.onEvent(client, context, serverContext)));
scheduledFuture.thenAcceptAsync(aBoolean -> subscribers.parallelStream()
.forEach(subscriber -> subscriber.onEvent(client, context, serverContext)));
}
}
Loading