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 b49dffe51835..da299b23c2f2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CodeCompletionHandlerBase.java @@ -487,7 +487,6 @@ public class CodeCompletionHandlerBase implements CodeInsightActionHandler { else if (decision instanceof AutoCompletionDecision.InsertItem) { final LookupElement item = ((AutoCompletionDecision.InsertItem)decision).getElement(); indicator.closeAndFinish(true); - indicator.getCompletionState().assertDisposed(); final Runnable restorePrefix = rememberDocumentState(indicator.getEditor()); indicator.getOffsetMap() .addOffset(CompletionInitializationContext.START_OFFSET, (offset1 - item.getPrefixMatcher().getPrefix().length())); 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 2080edea576c..75d3409600e3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -102,7 +102,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } }; private final Semaphore myDuringCompletionSemaphore = new Semaphore(); - private final CompletionState myState; private volatile int myCount; @@ -116,7 +115,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement myLookup = lookup; myLookup.setArranger(new CompletionLookupArranger(parameters)); - myState = new CompletionState(); myLookup.addLookupListener(myLookupListener); myLookup.setCalculating(true); @@ -191,10 +189,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } } - public CompletionState getCompletionState() { - return myState; - } - private static int findReplacementOffset(int selectionEndOffset, PsiReference reference) { final List ranges = ReferenceRange.getAbsoluteRanges(reference); for (TextRange range : ranges) { @@ -240,9 +234,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement myLookup.setAdvertisementText(s); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { - if (isOutdated()) { - return; - } if (isAutopopupCompletion() && !myLookup.isShown()) { return; } @@ -264,11 +255,7 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement } private boolean isOutdated() { - if (!myState.isCompletionDisposed()) { - CompletionProgressIndicator current = CompletionServiceImpl.getCompletionService().getCurrentCompletion(); - LOG.assertTrue(this == current, current + " != " + this); - } - return myState.isCompletionDisposed() || myEditor.isDisposed() || getProject().isDisposed(); + return CompletionServiceImpl.getCompletionPhase().indicator != this; } private void trackModifiers() { @@ -321,10 +308,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement CompletionServiceImpl.getCompletionService().setCurrentCompletion(this); } - void assertDisposed() { - myState.assertDisposed(); - } - public CodeCompletionHandlerBase getHandler() { return myHandler; } @@ -400,7 +383,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement LOG.assertTrue(lookup == myLookup); myLookup.removeLookupListener(myLookupListener); finishCompletionProcess(); - myState.assertDisposed(); CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass()); if (hideLookup) { @@ -411,8 +393,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement private void finishCompletionProcess() { cancel(); - myState.setCompletionDisposed(true); - ApplicationManager.getApplication().assertIsDispatchThread(); Disposer.dispose(myQueue); @@ -584,9 +564,6 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { - if (isOutdated()) { - return; - } if (phase != CompletionServiceImpl.getCompletionPhase()) { return; } @@ -606,11 +583,10 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement @Override public String toString() { - return "CompletionProgressIndicator[count=" + myCount + "," + myState.toString() + "]"; + return "CompletionProgressIndicator[count=" + myCount + ",phase=" + CompletionServiceImpl.getCompletionPhase() + "]"; } protected void handleEmptyLookup(final boolean awaitSecondInvocation) { - assertDisposed(); assert !isAutopopupCompletion(); if (ApplicationManager.getApplication().isUnitTestMode() || !myHandler.invokedExplicitly) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java deleted file mode 100644 index 1965874478a8..000000000000 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionState.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellij.codeInsight.completion; - -import com.intellij.codeInsight.completion.impl.CompletionServiceImpl; -import com.intellij.openapi.diagnostic.Logger; - -/** - * @author peter - */ -public class CompletionState { - private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.CompletionState"); - private boolean myCompletionDisposed; - - public boolean isCompletionDisposed() { - return myCompletionDisposed; - } - - public void setCompletionDisposed(boolean completionDisposed) { - LOG.assertTrue(!myCompletionDisposed, this); - myCompletionDisposed = completionDisposed; - } - - public void assertDisposed() { - LOG.assertTrue(myCompletionDisposed, this); - } - - @Override - public String toString() { - return "CompletionState{" + - "phase=" + CompletionServiceImpl.getCompletionPhase() + - ", myCompletionDisposed=" + myCompletionDisposed + - '}'; - } -}