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 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);
  }