forked from eclipse-lemminx/lemminx-maven
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show with progress bar the load of long process
Fixes eclipse-lemminx#471 Signed-off-by: azerr <azerr@redhat.com>
- Loading branch information
1 parent
c1df034
commit 27897e9
Showing
4 changed files
with
175 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...-maven/src/main/java/org/eclipse/lemminx/extensions/maven/utils/MyCompletableFutures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.eclipse.lemminx.extensions.maven.utils; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Function; | ||
|
||
import org.eclipse.lsp4j.jsonrpc.CancelChecker; | ||
|
||
public class MyCompletableFutures { | ||
|
||
/** | ||
* A utility method to create a {@link CompletableFuture} with cancellation | ||
* support. | ||
* | ||
* @param code a function that accepts a {@link CancelChecker} and returns the | ||
* to be computed value | ||
* @return a future | ||
*/ | ||
public static <R> CompletableFuture<R> computeAsync(Function<CancelChecker, R> code) { | ||
return org.eclipse.lsp4j.jsonrpc.CompletableFutures.computeAsync(code); | ||
} | ||
|
||
public static <R> CompletableFuture<R> computeAsyncCompose(Function<CancelChecker, CompletableFuture<R>> code) { | ||
CompletableFuture<CancelChecker> start = new CompletableFuture<>(); | ||
CompletableFuture<R> result = start.thenComposeAsync(code); | ||
start.complete(new org.eclipse.lsp4j.jsonrpc.CompletableFutures.FutureCancelChecker(result)); | ||
return result; | ||
} | ||
} |