private void createFile(@NotNull FileTemplate template, @NotNull ModuleInfo moduleInfo) {
    if (moduleInfo.fileAlreadyExists()) return;
    Project project = moduleInfo.rootDir().getProject();
    Properties properties = FileTemplateManager.getInstance(project).getDefaultProperties();
    FileTemplateUtil.fillDefaultProperties(properties, moduleInfo.rootDir());
    properties.setProperty(FileTemplate.ATTRIBUTE_NAME, MODULE_INFO_CLASS);
    try {
      PsiJavaFile moduleInfoFile = // this is done to copy the file header to the output
        (PsiJavaFile)FileTemplateUtil.createFromTemplate(template, MODULE_INFO_FILE, properties, moduleInfo.rootDir());
      PsiJavaModule javaModule = moduleInfoFile.getModuleDeclaration();
      myLogger.assertTrue(javaModule != null, "module-info file should contain module declaration");

      CharSequence moduleText = moduleInfo.createModuleText();
      PsiJavaFile dummyFile = (PsiJavaFile)PsiFileFactory.getInstance(project)
        .createFileFromText(MODULE_INFO_FILE, JavaLanguage.INSTANCE, moduleText);
      PsiJavaModule actualModule = dummyFile.getModuleDeclaration();
      myLogger.assertTrue(actualModule != null, "module declaration wasn't created");
      javaModule.replace(actualModule);
      CodeStyleManager.getInstance(project).reformat(moduleInfoFile);
    }
    catch (Exception e) {
      myLogger.error("Failed to create module-info.java in " + moduleInfo.rootDir().getVirtualFile().getPath() + ": " + e.getMessage());
    }
  }
private void createFile(@NotNull FileTemplate template, @NotNull ModuleInfo moduleInfo)