Program: 166845
Project: 166845
Buggy source:
/** 
 * Add visitors for class, method, field, and type declarations.
 */
private void addDeclarationWriters(){
  addWriter(CompilationUnit.class,new CompilationUnitWriter(this));
  addWriter(TypeDeclaration.class,new TypeDeclarationWriter(this));
  addWriter(EnumDeclaration.class,new EnumDeclarationWriter(this));
  addWriter(MethodDeclaration.class,new MethodDeclarationWriter(this));
  addWriter(FieldDeclaration.class,new FieldDeclarationWriter(this));
  addWriter(VariableDeclarationFragment.class,new CSharpASTNodeWriter<VariableDeclarationFragment>(this){
    @Override public void write(    VariableDeclarationFragment variableDeclarationFragment){
      if (variableDeclarationFragment.getExtraDimensions() > 0)       throw sourceNotSupported("String_Node_Str");
      writeNode(variableDeclarationFragment.getName());
      Expression initializer=variableDeclarationFragment.getInitializer();
      if (initializer != null) {
        copySpaceAndComments();
        matchAndWrite("String_Node_Str");
        copySpaceAndComments();
        writeNode(initializer);
      }
    }
  }
);
  addWriter(SingleVariableDeclaration.class,new CSharpASTNodeWriter<SingleVariableDeclaration>(this){
    @Override public void write(    SingleVariableDeclaration singleVariableDeclaration){
      if (singleVariableDeclaration.getExtraDimensions() > 0)       throw sourceNotSupported("String_Node_Str");
      List<?> modifiers=singleVariableDeclaration.modifiers();
      ensureModifiersJustFinalOrAnnotations(modifiers);
      skipModifiers(modifiers);
      Type type=singleVariableDeclaration.getType();
      if (singleVariableDeclaration.isVarargs()) {
        write("String_Node_Str");
        writeNode(type);
        copySpaceAndComments();
        matchAndWrite("String_Node_Str","String_Node_Str");
      }
 else       writeNode(type);
      copySpaceAndComments();
      SimpleName name=singleVariableDeclaration.getName();
      writeNode(name);
      Expression initializer=singleVariableDeclaration.getInitializer();
      if (initializer != null)       throw new JUniversalException("String_Node_Str");
    }
  }
);
  addWriter(SimpleType.class,new CSharpASTNodeWriter<SimpleType>(this){
    @Override public void write(    SimpleType simpleType){
      Name name=simpleType.getName();
      if (isType(simpleType,"String_Node_Str")) {
        write("String_Node_Str");
        setPositionToEndOfNode(name);
      }
 else       if (isType(simpleType,"String_Node_Str")) {
        write("String_Node_Str");
        setPositionToEndOfNode(name);
      }
 else       if (isType(simpleType,"String_Node_Str")) {
        write("String_Node_Str");
        setPositionToEndOfNode(name);
      }
 else       if (name instanceof QualifiedName) {
        QualifiedName qualifiedName=(QualifiedName)name;
        write(getNamespaceNameForPackageName(qualifiedName.getQualifier()));
        setPositionToEndOfNode(qualifiedName.getQualifier());
        copySpaceAndComments();
        matchAndWrite("String_Node_Str","String_Node_Str");
        matchAndWrite(qualifiedName.getName().getIdentifier());
      }
 else {
        SimpleName simpleName=(SimpleName)name;
        matchAndWrite(simpleName.getIdentifier());
      }
    }
  }
);
  addWriter(ParameterizedType.class,new CSharpASTNodeWriter<ParameterizedType>(this){
    @Override public void write(    ParameterizedType parameterizedType){
      writeNode(parameterizedType.getType());
      copySpaceAndComments();
      matchAndWrite("String_Node_Str");
      writeCommaDelimitedNodes(parameterizedType.typeArguments());
      copySpaceAndComments();
      matchAndWrite("String_Node_Str");
    }
  }
);
  addWriter(WildcardType.class,new CSharpASTNodeWriter<WildcardType>(this){
    @Override public void write(    WildcardType wildcardType){
      ArrayList<WildcardType> wildcardTypes=getContext().getMethodWildcardTypes();
      if (wildcardTypes == null)       throw sourceNotSupported("String_Node_Str");
      writeWildcardTypeSyntheticName(wildcardTypes,wildcardType);
      setPositionToEndOfNode(wildcardType);
    }
  }
);
  addWriter(ArrayType.class,new CSharpASTNodeWriter<ArrayType>(this){
    @Override public void write(    ArrayType arrayType){
      writeNode(arrayType.getElementType());
      for (      Object dimensionObject : arrayType.dimensions()) {
        Dimension dimension=(Dimension)dimensionObject;
        copySpaceAndComments();
        matchAndWrite("String_Node_Str");
        copySpaceAndComments();
        matchAndWrite("String_Node_Str");
      }
    }
  }
);
  addWriter(PrimitiveType.class,new CSharpASTNodeWriter<PrimitiveType>(this){
    @Override public void write(    PrimitiveType primitiveType){
      PrimitiveType.Code code=primitiveType.getPrimitiveTypeCode();
      if (code == PrimitiveType.BYTE)       matchAndWrite("String_Node_Str","String_Node_Str");
 else       if (code == PrimitiveType.SHORT)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.CHAR)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.INT)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.LONG)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.FLOAT)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.DOUBLE)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.BOOLEAN)       matchAndWrite("String_Node_Str","String_Node_Str");
 else       if (code == PrimitiveType.VOID)       matchAndWrite("String_Node_Str","String_Node_Str");
 else       throw invalidAST("String_Node_Str" + code);
    }
  }
);
  addWriter(ArrayInitializer.class,new CSharpASTNodeWriter<ArrayInitializer>(this){
    @Override public void write(    ArrayInitializer arrayInitializer){
      matchAndWrite("String_Node_Str");
      writeCommaDelimitedNodes(arrayInitializer.expressions());
      copySpaceAndComments();
      matchAndWrite("String_Node_Str");
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Add visitors for class, method, field, and type declarations.
 */
private void addDeclarationWriters(){
  addWriter(CompilationUnit.class,new CompilationUnitWriter(this));
  addWriter(TypeDeclaration.class,new TypeDeclarationWriter(this));
  addWriter(EnumDeclaration.class,new EnumDeclarationWriter(this));
  addWriter(MethodDeclaration.class,new MethodDeclarationWriter(this));
  addWriter(FieldDeclaration.class,new FieldDeclarationWriter(this));
  addWriter(VariableDeclarationFragment.class,new CSharpASTNodeWriter<VariableDeclarationFragment>(this){
    @Override public void write(    VariableDeclarationFragment variableDeclarationFragment){
      if (variableDeclarationFragment.getExtraDimensions() > 0)       throw sourceNotSupported("String_Node_Str");
      writeNode(variableDeclarationFragment.getName());
      Expression initializer=variableDeclarationFragment.getInitializer();
      if (initializer != null) {
        copySpaceAndComments();
        matchAndWrite("String_Node_Str");
        copySpaceAndComments();
        writeNode(initializer);
      }
    }
  }
);
  addWriter(SingleVariableDeclaration.class,new CSharpASTNodeWriter<SingleVariableDeclaration>(this){
    @Override public void write(    SingleVariableDeclaration singleVariableDeclaration){
      if (singleVariableDeclaration.getExtraDimensions() > 0)       throw sourceNotSupported("String_Node_Str");
      List<?> modifiers=singleVariableDeclaration.modifiers();
      ensureModifiersJustFinalOrAnnotations(modifiers);
      skipModifiers(modifiers);
      Type type=singleVariableDeclaration.getType();
      if (singleVariableDeclaration.isVarargs()) {
        write("String_Node_Str");
        writeNode(type);
        copySpaceAndComments();
        matchAndWrite("String_Node_Str","String_Node_Str");
      }
 else       writeNode(type);
      copySpaceAndComments();
      SimpleName name=singleVariableDeclaration.getName();
      writeNode(name);
      Expression initializer=singleVariableDeclaration.getInitializer();
      if (initializer != null)       throw new JUniversalException("String_Node_Str");
    }
  }
);
  addWriter(SimpleType.class,new CSharpASTNodeWriter<SimpleType>(this){
    @Override public void write(    SimpleType simpleType){
      Name name=simpleType.getName();
      if (isType(simpleType,"String_Node_Str")) {
        write("String_Node_Str");
        setPositionToEndOfNode(name);
      }
 else       if (isType(simpleType,"String_Node_Str")) {
        write("String_Node_Str");
        setPositionToEndOfNode(name);
      }
 else       if (isType(simpleType,"String_Node_Str")) {
        write("String_Node_Str");
        setPositionToEndOfNode(name);
      }
 else       if (name instanceof QualifiedName) {
        QualifiedName qualifiedName=(QualifiedName)name;
        write(getNamespaceNameForPackageName(qualifiedName.getQualifier()));
        setPositionToEndOfNode(qualifiedName.getQualifier());
        copySpaceAndComments();
        matchAndWrite("String_Node_Str","String_Node_Str");
        matchAndWrite(qualifiedName.getName().getIdentifier());
      }
 else {
        SimpleName simpleName=(SimpleName)name;
        matchAndWrite(simpleName.getIdentifier());
      }
    }
  }
);
  addWriter(ParameterizedType.class,new CSharpASTNodeWriter<ParameterizedType>(this){
    @Override public void write(    ParameterizedType parameterizedType){
      writeNode(parameterizedType.getType());
      copySpaceAndComments();
      matchAndWrite("String_Node_Str");
      writeCommaDelimitedNodes(parameterizedType.typeArguments());
      copySpaceAndComments();
      matchAndWrite("String_Node_Str");
    }
  }
);
  addWriter(WildcardType.class,new CSharpASTNodeWriter<WildcardType>(this){
    @Override public void write(    WildcardType wildcardType){
      ArrayList<WildcardType> wildcardTypes=getContext().getMethodWildcardTypes();
      if (wildcardTypes == null)       throw sourceNotSupported("String_Node_Str");
      writeWildcardTypeSyntheticName(wildcardTypes,wildcardType);
      setPositionToEndOfNode(wildcardType);
    }
  }
);
  addWriter(ArrayType.class,new CSharpASTNodeWriter<ArrayType>(this){
    @Override public void write(    ArrayType arrayType){
      writeNode(arrayType.getElementType());
      for (      Object dimensionObject : arrayType.dimensions()) {
        Dimension dimension=(Dimension)dimensionObject;
        copySpaceAndComments();
        matchAndWrite("String_Node_Str");
        copySpaceAndComments();
        matchAndWrite("String_Node_Str");
      }
    }
  }
);
  addWriter(PrimitiveType.class,new CSharpASTNodeWriter<PrimitiveType>(this){
    @Override public void write(    PrimitiveType primitiveType){
      PrimitiveType.Code code=primitiveType.getPrimitiveTypeCode();
      if (code == PrimitiveType.BYTE)       matchAndWrite("String_Node_Str","String_Node_Str");
 else       if (code == PrimitiveType.SHORT)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.CHAR)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.INT)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.LONG)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.FLOAT)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.DOUBLE)       matchAndWrite("String_Node_Str");
 else       if (code == PrimitiveType.BOOLEAN)       matchAndWrite("String_Node_Str","String_Node_Str");
 else       if (code == PrimitiveType.VOID)       matchAndWrite("String_Node_Str","String_Node_Str");
 else       throw invalidAST("String_Node_Str" + code);
    }
  }
);
  addWriter(ArrayInitializer.class,new CSharpASTNodeWriter<ArrayInitializer>(this){
    @Override public void write(    ArrayInitializer arrayInitializer){
      if (arrayInitializer.getParent() instanceof ArrayInitializer) {
        context.write("String_Node_Str");
      }
      matchAndWrite("String_Node_Str");
      writeCommaDelimitedNodes(arrayInitializer.expressions());
      copySpaceAndComments();
      matchAndWrite("String_Node_Str");
    }
  }
);
}