diff --git a/platform/core-api/src/org/jetbrains/concurrency/InternalPromiseUtil.java b/platform/core-api/src/org/jetbrains/concurrency/InternalPromiseUtil.java
index 3f9e5e2a81ad..fb343abe3459 100644
--- a/platform/core-api/src/org/jetbrains/concurrency/InternalPromiseUtil.java
+++ b/platform/core-api/src/org/jetbrains/concurrency/InternalPromiseUtil.java
@@ -77,7 +77,7 @@ public class InternalPromiseUtil {
@NotNull
public Promise.State getState() {
- return error == null ? Promise.State.FULFILLED : Promise.State.REJECTED;
+ return error == null ? Promise.State.SUCCEEDED : Promise.State.REJECTED;
}
public boolean isCancelled() {
diff --git a/platform/core-api/src/org/jetbrains/concurrency/Promise.java b/platform/core-api/src/org/jetbrains/concurrency/Promise.java
index c66bb576081f..c28fa2246c55 100644
--- a/platform/core-api/src/org/jetbrains/concurrency/Promise.java
+++ b/platform/core-api/src/org/jetbrains/concurrency/Promise.java
@@ -22,13 +22,13 @@ import java.util.concurrent.TimeoutException;
*
*
* - pending: initial state, neither fulfilled nor rejected.
- * - fulfilled: meaning that the operation completed successfully.
+ * - succeeded: meaning that the operation completed successfully.
* - rejected: meaning that the operation failed.
*
*/
public interface Promise {
enum State {
- PENDING, FULFILLED, REJECTED
+ PENDING, SUCCEEDED, REJECTED
}
/**
@@ -139,4 +139,8 @@ public interface Promise {
default T blockingGet(int timeout) throws TimeoutException, ExecutionException {
return blockingGet(timeout, TimeUnit.MILLISECONDS);
}
+
+ default boolean isSucceeded() {
+ return getState() == State.SUCCEEDED;
+ }
}
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
index 8fc26e5eee3a..8bd247b25c72 100644
--- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
+++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java
@@ -207,7 +207,7 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
}
// We assume that data context from focus-based retrieval should success if performed from EDT.
Promise asyncResult = DataManager.getInstance().getDataContextFromFocusAsync();
- if (asyncResult.getState() == Promise.State.FULFILLED) {
+ if (asyncResult.isSucceeded()) {
Editor editor = null;
try {
editor = CommonDataKeys.EDITOR.getData(asyncResult.blockingGet(-1));
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/NonBlockingReadActionImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/NonBlockingReadActionImpl.java
index da3393a4fe9a..14fddbd82850 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/NonBlockingReadActionImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/NonBlockingReadActionImpl.java
@@ -139,7 +139,7 @@ class NonBlockingReadActionImpl implements NonBlockingReadAction {
void safeTransferToEdt(T result, Pair> edtFinish, ProgressIndicator indicator) {
if (Promises.isRejected(promise)) return;
-
+
Semaphore semaphore = new Semaphore(1);
ApplicationManager.getApplication().invokeLater(() -> {
if (checkObsolete()) {
@@ -147,13 +147,13 @@ class NonBlockingReadActionImpl implements NonBlockingReadAction {
return;
}
- // complete the promise now to prevent write actions inside custom callback from cancelling it
+ // complete the promise now to prevent write actions inside custom callback from cancelling it
promise.setResult(result);
// now background thread may release its read lock, and we continue on EDT, invoking custom callback
semaphore.up();
- if (Promises.isFulfilled(promise)) { // in case another thread managed to cancel it just before `setResult`
+ if (promise.isSucceeded()) { // in case another thread managed to cancel it just before `setResult`
edtFinish.second.accept(result);
}
}, edtFinish.first);
diff --git a/platform/platform-impl/src/org/jetbrains/concurrency/AsyncValueLoader.java b/platform/platform-impl/src/org/jetbrains/concurrency/AsyncValueLoader.java
index 7ee64bb2315d..6f76abf36c0f 100644
--- a/platform/platform-impl/src/org/jetbrains/concurrency/AsyncValueLoader.java
+++ b/platform/platform-impl/src/org/jetbrains/concurrency/AsyncValueLoader.java
@@ -32,7 +32,7 @@ public abstract class AsyncValueLoader {
public final T getResultIfFullFilled() {
Promise result = ref.get();
try {
- return (result != null && result.getState() == Promise.State.FULFILLED) ? result.blockingGet(0) : null;
+ return (result != null && result.isSucceeded()) ? result.blockingGet(0) : null;
}
catch (TimeoutException | ExecutionException e) {
return null;
@@ -87,7 +87,7 @@ public abstract class AsyncValueLoader {
// if current promise is not processed, so, we don't need to check cache state
return promise;
}
- else if (state == Promise.State.FULFILLED) {
+ else if (state == Promise.State.SUCCEEDED) {
//noinspection unchecked
if (!checkFreshness || isUpToDate()) {
return promise;
diff --git a/platform/platform-impl/src/org/jetbrains/concurrency/PromiseManager.java b/platform/platform-impl/src/org/jetbrains/concurrency/PromiseManager.java
index 39237559fe7c..3d790ce23341 100644
--- a/platform/platform-impl/src/org/jetbrains/concurrency/PromiseManager.java
+++ b/platform/platform-impl/src/org/jetbrains/concurrency/PromiseManager.java
@@ -43,7 +43,7 @@ public abstract class PromiseManager {
public final boolean has(HOST host) {
Promise result = fieldUpdater.get(host);
- return result != null && result.getState() == Promise.State.FULFILLED;
+ return result != null && result.isSucceeded();
}
@Nullable
@@ -76,7 +76,7 @@ public abstract class PromiseManager {
// if current promise is not processed, so, we don't need to check cache state
return promise;
}
- else if (state == Promise.State.FULFILLED) {
+ else if (state == Promise.State.SUCCEEDED) {
//noinspection unchecked
try {
if (!checkFreshness || isUpToDate(host, promise.blockingGet(0))) {
diff --git a/platform/platform-tests/testSrc/com/intellij/ui/tree/AbstractTreeWalkerTest.java b/platform/platform-tests/testSrc/com/intellij/ui/tree/AbstractTreeWalkerTest.java
index 11922776222c..e3351a5f4fe3 100644
--- a/platform/platform-tests/testSrc/com/intellij/ui/tree/AbstractTreeWalkerTest.java
+++ b/platform/platform-tests/testSrc/com/intellij/ui/tree/AbstractTreeWalkerTest.java
@@ -412,7 +412,7 @@ public class AbstractTreeWalkerTest {
switch (walker.promise().getState()) {
case PENDING:
throw new IllegalStateException("not processed");
- case FULFILLED:
+ case SUCCEEDED:
if (!error) break;
throw new IllegalStateException("not rejected");
case REJECTED:
diff --git a/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt b/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt
index 4835d1d2903c..f5ec6d9f2b75 100644
--- a/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt
+++ b/platform/projectModel-api/src/org/jetbrains/concurrency/AsyncPromise.kt
@@ -23,7 +23,7 @@ open class AsyncPromise : InternalPromiseUtil.BasePromise(), Cancel
private val valueRef = AtomicReference?>(null)
override fun onSuccess(handler: Consumer): Promise {
- setHandler(doneRef, handler, State.FULFILLED)
+ setHandler(doneRef, handler, State.SUCCEEDED)
return this
}
@@ -93,7 +93,7 @@ open class AsyncPromise : InternalPromiseUtil.BasePromise(), Cancel
}
private fun addHandlers(done: Consumer, rejected: Consumer) {
- setHandler(doneRef, done, State.FULFILLED)
+ setHandler(doneRef, done, State.SUCCEEDED)
setHandler(rejectedRef, rejected, State.REJECTED)
}
@@ -226,7 +226,7 @@ open class AsyncPromise : InternalPromiseUtil.BasePromise(), Cancel
val currentState = value.state
if (currentState == targetState) {
@Suppress("UNCHECKED_CAST")
- newConsumer.accept(if (currentState == State.FULFILLED) value.result as C_T else value.error as C_T)
+ newConsumer.accept(if (currentState == State.SUCCEEDED) value.result as C_T else value.error as C_T)
}
}
diff --git a/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt b/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt
index 6a6df96b7570..a92008528dee 100644
--- a/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt
+++ b/platform/projectModel-api/src/org/jetbrains/concurrency/promise.kt
@@ -21,9 +21,6 @@ val Promise<*>.isRejected: Boolean
val Promise<*>.isPending: Boolean
get() = state == Promise.State.PENDING
-val Promise<*>.isFulfilled: Boolean
- get() = state == Promise.State.FULFILLED
-
private val REJECTED: Promise<*> by lazy { DonePromise(InternalPromiseUtil.PromiseValue.createRejected(createError("rejected"))) }
@Suppress("UNCHECKED_CAST")
diff --git a/platform/script-debugger/debugger-ui/src/RemoteVmConnection.kt b/platform/script-debugger/debugger-ui/src/RemoteVmConnection.kt
index f7dd5bdfbbba..fa1e8afe26fe 100644
--- a/platform/script-debugger/debugger-ui/src/RemoteVmConnection.kt
+++ b/platform/script-debugger/debugger-ui/src/RemoteVmConnection.kt
@@ -90,7 +90,7 @@ abstract class RemoteVmConnection : VmConnection() {
connectResult.handleThrowable(Consumer { result.setError(it) })
val channel = connectResult.channel
channel?.closeFuture()?.addListener {
- if (result.isFulfilled) {
+ if (result.isSucceeded) {
close("Process disconnected unexpectedly", ConnectionStatus.DISCONNECTED)
}
}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/actions/MavenProjectModelModifierTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/actions/MavenProjectModelModifierTest.java
index 6529ecf1f36f..4bcd0301cc2b 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/actions/MavenProjectModelModifierTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/actions/MavenProjectModelModifierTest.java
@@ -1,18 +1,4 @@
-/*
- * Copyright 2000-2017 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Copyright 2000-2018 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.
package org.jetbrains.idea.maven.actions;
import com.intellij.openapi.module.EffectiveLanguageLevelUtil;
@@ -238,7 +224,7 @@ public class MavenProjectModelModifierTest extends MavenDomWithIndicesTestCase {
myProjectsManager.waitForArtifactsDownloadingCompletion();
performPostImportTasks();
myProjectsManager.performScheduledImportInTests();
- assertSame(Promise.State.FULFILLED, result.getState());
+ assertSame(Promise.State.SUCCEEDED, result.getState());
}
private MavenProjectModelModifier getExtension() {