private static PsiDirectory getWritableModuleDirectory(@NotNull Module module, @NotNull Query<? extends VirtualFile> vFiles) {
    PsiManager manager = PsiManager.getInstance(module.getProject());
    for (VirtualFile vFile : vFiles) {
      if (ModuleUtilCore.findModuleForFile(vFile, module.getProject()) != module) continue;
      PsiDirectory directory = manager.findDirectory(vFile);
      if (directory != null && directory.isValid() && directory.isWritable()) {
        return directory;
      }
    }
    return null;
  }
private static PsiDirectory getWritableModuleDirectory(@NotNull Module module, @NotNull Query<? extends VirtualFile> vFiles)