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

chore: Support Jetbrains IDEs 243 - take into account that addListene… #6782

Merged
merged 1 commit into from
Sep 24, 2024
Merged
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 @@ -19,16 +19,35 @@
import com.intellij.openapi.Disposable;
import com.intellij.openapi.components.ComponentManagerEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;

import com.intellij.util.JavaCoroutines;
import com.intellij.vfs.AsyncVfsEventsListener;
import com.intellij.vfs.AsyncVfsEventsPostProcessor;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Consumer;

// #api242
public class AsyncVfsEventsPostProcessorCompat {
private AsyncVfsEventsPostProcessorCompat(){

}

public static void addListener(AsyncVfsEventsListener listener, Disposable disposable, Project project) {
AsyncVfsEventsPostProcessor.getInstance().addListener(listener, ((ComponentManagerEx)project).getCoroutineScope());
public static void addListener(Consumer<List<? extends VFileEvent>> listener, Disposable disposable, Project project) {
AsyncVfsEventsPostProcessor.getInstance().addListener(new AsyncVfsEventsListener() {
@Override
public @Nullable Object filesChanged(@NotNull List<? extends VFileEvent> list, @NotNull Continuation<? super Unit> continuation) {
return JavaCoroutines.suspendJava(javaContinuation -> {
listener.accept(list);
javaContinuation.resume(Unit.INSTANCE);
}
, continuation);
}
}, ((ComponentManagerEx) project).getCoroutineScope());
}
}
Loading