Program: 15469
Project: 15469
Buggy source:
public static void buildFile(AnActionEvent event,final Project project,String templatePath){
  String extension=templatePath.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
  String fileName=Messages.showInputDialog(project,"String_Node_Str",String.format("String_Node_Str",extension),Symfony2Icons.SYMFONY);
  if (fileName == null || StringUtils.isBlank(fileName)) {
    return;
  }
  FileType fileType=templatePath.endsWith("String_Node_Str") ? YAMLFileType.YML : XmlFileType.INSTANCE;
  if (!fileName.endsWith("String_Node_Str" + extension)) {
    fileName=fileName.concat("String_Node_Str" + extension);
  }
  DataContext dataContext=event.getDataContext();
  IdeView view=LangDataKeys.IDE_VIEW.getData(dataContext);
  if (view == null) {
    return;
  }
  PsiDirectory[] directories=view.getDirectories();
  if (directories.length == 0) {
    return;
  }
  final PsiDirectory initialBaseDir=directories[0];
  if (initialBaseDir == null) {
    return;
  }
  if (initialBaseDir.findFile(fileName) != null) {
    Messages.showInfoMessage("String_Node_Str","String_Node_Str");
    return;
  }
  String content;
  try {
    content=StreamUtil.readText(ServiceActionUtil.class.getResourceAsStream(templatePath),"String_Node_Str");
  }
 catch (  IOException e) {
    e.printStackTrace();
    return;
  }
  final PsiFileFactory factory=PsiFileFactory.getInstance(project);
  String bundleName="String_Node_Str";
  SymfonyBundleUtil symfonyBundleUtil=new SymfonyBundleUtil(project);
  SymfonyBundle symfonyBundle=symfonyBundleUtil.getContainingBundle(initialBaseDir);
  if (symfonyBundle != null) {
    bundleName=StringUtils.strip(symfonyBundle.getNamespaceName(),"String_Node_Str");
  }
  String underscoreBundle=bundleName.replace("String_Node_Str","String_Node_Str").toLowerCase();
  if (underscoreBundle.endsWith("String_Node_Str")) {
    underscoreBundle=underscoreBundle.substring(0,underscoreBundle.length() - 6);
  }
  content=content.replace("String_Node_Str",bundleName).replace("String_Node_Str",underscoreBundle);
  final PsiFile file=factory.createFileFromText(fileName,fileType,content);
  ApplicationManager.getApplication().runWriteAction(new Runnable(){
    @Override public void run(){
      CodeStyleManager.getInstance(project).reformat(file);
      initialBaseDir.add(file);
    }
  }
);
  PsiFile psiFile=initialBaseDir.findFile(fileName);
  if (psiFile != null) {
    view.selectElement(psiFile);
  }
}

Fixed version (ground truth):
public static void buildFile(AnActionEvent event,final Project project,String templatePath){
  String extension=templatePath.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str";
  String fileName=Messages.showInputDialog(project,"String_Node_Str",String.format("String_Node_Str",extension),Symfony2Icons.SYMFONY);
  if (fileName == null || StringUtils.isBlank(fileName)) {
    return;
  }
  FileType fileType=templatePath.endsWith("String_Node_Str") ? YAMLFileType.YML : XmlFileType.INSTANCE;
  if (!fileName.endsWith("String_Node_Str" + extension)) {
    fileName=fileName.concat("String_Node_Str" + extension);
  }
  DataContext dataContext=event.getDataContext();
  IdeView view=LangDataKeys.IDE_VIEW.getData(dataContext);
  if (view == null) {
    return;
  }
  PsiDirectory[] directories=view.getDirectories();
  if (directories.length == 0) {
    return;
  }
  final PsiDirectory initialBaseDir=directories[0];
  if (initialBaseDir == null) {
    return;
  }
  if (initialBaseDir.findFile(fileName) != null) {
    Messages.showInfoMessage("String_Node_Str","String_Node_Str");
    return;
  }
  String content;
  try {
    content=StreamUtil.readText(ServiceActionUtil.class.getResourceAsStream(templatePath),"String_Node_Str").replace("String_Node_Str","String_Node_Str");
  }
 catch (  IOException e) {
    e.printStackTrace();
    return;
  }
  final PsiFileFactory factory=PsiFileFactory.getInstance(project);
  String bundleName="String_Node_Str";
  SymfonyBundleUtil symfonyBundleUtil=new SymfonyBundleUtil(project);
  SymfonyBundle symfonyBundle=symfonyBundleUtil.getContainingBundle(initialBaseDir);
  if (symfonyBundle != null) {
    bundleName=StringUtils.strip(symfonyBundle.getNamespaceName(),"String_Node_Str");
  }
  String underscoreBundle=bundleName.replace("String_Node_Str","String_Node_Str").toLowerCase();
  if (underscoreBundle.endsWith("String_Node_Str")) {
    underscoreBundle=underscoreBundle.substring(0,underscoreBundle.length() - 6);
  }
  content=content.replace("String_Node_Str",bundleName).replace("String_Node_Str",underscoreBundle);
  final PsiFile file=factory.createFileFromText(fileName,fileType,content);
  ApplicationManager.getApplication().runWriteAction(new Runnable(){
    @Override public void run(){
      CodeStyleManager.getInstance(project).reformat(file);
      initialBaseDir.add(file);
    }
  }
);
  PsiFile psiFile=initialBaseDir.findFile(fileName);
  if (psiFile != null) {
    view.selectElement(psiFile);
  }
}