@TestOnly
 public static void cleanupForNextTest() {
   CompletionProgressIndicator currentCompletion =
       CompletionServiceImpl.getCompletionService().getCurrentCompletion();
   if (currentCompletion != null) {
     currentCompletion.finishCompletionProcess(true);
     CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
   } else {
     CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
   }
   CompletionLookupArranger.cancelLastCompletionStatisticsUpdate();
 }
  public void closeAndFinish(boolean hideLookup) {
    if (!myLookup.isLookupDisposed()) {
      Lookup lookup = LookupManager.getActiveLookup(myEditor);
      LOG.assertTrue(lookup == myLookup, "lookup changed: " + lookup + "; " + this);
    }
    myLookup.removeLookupListener(myLookupListener);
    finishCompletionProcess(true);
    CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());

    if (hideLookup) {
      LookupManager.getInstance(getProject()).hideActiveLookup();
    }
  }