@Override
 public void doApplyInformationToEditor() {
   final boolean virtSpace =
       TargetElementUtil.inVirtualSpace(myEditor, myEditor.getCaretModel().getOffset());
   final List<HighlightInfo> infos =
       virtSpace ? Collections.<HighlightInfo>emptyList() : getHighlights();
   UpdateHighlightersUtil.setHighlightersToEditor(
       myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId());
 }
  @NotNull
  @VisibleForTesting
  public static PsiElement[] findAllTargetElements(Project project, Editor editor, int offset) {
    if (TargetElementUtil.inVirtualSpace(editor, offset)) {
      return PsiElement.EMPTY_ARRAY;
    }

    final PsiElement[] targets = findTargetElementsNoVS(project, editor, offset, true);
    return targets != null ? targets : PsiElement.EMPTY_ARRAY;
  }
  // returns true if processor is run or is going to be run after showing popup
  public static boolean chooseAmbiguousTarget(
      @NotNull Editor editor,
      int offset,
      @NotNull PsiElementProcessor<PsiElement> processor,
      @NotNull String titlePattern,
      @Nullable PsiElement[] elements) {
    if (TargetElementUtil.inVirtualSpace(editor, offset)) {
      return false;
    }

    final PsiReference reference = TargetElementUtil.findReference(editor, offset);

    if (elements == null || elements.length == 0) {
      elements =
          reference == null
              ? PsiElement.EMPTY_ARRAY
              : PsiUtilCore.toPsiElementArray(
                  underModalProgress(
                      reference.getElement().getProject(),
                      "Resolving Reference...",
                      () -> suggestCandidates(reference)));
    }

    if (elements.length == 1) {
      PsiElement element = elements[0];
      LOG.assertTrue(element != null);
      processor.execute(element);
      return true;
    }
    if (elements.length > 1) {
      String title;

      if (reference == null) {
        title = titlePattern;
      } else {
        final TextRange range = reference.getRangeInElement();
        final String elementText = reference.getElement().getText();
        LOG.assertTrue(
            range.getStartOffset() >= 0 && range.getEndOffset() <= elementText.length(),
            Arrays.toString(elements) + ";" + reference);
        final String refText = range.substring(elementText);
        title = MessageFormat.format(titlePattern, refText);
      }

      NavigationUtil.getPsiElementPopup(
              elements, new DefaultPsiElementCellRenderer(), title, processor)
          .showInBestPositionFor(editor);
      return true;
    }
    return false;
  }