private void focusCurrentExpression() {
    if (isFinished() || isDisposed()) {
      return;
    }

    PsiDocumentManager.getInstance(myProject).commitDocument(getDocument());

    final int currentSegmentNumber = getCurrentSegmentNumber();

    lockSegmentAtTheSameOffsetIfAny();

    if (currentSegmentNumber < 0) return;
    final int start = getSegments().getSegmentStart(currentSegmentNumber);
    final int end = getSegments().getSegmentEnd(currentSegmentNumber);
    if (end >= 0 && getEditor() != null) {
      if (getTemplate().isScrollToTemplate()) {
        getEditor().getCaretModel().moveToOffset(end);
        getEditor().getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
      }
      getEditor().getSelectionModel().removeSelection();
      getEditor().getSelectionModel().setSelection(start, end);
    }

    DumbService.getInstance(myProject).withAlternativeResolveEnabled(() -> {
      Expression expressionNode = getCurrentExpression();
      LookupElement[] lookupItems = getCurrentExpressionLookupItems();
      final PsiFile psiFile = getPsiFile();
      if (lookupItems.length != 0) {
        myLiveTemplateProcessor.runLookup(this, myProject, getEditor(), lookupItems, expressionNode);
      }
      else {
        try {
          Result result = expressionNode.calculateResult(getCurrentExpressionContext());
          if (result != null) {
            result.handleFocused(psiFile, getDocument(), getSegments().getSegmentStart(currentSegmentNumber),
                                 getSegments().getSegmentEnd(currentSegmentNumber));
          }
        }
        catch (IndexNotReadyException ignore) {
        }
      }
    });
    focusCurrentHighlighter(true);
  }
private void focusCurrentExpression()