private static PsiDirectory @NotNull [] filterSourceDirectories(
    @NotNull Project project,
    @NotNull PsiDirectory baseDir,
    PsiDirectory @NotNull [] moduleDirectories
  ) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    if (fileIndex.isInTestSourceContent(baseDir.getVirtualFile())) {
      List<PsiDirectory> result = new ArrayList<>();
      for (PsiDirectory moduleDirectory : moduleDirectories) {
        if (fileIndex.isInTestSourceContent(moduleDirectory.getVirtualFile())) {
          result.add(moduleDirectory);
        }
      }
      moduleDirectories = result.toArray(PsiDirectory.EMPTY_ARRAY);
    }
    return moduleDirectories;
  }
private static PsiDirectory @NotNull [] filterSourceDirectories(
    @NotNull Project project,
    @NotNull PsiDirectory baseDir,
    PsiDirectory @NotNull [] moduleDirectories
  )