Program: 151613
Project: 151613
Buggy source:
@SuppressWarnings("String_Node_Str") @DefaultCommand public void create(@Option(name="String_Node_Str",description="String_Node_Str",required=true) final String name,@Option(name="String_Node_Str",description="String_Node_Str",required=true,type=PromptType.JAVA_PACKAGE) final String javaPackage,@Option(name="String_Node_Str",description="String_Node_Str",required=false,completer=NewProjectPackagingTypeCompleter.class,defaultValue="String_Node_Str") final PackagingType type,@Option(name="String_Node_Str",description="String_Node_Str",required=false) final Resource<?> projectFolder,@Option(name="String_Node_Str",description="String_Node_Str",required=false,defaultValue="String_Node_Str",flagOnly=true) final boolean createMain,@Option(name="String_Node_Str",description="String_Node_Str") final String finalName,final PipeOut out) throws IOException {
  DirectoryResource dir=null;
  if (!getValidPackagingTypes().contains(type)) {
    throw new RuntimeException("String_Node_Str" + type);
  }
  try {
    if (projectFolder instanceof FileResource<?>) {
      if (!projectFolder.exists()) {
        ((FileResource<?>)projectFolder).mkdirs();
        dir=projectFolder.reify(DirectoryResource.class);
      }
 else       if (projectFolder instanceof DirectoryResource) {
        dir=(DirectoryResource)projectFolder;
      }
 else {
        ShellMessages.error(out,"String_Node_Str" + projectFolder.getFullyQualifiedName() + "String_Node_Str");
      }
    }
    if (dir == null) {
      dir=shell.getCurrentDirectory().getChildDirectory(name);
    }
  }
 catch (  ResourceException e) {
  }
  if (projectFactory.containsProject(dir) || !shell.promptBoolean("String_Node_Str" + dir.getFullyQualifiedName() + "String_Node_Str")) {
    if (projectFactory.containsProject(dir)) {
      ShellMessages.error(out,"String_Node_Str" + dir.getFullyQualifiedName() + "String_Node_Str");
    }
    if (shell.getCurrentResource() == null) {
      dir=ResourceUtil.getContextDirectory(factory.getResourceFrom(Files.getWorkingDirectory()));
    }
 else {
      dir=shell.getCurrentDirectory();
    }
    FileResource<?> newDir;
    do {
      newDir=shell.getCurrentDirectory();
      shell.println();
      if (!projectFactory.containsProject(newDir.reify(DirectoryResource.class))) {
        newDir=shell.promptFile("String_Node_Str" + newDir + "String_Node_Str",dir);
      }
 else {
        newDir=shell.promptFile("String_Node_Str");
      }
      if (!newDir.exists()) {
        newDir.mkdirs();
        newDir=newDir.reify(DirectoryResource.class);
      }
 else       if (newDir.isDirectory() && !projectFactory.containsProject(newDir.reify(DirectoryResource.class))) {
        newDir=newDir.reify(DirectoryResource.class);
      }
 else {
        ShellMessages.error(out,"String_Node_Str" + newDir.getFullyQualifiedName() + "String_Node_Str");
        newDir=null;
      }
    }
 while ((newDir == null) || !(newDir instanceof DirectoryResource));
    dir=(DirectoryResource)newDir;
  }
  if (!dir.exists()) {
    dir.mkdirs();
  }
  Project project=null;
  if (type.equals(PackagingType.JAR) || type.equals(PackagingType.WAR)) {
    project=projectFactory.createProject(dir,DependencyFacet.class,MetadataFacet.class,JavaSourceFacet.class,ResourceFacet.class);
  }
 else {
    project=projectFactory.createProject(dir,DependencyFacet.class,MetadataFacet.class);
  }
  MetadataFacet meta=project.getFacet(MetadataFacet.class);
  meta.setProjectName(name);
  meta.setTopLevelPackage(javaPackage);
  PackagingFacet packaging=project.getFacet(PackagingFacet.class);
  packaging.setPackagingType(type);
  DependencyFacet deps=project.getFacet(DependencyFacet.class);
  deps.addRepository(KnownRepository.JBOSS_NEXUS);
  if (packaging.getPackagingType().equals(PackagingType.JAR) && createMain) {
    project.getFacet(JavaSourceFacet.class).saveJavaSource(JavaParser.create(JavaClass.class).setPackage(javaPackage).setName("String_Node_Str").addMethod("String_Node_Str").setBody("String_Node_Str" + name + "String_Node_Str").getOrigin());
  }
  if (finalName != null) {
    packaging.setFinalName(finalName);
  }
 else {
    packaging.setFinalName(name);
  }
  if (project.hasFacet(ResourceFacet.class)) {
    project.getFacet(ResourceFacet.class).createResource("String_Node_Str".toCharArray(),"String_Node_Str");
  }
  shell.setCurrentResource(project.getProjectRoot());
  ShellMessages.success(out,"String_Node_Str" + name + "String_Node_Str"+ dir.getFullyQualifiedName()+ "String_Node_Str");
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @DefaultCommand public void create(@Option(name="String_Node_Str",description="String_Node_Str",required=true) final String name,@Option(name="String_Node_Str",description="String_Node_Str",required=true,type=PromptType.JAVA_PACKAGE) final String javaPackage,@Option(name="String_Node_Str",description="String_Node_Str",required=false,completer=NewProjectPackagingTypeCompleter.class,defaultValue="String_Node_Str") final PackagingType type,@Option(name="String_Node_Str",description="String_Node_Str",required=false) final Resource<?> projectFolder,@Option(name="String_Node_Str",description="String_Node_Str",required=false,defaultValue="String_Node_Str",flagOnly=true) final boolean createMain,@Option(name="String_Node_Str",description="String_Node_Str") final String finalName,final PipeOut out) throws IOException {
  DirectoryResource dir=null;
  if (!getValidPackagingTypes().contains(type)) {
    throw new RuntimeException("String_Node_Str" + type);
  }
  try {
    if (projectFolder instanceof FileResource<?>) {
      if (!projectFolder.exists()) {
        ((FileResource<?>)projectFolder).mkdirs();
        dir=projectFolder.reify(DirectoryResource.class);
      }
 else       if (projectFolder instanceof DirectoryResource) {
        dir=(DirectoryResource)projectFolder;
      }
 else {
        ShellMessages.error(out,"String_Node_Str" + projectFolder.getFullyQualifiedName() + "String_Node_Str");
      }
    }
    if (dir == null) {
      dir=shell.getCurrentDirectory().getChildDirectory(name);
    }
  }
 catch (  ResourceException e) {
  }
  if (projectFactory.containsProject(dir) || !shell.promptBoolean("String_Node_Str" + dir.getFullyQualifiedName() + "String_Node_Str")) {
    if (projectFactory.containsProject(dir)) {
      ShellMessages.error(out,"String_Node_Str" + dir.getFullyQualifiedName() + "String_Node_Str");
    }
    if (shell.getCurrentResource() == null) {
      dir=ResourceUtil.getContextDirectory(factory.getResourceFrom(Files.getWorkingDirectory()));
    }
 else {
      dir=shell.getCurrentDirectory();
    }
    FileResource<?> newDir;
    do {
      newDir=shell.getCurrentDirectory();
      shell.println();
      if (!projectFactory.containsProject(newDir.reify(DirectoryResource.class))) {
        newDir=shell.promptFile("String_Node_Str" + newDir + "String_Node_Str",dir);
      }
 else {
        newDir=shell.promptFile("String_Node_Str");
      }
      if (!newDir.exists()) {
        newDir.mkdirs();
        newDir=newDir.reify(DirectoryResource.class);
      }
 else       if (newDir.isDirectory() && !projectFactory.containsProject(newDir.reify(DirectoryResource.class))) {
        newDir=newDir.reify(DirectoryResource.class);
      }
 else {
        ShellMessages.error(out,"String_Node_Str" + newDir.getFullyQualifiedName() + "String_Node_Str");
        newDir=null;
      }
    }
 while ((newDir == null) || !(newDir instanceof DirectoryResource));
    dir=(DirectoryResource)newDir;
  }
  if (!dir.exists()) {
    dir.mkdirs();
  }
  Project project=null;
  if (type.equals(PackagingType.JAR)) {
    project=projectFactory.createProject(dir,DependencyFacet.class,MetadataFacet.class,JavaSourceFacet.class,ResourceFacet.class);
  }
 else   if (type.equals(PackagingType.WAR)) {
    project=projectFactory.createProject(dir,DependencyFacet.class,MetadataFacet.class,WebResourceFacet.class,JavaSourceFacet.class,ResourceFacet.class);
  }
 else {
    project=projectFactory.createProject(dir,DependencyFacet.class,MetadataFacet.class);
  }
  MetadataFacet meta=project.getFacet(MetadataFacet.class);
  meta.setProjectName(name);
  meta.setTopLevelPackage(javaPackage);
  PackagingFacet packaging=project.getFacet(PackagingFacet.class);
  packaging.setPackagingType(type);
  DependencyFacet deps=project.getFacet(DependencyFacet.class);
  deps.addRepository(KnownRepository.JBOSS_NEXUS);
  if (packaging.getPackagingType().equals(PackagingType.JAR) && createMain) {
    project.getFacet(JavaSourceFacet.class).saveJavaSource(JavaParser.create(JavaClass.class).setPackage(javaPackage).setName("String_Node_Str").addMethod("String_Node_Str").setBody("String_Node_Str" + name + "String_Node_Str").getOrigin());
  }
  if (finalName != null) {
    packaging.setFinalName(finalName);
  }
 else {
    packaging.setFinalName(name);
  }
  if (project.hasFacet(ResourceFacet.class)) {
    project.getFacet(ResourceFacet.class).createResource("String_Node_Str".toCharArray(),"String_Node_Str");
  }
  shell.setCurrentResource(project.getProjectRoot());
  ShellMessages.success(out,"String_Node_Str" + name + "String_Node_Str"+ dir.getFullyQualifiedName()+ "String_Node_Str");
}