protected static @NlsSafe String getElementText(Object element) {
    if (element instanceof LibraryDescriptor) {
      return getElementTextFromLibraryDescriptor((LibraryDescriptor)element);
    }

    if (element instanceof File) {
      return getElementTextFromFile((File)element);
    }

    if (element instanceof ModuleDescriptor moduleDescriptor) {
      final StringBuilder builder = new StringBuilder(moduleDescriptor.getName());

      final Set<File> contents = moduleDescriptor.getContentRoots();
      final int rootCount = contents.size();
      if (rootCount > 0) {
        builder.append(" (");
        builder.append(contents.iterator().next().getPath());
        if (rootCount > 1) {
          builder.append("...");
        }
        builder.append(")");
      }

      final Collection<? extends DetectedProjectRoot> sourceRoots = moduleDescriptor.getSourceRoots();
      if (sourceRoots.size() > 0) {
        StringJoiner joiner = new StringJoiner(",", " [", "]");
        for (DetectedProjectRoot root : sourceRoots) {
          joiner.add(root.getDirectory().getName());
        }
        builder.append(joiner);
      }
      return builder.toString();
    }

    return "";
  }
protected static @NlsSafe String getElementText(Object element)