AnAction[] (@NotNull List<? extends DirectoryProjectGenerator<?>> generators, @NotNull AbstractCallback<PyNewProjectSettings> callback) { generators = new ArrayList<>(generators); generators.sort(Comparator.comparing(DirectoryProjectGenerator::getName)); generators.sort(Comparator.comparingInt(value -> { if (value instanceof PyFrameworkProjectGenerator) { return -2; } if (value instanceof PythonProjectGenerator) { return -1; } return 0; })); //noinspection unchecked return StreamEx.of(generators) .flatMap(generator -> StreamEx.of(getActions((DirectoryProjectGenerator<PyNewProjectSettings>)generator, callback))) .toArray(EMPTY_ARRAY); }