From c3563824527cb23e20f87878dcfbb177b55c3334 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 25 Jan 2011 20:16:49 +0100 Subject: [PATCH] all the state concerning restart is now covered by the phase --- .../completion/CodeCompletionHandlerBase.java | 2 +- .../CompletionProgressIndicator.java | 20 +++------------ .../completion/CompletionState.java | 25 ------------------- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java index a9db64faa5ed..8bb911a89793 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -309,7 +309,7 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { final ApplicationAdapter listener = new ApplicationAdapter() { @Override public void beforeWriteActionStart(Object action) { - indicator.cancelByWriteAction(); + indicator.scheduleRestart(); } }; ApplicationManager.getApplication().addApplicationListener(listener); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index b74b7ebe0f81..8dcdc80e8778 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -413,7 +413,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } private void finishCompletionProcess() { - myState.setToRestart(false); cancel(); myState.setCompletionDisposed(true); @@ -450,8 +449,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement if (isOutdated()) return; if (!isBackgrounded()) return; - if (isCanceled() && myState.isRestartScheduled()) { - CompletionServiceImpl.assertPhase(CompletionPhase.Restarted.class); + if (CompletionServiceImpl.isPhase(CompletionPhase.Restarted.class)) { return; } @@ -511,13 +509,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement return false; } - public void cancelByWriteAction() { - myState.setToRestart(true); - cancel(); - - scheduleRestart(); - } - public boolean fillInCommonPrefix(final boolean explicit) { if (isInsideIdentifier()) { return false; @@ -608,12 +599,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } public void prefixUpdated() { - if (myState.isToRestart()) { - scheduleRestart(); - return; - } - - final CharSequence text = myEditor.getDocument().getCharsSequence(); final int caretOffset = myEditor.getCaretModel().getOffset(); for (Pair> pair : myRestartingPrefixConditions) { @@ -629,8 +614,9 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } public void scheduleRestart() { + cancel(); + ApplicationManager.getApplication().assertIsDispatchThread(); - myState.scheduleRestart(); final CompletionPhase phase = new CompletionPhase.Restarted(); CompletionServiceImpl.setCompletionPhase(phase); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java index 217d9ded93c4..5e620d64f54b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java @@ -11,8 +11,6 @@ public class CompletionState { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.CompletionState"); private boolean myCompletionDisposed; private boolean myShownLookup; - private Boolean myToRestart; - private boolean myRestartScheduled; private boolean myModifiersChanged; private boolean myBackgrounded; private volatile boolean myFocusLookupWhenDone; @@ -40,27 +38,6 @@ public class CompletionState { myShownLookup = shownLookup; } - public boolean isToRestart() { - return myToRestart == Boolean.TRUE; - } - - public void setToRestart(boolean toRestart) { - if (toRestart && myToRestart != null) { - LOG.assertTrue(myToRestart == Boolean.FALSE, this); //explicit completionFinished was invoked before this write action - return; - } - - myToRestart = toRestart; - } - - public boolean isRestartScheduled() { - return myRestartScheduled; - } - - public void scheduleRestart() { - myRestartScheduled = true; - } - public boolean areModifiersChanged() { return myModifiersChanged; } @@ -118,8 +95,6 @@ public class CompletionState { "phase=" + CompletionServiceImpl.getCompletionPhase() + ", myCompletionDisposed=" + myCompletionDisposed + ", myShownLookup=" + myShownLookup + - ", myToRestart=" + myToRestart + - ", myRestartScheduled=" + myRestartScheduled + ", myModifiersReleased=" + myModifiersChanged + ", myBackgrounded=" + myBackgrounded + ", myFocusLookupWhenDone=" + myFocusLookupWhenDone +