public boolean showLookup() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    checkValid();
    LOG.assertTrue(!myShown);
    myShown = true;
    myStampShown = System.currentTimeMillis();

    if (ApplicationManager.getApplication().isUnitTestMode()) return true;

    if (!myEditor.getContentComponent().isShowing()) {
      hide();
      return false;
    }

    myAdComponent.showRandomText();

    myUi = new LookupUi(this, myAdComponent, myList, myProject);
    myUi.setCalculating(myCalculating);
    Point p = myUi.calculatePosition().getLocation();
    try {
      HintManagerImpl.getInstanceImpl()
          .showEditorHint(
              this,
              myEditor,
              p,
              HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING,
              0,
              false,
              HintManagerImpl.createHintHint(myEditor, p, this, HintManager.UNDER)
                  .setAwtTooltip(false));
    } catch (Exception e) {
      LOG.error(e);
    }

    if (!isVisible() || !myList.isShowing()) {
      hide();
      return false;
    }

    DaemonCodeAnalyzer.getInstance(myProject).disableUpdateByTimer(this);

    return true;
  }
 public void refreshUi(boolean mayCheckReused, boolean onExplicitAction) {
   assert !myUpdating;
   LookupElement prevItem = getCurrentItem();
   myUpdating = true;
   try {
     final boolean reused = mayCheckReused && checkReused();
     boolean selectionVisible = isSelectionVisible();
     boolean itemsChanged = updateList(onExplicitAction, reused);
     if (isVisible()) {
       LOG.assertTrue(!ApplicationManager.getApplication().isUnitTestMode());
       myUi.refreshUi(selectionVisible, itemsChanged, reused, onExplicitAction);
     }
   } finally {
     myUpdating = false;
     fireCurrentItemChanged(prevItem, getCurrentItem());
   }
 }
  public boolean performGuardedChange(Runnable change) {
    checkValid();
    assert !myChangeGuard : "already in change";

    myEditor.getDocument().startGuardedBlockChecking();
    myChangeGuard = true;
    boolean result;
    try {
      result = myOffsets.performGuardedChange(change);
    } finally {
      myEditor.getDocument().stopGuardedBlockChecking();
      myChangeGuard = false;
    }
    if (!result || myDisposed) {
      hide();
      return false;
    }
    if (isVisible()) {
      HintManagerImpl.updateLocation(this, myEditor, myUi.calculatePosition().getLocation());
    }
    checkValid();
    return true;
  }
 public void setCalculating(final boolean calculating) {
   myCalculating = calculating;
   if (myUi != null) {
     myUi.setCalculating(calculating);
   }
 }
 @Override
 public boolean isPositionedAboveCaret() {
   return myUi != null && myUi.isPositionedAboveCaret();
 }