Program: 11848
Project: 11848
Buggy source:
/** 
 * Performs code generation for the given object and project type. A project type is repesented by an arbitrary object that is meaningful to the generator adapters for the relevant objects. Since this is a long-running operation, it reports progress using the given <code>Monitor</code>. Its final status is returned as a <code>Diagnostic</code>. The <code>projectTypeName</code>, if non-null, is used only to provide to the <code>Monitor</code> a more specific message for the task. <p>It is not necessary to call   {@link #canGenerate(Object,Object)} before this method. If that method would return <code>false</code>, this method should generate nothing when invoked with the same arguments. <p>Code generation is performed as follows: <ol> <li>The  {@link GeneratorAdapter adapters} for the object are obtained.<li>A complete collection of objects to be considered is formed by iteratively invoking the {@link GeneratorAdapter#getGenerateParent(Object,Object) getGenerateParent(Object, Object)} and{@link GeneratorAdapter#getGenerateChildren(Object,Object) getGenerateChildren(Object, Object)} methods on theadapters for the object, the adapters for the object's parent and children, and so on. It is the adapters' responsibility to determine the relevant objects through their implementations of these methods. <li>If this is the first invocation of  {@link #generate(Object,Object,String,Monitor)} or initialization hasbeen  {@link #requestInitialize() requested},   {@link GeneratorAdapterFactory#initialize(Object) initialize(Object)}is invoked on each adapter factory for the   {@link #getInput() input} object.<li>The  {@link GeneratorAdapter#preGenerate(Object,Object) preGenerate(Object, Object)} method is invoked on allthe adapters for every object in the set formed in step 2, giving the adapters a chance to perform setup before any code is generated. <li>The  {@link GeneratorAdapter#generate(Object,Object,Monitor) generate(Object, Object, Monitor)} method isinvoked on all the adapters for every object in the set formed in step 2. This is where code generation actually occurs. <li>The  {@link GeneratorAdapter#postGenerate(Object,Object) postGenerate(Object, Object)} method is invoked on allthe adapters for every object in the set formed in step 2, giving adapters a chance to clean up from code generation. </ol> <p>The operation may be cancelled during step 4 or 5, either based on the <code>Monitor</code> or the <code>Diagnostic</code> returned by any generator adapter invocation. By default, only a <code>CANCEL</code> {@link org.eclipse.emf.common.util.Diagnostic#getSeverity severity} will cause code generation to stop; however,this can be customized by overriding  {@link #canContinue(Diagnostic) canContinue(Diagnostic)}. Even if code generation is cancelled,   {@link GeneratorAdapter#postGenerate(Object,Object) postGenerate(Object, Object)} willstill be called on all the adapters on which  {@link GeneratorAdapter#preGenerate(Object,Object) preGenerate(Object, Object)}has been called.
 * @see #canGenerate(Object,Object)
 * @see #requestInitialize()
 * @see GeneratorAdapter#getGenerateParent(Object,Object)
 * @see GeneratorAdapter#getGenerateChildren(Object,Object)
 * @see GeneratorAdapter#preGenerate(Object,Object)
 * @see GeneratorAdapter#generate(Object,Object,Monitor)
 * @see GeneratorAdapter#postGenerate(Object,Object)
 * @see GeneratorAdapterFactory#initialize(Object)
 */
public Diagnostic generate(Object object,Object projectType,String projectTypeName,Monitor monitor){
  if (SYSOUT_BEGIN_END)   System.out.println("String_Node_Str" + new java.util.Date());
  try {
    String message=projectTypeName != null ? CodeGenEcorePlugin.INSTANCE.getString("String_Node_Str",new Object[]{projectTypeName}) : CodeGenEcorePlugin.INSTANCE.getString("String_Node_Str");
    BasicDiagnostic result=new BasicDiagnostic(CodeGenEcorePlugin.ID,0,message,null);
    GeneratorData[] data=getGeneratorData(object,projectType,true);
    monitor.beginTask("String_Node_Str",data.length + 2);
    monitor.subTask(message);
    if (initializeNeeded) {
      initializeNeeded=false;
      initialize();
    }
    int preIndex=0;
    for (; preIndex < data.length && canContinue(result); preIndex++) {
      result.add(data[preIndex].adapter.preGenerate(data[preIndex].object,projectType));
    }
    monitor.worked(1);
    for (int i=0; i < data.length && canContinue(result); i++) {
      result.add(data[i].adapter.generate(data[i].object,projectType,CodeGenUtil.createMonitor(monitor,1)));
      if (monitor.isCanceled()) {
        result.add(Diagnostic.CANCEL_INSTANCE);
      }
    }
    for (int i=0; i < preIndex; i++) {
      result.add(data[i].adapter.postGenerate(data[i].object,projectType));
    }
    return result;
  }
  finally {
    monitor.done();
    if (SYSOUT_BEGIN_END)     System.out.println("String_Node_Str" + new java.util.Date());
  }
}

