mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
replace QueryWrapper with non-parameterized QueryExecutionInterceptor
GitOrigin-RevId: 04bb5d6da9c0fa11bbb7251a3500d5d89b93d000
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b19cadb360
commit
cd5f782c15
@@ -441,6 +441,7 @@ f:com.intellij.util.CoroutinesKt
|
||||
- *bs:awaitCancellationAndInvoke$default(kotlinx.coroutines.CoroutineScope,kotlin.coroutines.CoroutineContext,kotlin.jvm.functions.Function2,I,java.lang.Object):V
|
||||
f:com.intellij.util.ExecutorsQuery
|
||||
- com.intellij.util.AbstractQuery
|
||||
- *:interceptWith(com.intellij.util.QueryExecutionInterceptor):com.intellij.util.Query
|
||||
- *:wrap(com.intellij.util.QueryWrapper):com.intellij.util.Query
|
||||
*a:com.intellij.util.PerformanceAssertions
|
||||
- *sf:Companion:com.intellij.util.PerformanceAssertions$Companion
|
||||
@@ -453,9 +454,12 @@ com.intellij.util.Query
|
||||
- java.lang.Iterable
|
||||
- *:filtering(java.util.function.Predicate):com.intellij.util.Query
|
||||
- *:flatMapping(java.util.function.Function):com.intellij.util.Query
|
||||
- *:interceptWith(com.intellij.util.QueryExecutionInterceptor):com.intellij.util.Query
|
||||
- *:mapping(java.util.function.Function):com.intellij.util.Query
|
||||
- *:transforming(java.util.function.Function):com.intellij.util.Query
|
||||
- *:wrap(com.intellij.util.QueryWrapper):com.intellij.util.Query
|
||||
*:com.intellij.util.QueryExecutionInterceptor
|
||||
- a:intercept(kotlin.jvm.functions.Function0):Z
|
||||
com.intellij.util.QueryExecutor
|
||||
- *:wrap(com.intellij.util.QueryWrapper):com.intellij.util.QueryExecutor
|
||||
*:com.intellij.util.QueryWrapper
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
@@ -44,9 +45,24 @@ public final class ExecutorsQuery<Result, Parameter> extends AbstractQuery<Resul
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"deprecation", "MissingDeprecatedAnnotation"})
|
||||
@ScheduledForRemoval
|
||||
@Deprecated
|
||||
@Experimental
|
||||
@Override
|
||||
public @NotNull Query<Result> wrap(@NotNull QueryWrapper<Result> wrapper) {
|
||||
return new ExecutorsQuery<>(myParameters, ContainerUtil.map(myExecutors, e -> e.wrap(wrapper)));
|
||||
}
|
||||
|
||||
@Experimental
|
||||
@Override
|
||||
public @NotNull Query<Result> interceptWith(@NotNull QueryExecutionInterceptor interceptor) {
|
||||
return new ExecutorsQuery<>(myParameters, ContainerUtil.map(myExecutors, e -> interceptWith(e, interceptor)));
|
||||
}
|
||||
|
||||
private static <R, P> QueryExecutor<R, P> interceptWith(QueryExecutor<R, P> executor, QueryExecutionInterceptor interceptor) {
|
||||
return (parameters, consumer) -> {
|
||||
return interceptor.intercept(() -> executor.execute(parameters, consumer));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util;
|
||||
|
||||
import com.intellij.concurrency.AsyncFuture;
|
||||
import com.intellij.concurrency.AsyncUtil;
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -127,6 +128,22 @@ public interface Query<Result> extends Iterable<Result> {
|
||||
return findAll().iterator();
|
||||
}
|
||||
|
||||
@Experimental
|
||||
default @NotNull Query<Result> interceptWith(@NotNull QueryExecutionInterceptor interceptor) {
|
||||
Query<Result> query = this;
|
||||
return new AbstractQuery<Result>() {
|
||||
@Override
|
||||
protected boolean processResults(@NotNull Processor<? super Result> consumer) {
|
||||
return interceptor.intercept(() -> delegateProcessResults(query, consumer));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #interceptWith}
|
||||
*/
|
||||
@ScheduledForRemoval
|
||||
@Deprecated
|
||||
@Experimental
|
||||
default @NotNull Query<Result> wrap(@NotNull QueryWrapper<Result> wrapper) {
|
||||
Query<Result> query = this;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental
|
||||
|
||||
@Experimental
|
||||
fun interface QueryExecutionInterceptor {
|
||||
|
||||
/**
|
||||
* Implementation is expected to call [invocation] and return its value.
|
||||
*/
|
||||
fun intercept(invocation: () -> Boolean): Boolean
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -21,6 +22,8 @@ public interface QueryExecutor<Result, Param> {
|
||||
*/
|
||||
boolean execute(@NotNull Param queryParameters, @NotNull Processor<? super Result> consumer);
|
||||
|
||||
@ScheduledForRemoval
|
||||
@Deprecated
|
||||
@Experimental
|
||||
default @NotNull QueryExecutor<Result, Param> wrap(@NotNull QueryWrapper<Result> wrapper) {
|
||||
return (queryParameters, consumer) -> wrapper.wrapExecution(c -> execute(queryParameters, c), consumer);
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental;
|
||||
import org.jetbrains.annotations.ApiStatus.ScheduledForRemoval;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link QueryExecutionInterceptor}
|
||||
*/
|
||||
@ScheduledForRemoval
|
||||
@Deprecated
|
||||
@Experimental
|
||||
@FunctionalInterface
|
||||
public interface QueryWrapper<Result> {
|
||||
|
||||
Reference in New Issue
Block a user