private void doTest(String text, int highlightedParameterIndex) {
    myFixture.configureByText("a.erl", text);
    final ParameterInfoHandler paramInfoHandler = new ErlangParameterInfoHandler();
    //    final CreateParameterInfoContext parameterInfoContext = new
    // MockCreateParameterInfoContext(myFixture.getEditor(), myFixture.getFile());
    //    final Object list = paramInfoHandler.findElementForParameterInfo(parameterInfoContext);

    //    if (highlightedParameterIndex >= 0) {
    //      assertNotNull(list);
    //      Object[] itemsToShow = parameterInfoContext.getItemsToShow();
    //      assertNotNull(itemsToShow);
    //      assertTrue(itemsToShow.length > 0);
    //    }
    MockUpdateParameterInfoContext updateContext =
        new MockUpdateParameterInfoContext(myFixture.getEditor(), myFixture.getFile());
    final Object element = paramInfoHandler.findElementForUpdatingParameterInfo(updateContext);
    if (element == null) {
      assertEquals(-1, highlightedParameterIndex);
    } else {
      assertNotNull(element);
      //noinspection unchecked
      paramInfoHandler.updateParameterInfo(element, updateContext);
      assertEquals(highlightedParameterIndex, updateContext.getCurrentParameter());
    }
  }
  public Object[] getSelectedElements() {
    ParameterInfoContext context =
        new ParameterInfoContext() {
          @Override
          public Project getProject() {
            return myProject;
          }

          @Override
          public PsiFile getFile() {
            return myComponent.getParameterOwner().getContainingFile();
          }

          @Override
          public int getOffset() {
            return myEditor.getCaretModel().getOffset();
          }

          @Override
          @NotNull
          public Editor getEditor() {
            return myEditor;
          }
        };

    if (!myHandler.tracksParameterIndex()) {
      return myHandler.getParametersForDocumentation(myComponent.getObjects()[0], context);
    }

    final Object[] objects = myComponent.getObjects();
    int selectedParameterIndex = myComponent.getCurrentParameterIndex();
    List<Object> params = new ArrayList<>(objects.length);

    final Object highlighted = myComponent.getHighlighted();
    for (Object o : objects) {
      if (highlighted != null && !o.equals(highlighted)) continue;
      collectParams(context, selectedParameterIndex, params, o);
    }

    // choose anything when highlighted is not applicable
    if (highlighted != null && params.isEmpty()) {
      for (Object o : objects) {
        collectParams(context, selectedParameterIndex, params, o);
      }
    }

    return ArrayUtil.toObjectArray(params);
  }
  private void updateComponent() {
    if (!myHint.isVisible()) {
      Disposer.dispose(this);
      return;
    }

    final PsiFile file =
        PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
    CharSequence chars = myEditor.getDocument().getCharsSequence();
    boolean noDelimiter =
        myHandler instanceof ParameterInfoHandlerWithTabActionSupport
            && ((ParameterInfoHandlerWithTabActionSupport) myHandler)
                    .getActualParameterDelimiterType()
                == TokenType.WHITE_SPACE;
    int caretOffset = myEditor.getCaretModel().getOffset();
    final int offset =
        noDelimiter ? caretOffset : CharArrayUtil.shiftBackward(chars, caretOffset - 1, " \t") + 1;

    final UpdateParameterInfoContext context = new MyUpdateParameterInfoContext(offset, file);
    final Object elementForUpdating = myHandler.findElementForUpdatingParameterInfo(context);

    if (elementForUpdating != null) {
      myHandler.updateParameterInfo(elementForUpdating, context);
      if (!myDisposed
          && myHint.isVisible()
          && !myEditor.isDisposed()
          && myEditor.getComponent().getRootPane() != null) {
        myComponent.update();
        IdeTooltip tooltip = myHint.getCurrentIdeTooltip();
        short position =
            tooltip != null ? toShort(tooltip.getPreferredPosition()) : HintManager.UNDER;
        Pair<Point, Short> pos =
            myProvider.getBestPointPosition(
                myHint,
                elementForUpdating instanceof PsiElement ? (PsiElement) elementForUpdating : null,
                caretOffset,
                true,
                position);
        HintManagerImpl.adjustEditorHintPosition(myHint, myEditor, pos.getFirst(), pos.getSecond());
      }
    } else {
      context.removeHint();
    }
  }
  private void moveToParameterAtOffset(int offset) {
    PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
    PsiElement argsList = findArgumentList(file, offset, -1);
    if (argsList == null) return;

    myEditor.getCaretModel().moveToOffset(offset);
    myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    myEditor.getSelectionModel().removeSelection();
    myHandler.updateParameterInfo(argsList, new MyUpdateParameterInfoContext(offset, file));
  }
  private void collectParams(
      ParameterInfoContext context, int selectedParameterIndex, List<Object> params, Object o) {
    final Object[] availableParams = myHandler.getParametersForDocumentation(o, context);

    if (availableParams != null
        && selectedParameterIndex < availableParams.length
        && selectedParameterIndex >= 0) {
      params.add(availableParams[selectedParameterIndex]);
    }
  }
  public void update() {
    MyParameterContext context = new MyParameterContext();

    for (int i = 0; i < myObjects.length; i++) {
      context.i = i;
      final Object o = myObjects[i];

      //noinspection unchecked
      myHandler.updateUI(o, context);
    }

    invalidate();
    validate();
    repaint();
  }