Fixed version (ground truth):
/** 
 * Performs code generation for the given object and project type. A project type is represented by an arbitrary object that is meaningful to the generator adapters for the relevant objects. Since this is a long-running operation, it reports progress using the given <code>Monitor</code>. Its final status is returned as a <code>Diagnostic</code>. The <code>projectTypeName</code>, if non-null, is used only to provide to the <code>Monitor</code> a more specific message for the task. <p>It is not necessary to call   {@link #canGenerate(Object,Object)} before this method. If that method would return <code>false</code>, this method should generate nothing when invoked with the same arguments. <p>Code generation is performed as follows: <ol> <li>The  {@link GeneratorAdapter adapters} for the object are obtained.<li>A complete collection of objects to be considered is formed by iteratively invoking the {@link GeneratorAdapter#getGenerateParent(Object,Object) getGenerateParent(Object, Object)} and{@link GeneratorAdapter#getGenerateChildren(Object,Object) getGenerateChildren(Object, Object)} methods on theadapters for the object, the adapters for the object's parent and children, and so on. It is the adapters' responsibility to determine the relevant objects through their implementations of these methods. <li>If this is the first invocation of  {@link #generate(Object,Object,String,Monitor)} or initialization hasbeen  {@link #requestInitialize() requested},   {@link GeneratorAdapterFactory#initialize(Object) initialize(Object)}is invoked on each adapter factory for the   {@link #getInput() input} object.<li>The  {@link GeneratorAdapter#preGenerate(Object,Object) preGenerate(Object, Object)} method is invoked on allthe adapters for every object in the set formed in step 2, giving the adapters a chance to perform setup before any code is generated. <li>The  {@link GeneratorAdapter#generate(Object,Object,Monitor) generate(Object, Object, Monitor)} method isinvoked on all the adapters for every object in the set formed in step 2. This is where code generation actually occurs. <li>The  {@link GeneratorAdapter#postGenerate(Object,Object) postGenerate(Object, Object)} method is invoked on allthe adapters for every object in the set formed in step 2, giving adapters a chance to clean up from code generation. </ol> <p>The operation may be canceled during step 4 or 5, either based on the <code>Monitor</code> or the <code>Diagnostic</code> returned by any generator adapter invocation. By default, only a <code>CANCEL</code> {@link org.eclipse.emf.common.util.Diagnostic#getSeverity severity} will cause code generation to stop; however,this can be customized by overriding  {@link #canContinue(Diagnostic) canContinue(Diagnostic)}. Even if code generation is canceled,   {@link GeneratorAdapter#postGenerate(Object,Object) postGenerate(Object, Object)} willstill be called on all the adapters on which  {@link GeneratorAdapter#preGenerate(Object,Object) preGenerate(Object, Object)}has been called.
 * @see #canGenerate(Object,Object)
 * @see #requestInitialize()
 * @see GeneratorAdapter#getGenerateParent(Object,Object)
 * @see GeneratorAdapter#getGenerateChildren(Object,Object)
 * @see GeneratorAdapter#preGenerate(Object,Object)
 * @see GeneratorAdapter#generate(Object,Object,Monitor)
 * @see GeneratorAdapter#postGenerate(Object,Object)
 * @see GeneratorAdapterFactory#initialize(Object)
 */
public Diagnostic generate(Object object,Object projectType,String projectTypeName,Monitor monitor){
  if (SYSOUT_BEGIN_END)   System.out.println("String_Node_Str" + new java.util.Date());
  try {
    String message=projectTypeName != null ? CodeGenEcorePlugin.INSTANCE.getString("String_Node_Str",new Object[]{projectTypeName}) : CodeGenEcorePlugin.INSTANCE.getString("String_Node_Str");
    BasicDiagnostic result=new BasicDiagnostic(CodeGenEcorePlugin.ID,0,message,null);
    GeneratorData[] data=getGeneratorData(object,projectType,true);
    monitor.beginTask("String_Node_Str",data.length + 2);
    monitor.subTask(message);
    if (initializeNeeded) {
      initializeNeeded=false;
      initialize();
    }
    int preIndex=0;
    for (; preIndex < data.length && canContinue(result); preIndex++) {
      result.add(data[preIndex].adapter.preGenerate(data[preIndex].object,projectType));
    }
    monitor.worked(1);
    for (int i=0; i < data.length && canContinue(result); i++) {
      result.add(data[i].adapter.generate(data[i].object,projectType,CodeGenUtil.createMonitor(monitor,1)));
      if (monitor.isCanceled()) {
        result.add(Diagnostic.CANCEL_INSTANCE);
      }
    }
    for (int i=0; i < preIndex; i++) {
      result.add(data[i].adapter.postGenerate(data[i].object,projectType));
    }
    return result;
  }
  finally {
    monitor.done();
    if (SYSOUT_BEGIN_END)     System.out.println("String_Node_Str" + new java.util.Date());
  }
}