private static PsiElement @NotNull [] validate(PsiElement @Nullable [] selectedElements) {
    if (selectedElements == null) return PsiElement.EMPTY_ARRAY;
    for (PsiElement element : selectedElements) {
      if (element == null || !element.isValid()) {
        return PsiElement.EMPTY_ARRAY;
      }
    }
    return selectedElements;
  }
private static PsiElement @NotNull [] validate(PsiElement @Nullable [] selectedElements)