diff --git a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java index 4a72e09dcd8e..579f64c4a587 100644 --- a/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java +++ b/platform/core-api/src/com/intellij/openapi/application/ModalityInvokator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -13,16 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.openapi.application; import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Condition; import org.jetbrains.annotations.NotNull; +/** + * @author max + */ public interface ModalityInvokator { /** * Causes runnable.run() to be executed asynchronously on the diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java index fb99c5c9af7f..f58965e756d4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/LaterInvocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -51,22 +51,21 @@ public class LaterInvocator { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.application.impl.LaterInvocator"); private static final boolean DEBUG = LOG.isDebugEnabled(); - public static final Object LOCK = new Object(); //public for tests + private static final Object LOCK = new Object(); private static final IdeEventQueue ourEventQueue = IdeEventQueue.getInstance(); private static final FrequentEventDetector ourFrequentEventDetector = new FrequentEventDetector(1009, 100); - private LaterInvocator() { - } + private LaterInvocator() { } private static class RunnableInfo { @NotNull private final Runnable runnable; @NotNull private final ModalityState modalityState; - @NotNull private final Condition expired; + @NotNull private final Condition expired; @NotNull private final ActionCallback callback; public RunnableInfo(@NotNull Runnable runnable, @NotNull ModalityState modalityState, - @NotNull Condition expired, + @NotNull Condition expired, @NotNull ActionCallback callback) { this.runnable = runnable; this.modalityState = modalityState; @@ -101,7 +100,9 @@ public class LaterInvocator { int index = ourModalEntities.indexOf(window); if (index < 0) { Window owner = window.getOwner(); - if (owner == null) return (ModalityStateEx)ApplicationManager.getApplication().getNoneModalityState(); + if (owner == null) { + return (ModalityStateEx)ApplicationManager.getApplication().getNoneModalityState(); + } ModalityStateEx ownerState = modalityStateForWindow(owner); if (window instanceof Dialog && ((Dialog)window).isModal()) { return ownerState.appendEntity(window); @@ -109,22 +110,18 @@ public class LaterInvocator { return ownerState; } - ArrayList result = new ArrayList(); + List result = new ArrayList(); for (Object entity : ourModalEntities) { - if (entity instanceof Window) { + if (entity instanceof Window || + entity instanceof ProgressIndicator && ((ProgressIndicator)entity).isModal()) { result.add(entity); } - else if (entity instanceof ProgressIndicator) { - if (((ProgressIndicator)entity).isModal()) { - result.add(entity); - } - } } return new ModalityStateEx(result.toArray()); } @NotNull - static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired) { + static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired) { ModalityState modalityState = ModalityState.defaultModalityState(); return invokeLater(runnable, modalityState, expired); } @@ -135,9 +132,7 @@ public class LaterInvocator { } @NotNull - static ActionCallback invokeLater(@NotNull Runnable runnable, - @NotNull ModalityState modalityState, - @NotNull Condition expired) { + static ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState modalityState, @NotNull Condition expired) { ourFrequentEventDetector.eventHappened(); final ActionCallback callback = new ActionCallback(); @@ -332,13 +327,8 @@ public class LaterInvocator { lastInfo.runnable.run(); lastInfo.callback.setDone(); } - catch (ProcessCanceledException ex) { - // ignore - } + catch (ProcessCanceledException ignored) { } catch (Throwable t) { - if (t instanceof StackOverflowError) { - t.printStackTrace(); - } LOG.error(t); } finally { @@ -354,9 +344,8 @@ public class LaterInvocator { } @Override - @NonNls public String toString() { - return "LaterInvocator.FlushQueue" + (myLastInfo == null ? "" : " lastInfo="+myLastInfo); + return "LaterInvocator.FlushQueue" + (myLastInfo == null ? "" : " lastInfo=" + myLastInfo); } } @@ -366,20 +355,4 @@ public class LaterInvocator { return ContainerUtil.newArrayList(ourQueue); } } - - @TestOnly - static String dumpQueue() { - synchronized (LOCK) { - @NonNls String result = ""; - if (!ourForcedFlushQueue.isEmpty()) { - result = "(Forced queue: " + ourForcedFlushQueue + ") "; - } - List r = new ArrayList(ourQueue); - result += r + (ourQueueSkipCount == 0 ? "" : " (ourQueueSkipCount="+ourQueueSkipCount+")") - + (ourModalEntities.isEmpty() ? " (non-modal)" : " (modal entities: "+ourModalEntities+")" - + (FLUSHER_SCHEDULED.get() ? " (Flusher scheduled)" : "") - ); - return result; - } - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java index 07b55a6e4010..dbb164ea7cac 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityInvokatorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -13,10 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * @author max - */ package com.intellij.openapi.application.impl; import com.intellij.openapi.application.ApplicationManager; @@ -26,9 +22,11 @@ import com.intellij.openapi.util.ActionCallback; import com.intellij.openapi.util.Condition; import org.jetbrains.annotations.NotNull; +/** + * @author max + */ class ModalityInvokatorImpl implements ModalityInvokator { - ModalityInvokatorImpl() { - } + ModalityInvokatorImpl() { } @NotNull @Override @@ -38,13 +36,13 @@ class ModalityInvokatorImpl implements ModalityInvokator { @NotNull @Override - public ActionCallback invokeLater(@NotNull final Runnable runnable, @NotNull final Condition expired) { + public ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull Condition expired) { return LaterInvocator.invokeLater(runnable, expired); } @NotNull @Override - public ActionCallback invokeLater(@NotNull final Runnable runnable, @NotNull final ModalityState state, @NotNull final Condition expired) { + public ActionCallback invokeLater(@NotNull Runnable runnable, @NotNull ModalityState state, @NotNull Condition expired) { return LaterInvocator.invokeLater(runnable, state, expired); }