nus-yam/ex-repair huggingface dataset:
Program: 27607
Project: 27607
Buggy source:
private void assertPrettyPrint(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertPrettyPrint(String js,String expected,final CompilerOptionBuilder optionBuilder){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
      optionBuilder.setOptions(options);
    }
  }
)));
}
Program: 27608
Project: 27608
Buggy source:
private void validateExport(Node n){
  validateNodeType(Token.EXPORT,n);
  if (n.getBooleanProp(Node.EXPORT_ALL_FROM)) {
    validateChildCount(n,2);
    validateNodeType(Token.EMPTY,n.getFirstChild());
    validateString(n.getChildAtIndex(1));
  }
 else   if (n.getBooleanProp(Node.EXPORT_DEFAULT)) {
    validateChildCount(n,1);
    validateAssignmentTarget(n.getFirstChild());
  }
 else {
    validateMinimumChildCount(n,1);
    validateMaximumChildCount(n,2);
    if (n.getFirstChild().getType() == Token.EXPORT_SPECS) {
      validateExportSpecifiers(n.getFirstChild());
    }
 else {
      validateStatement(n.getFirstChild());
    }
    if (n.getChildCount() == 2) {
      validateString(n.getChildAtIndex(1));
    }
  }
}

Fixed version (ground truth):
private void validateExport(Node n){
  validateNodeType(Token.EXPORT,n);
  if (n.getBooleanProp(Node.EXPORT_ALL_FROM)) {
    validateChildCount(n,2);
    validateNodeType(Token.EMPTY,n.getFirstChild());
    validateString(n.getChildAtIndex(1));
  }
 else   if (n.getBooleanProp(Node.EXPORT_DEFAULT)) {
    validateChildCount(n,1);
    validateExpression(n.getFirstChild());
  }
 else {
    validateMinimumChildCount(n,1);
    validateMaximumChildCount(n,2);
    if (n.getFirstChild().getType() == Token.EXPORT_SPECS) {
      validateExportSpecifiers(n.getFirstChild());
    }
 else {
      validateStatement(n.getFirstChild());
    }
    if (n.getChildCount() == 2) {
      validateString(n.getChildAtIndex(1));
    }
  }
}
Program: 27611
Project: 27611
Buggy source:
public static Node declaration(Node lhs,Node value,int type){
  if (lhs.isName()) {
    Preconditions.checkState(!lhs.hasChildren());
  }
 else {
    Preconditions.checkState(lhs.isArrayPattern() || lhs.isObjectPattern());
  }
  Preconditions.checkState(mayBeExpression(value));
  lhs.addChildToBack(value);
  return new Node(type,lhs);
}

Fixed version (ground truth):
public static Node declaration(Node lhs,Node value,int type){
  if (lhs.isName()) {
    Preconditions.checkState(!lhs.hasChildren());
  }
 else {
    Preconditions.checkState(lhs.isArrayPattern() || lhs.isObjectPattern());
  }
  Preconditions.checkState(mayBeExpression(value),"String_Node_Str",value);
  lhs.addChildToBack(value);
  return new Node(type,lhs);
}
Program: 27612
Project: 27612
Buggy source:
/** 
 * It isn't possible to always determine if a detached node is a expression, so make a best guess.
 */
private static boolean mayBeExpression(Node n){
switch (n.getType()) {
case Token.FUNCTION:
    return true;
case Token.ADD:
case Token.AND:
case Token.ARRAYLIT:
case Token.ASSIGN:
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_LSH:
case Token.ASSIGN_RSH:
case Token.ASSIGN_URSH:
case Token.ASSIGN_ADD:
case Token.ASSIGN_SUB:
case Token.ASSIGN_MUL:
case Token.ASSIGN_DIV:
case Token.ASSIGN_MOD:
case Token.BITAND:
case Token.BITOR:
case Token.BITNOT:
case Token.BITXOR:
case Token.CALL:
case Token.CAST:
case Token.COMMA:
case Token.DEC:
case Token.DELPROP:
case Token.DIV:
case Token.EQ:
case Token.FALSE:
case Token.GE:
case Token.GETPROP:
case Token.GETELEM:
case Token.GT:
case Token.HOOK:
case Token.IN:
case Token.INC:
case Token.INSTANCEOF:
case Token.LE:
case Token.LSH:
case Token.LT:
case Token.MOD:
case Token.MUL:
case Token.NAME:
case Token.NE:
case Token.NEG:
case Token.NEW:
case Token.NOT:
case Token.NUMBER:
case Token.NULL:
case Token.OBJECTLIT:
case Token.OR:
case Token.POS:
case Token.REGEXP:
case Token.RSH:
case Token.SHEQ:
case Token.SHNE:
case Token.SPREAD:
case Token.STRING:
case Token.SUB:
case Token.SUPER:
case Token.TEMPLATELIT:
case Token.THIS:
case Token.TYPEOF:
case Token.TRUE:
case Token.URSH:
case Token.VOID:
case Token.YIELD:
  return true;
default :
return false;
}
}

Fixed version (ground truth):
/** 
 * It isn't possible to always determine if a detached node is a expression, so make a best guess.
 */
private static boolean mayBeExpression(Node n){
switch (n.getType()) {
case Token.FUNCTION:
case Token.CLASS:
    return true;
case Token.ADD:
case Token.AND:
case Token.ARRAYLIT:
case Token.ASSIGN:
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_LSH:
case Token.ASSIGN_RSH:
case Token.ASSIGN_URSH:
case Token.ASSIGN_ADD:
case Token.ASSIGN_SUB:
case Token.ASSIGN_MUL:
case Token.ASSIGN_DIV:
case Token.ASSIGN_MOD:
case Token.BITAND:
case Token.BITOR:
case Token.BITNOT:
case Token.BITXOR:
case Token.CALL:
case Token.CAST:
case Token.COMMA:
case Token.DEC:
case Token.DELPROP:
case Token.DIV:
case Token.EQ:
case Token.FALSE:
case Token.GE:
case Token.GETPROP:
case Token.GETELEM:
case Token.GT:
case Token.HOOK:
case Token.IN:
case Token.INC:
case Token.INSTANCEOF:
case Token.LE:
case Token.LSH:
case Token.LT:
case Token.MOD:
case Token.MUL:
case Token.NAME:
case Token.NE:
case Token.NEG:
case Token.NEW:
case Token.NOT:
case Token.NUMBER:
case Token.NULL:
case Token.OBJECTLIT:
case Token.OR:
case Token.POS:
case Token.REGEXP:
case Token.RSH:
case Token.SHEQ:
case Token.SHNE:
case Token.SPREAD:
case Token.STRING:
case Token.SUB:
case Token.SUPER:
case Token.TEMPLATELIT:
case Token.THIS:
case Token.TYPEOF:
case Token.TRUE:
case Token.URSH:
case Token.VOID:
case Token.YIELD:
  return true;
default :
return false;
}
}
Program: 27613
Project: 27613
Buggy source:
public void testMultiNameClass(){
  test("String_Node_Str",null,Es6ToEs3Converter.CANNOT_CONVERT_YET);
  test("String_Node_Str",null,Es6ToEs3Converter.CANNOT_CONVERT_YET);
}

Fixed version (ground truth):
public void testMultiNameClass(){
  test("String_Node_Str","String_Node_Str");
  test("String_Node_Str","String_Node_Str");
}
Program: 27614
Project: 27614
Buggy source:
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if (c == '"' && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}

Fixed version (ground truth):
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if ((c == '"' || c == '\'') && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}
Program: 27615
Project: 27615
Buggy source:
@Override void appendOp(String op,boolean binOp){
  if (binOp) {
    if (getLastChar() != ' ' && op.charAt(0) != ',') {
      append("String_Node_Str");
    }
    append(op);
    append("String_Node_Str");
  }
 else {
    append(op);
  }
}

Fixed version (ground truth):
@Override void appendOp(String op,boolean binOp){
  if (getLastChar() != ' ' && op.charAt(0) != ',') {
    append("String_Node_Str");
  }
  append(op);
  if (binOp) {
    append("String_Node_Str");
  }
}
Program: 27616
Project: 27616
Buggy source:
public void testStrict(){
  String result=parsePrint("String_Node_Str",false,false,0,false,true);
  assertEquals("String_Node_Str",result);
}

Fixed version (ground truth):
public void testStrict(){
  String result=new CodePrinter.Builder(parse("String_Node_Str",true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(0);
    }
  }
)).setOutputTypes(false).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(true).build();
  assertEquals("String_Node_Str",result);
}
Program: 27617
Project: 27617
Buggy source:
String parsePrint(String js,boolean prettyprint,boolean lineBreak,int lineThreshold,boolean outputTypes,boolean tagAsStrict){
  return new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(prettyprint,lineThreshold,lineBreak)).setOutputTypes(outputTypes).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(tagAsStrict).build();
}

Fixed version (ground truth):
String parsePrint(String js,CompilerOptions options){
  return new CodePrinter.Builder(parse(js)).setCompilerOptions(options).build();
}
Program: 27618
Project: 27618
Buggy source:
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,10));
}

Fixed version (ground truth):
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(10);
    }
  }
)));
}
Program: 27619
Project: 27619
Buggy source:
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,false,false,false,30));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,false,false,true,30));
}

Fixed version (ground truth):
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(false);
    }
  }
)));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(true);
    }
  }
)));
}
Program: 27620
Project: 27620
Buggy source:
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}
Program: 27621
Project: 27621
Buggy source:
CompilerOptions newCompilerOptions(boolean prettyprint,int lineThreshold,boolean lineBreak){
  CompilerOptions options=newCompilerOptions(prettyprint,lineThreshold);
  options.setLineBreak(lineBreak);
  return options;
}

Fixed version (ground truth):
CompilerOptions newCompilerOptions(CompilerOptionBuilder builder){
  CompilerOptions options=new CompilerOptions();
  options.setTrustedStrings(trustedStrings);
  options.preserveTypeAnnotations=preserveTypeAnnotations;
  options.setLanguageOut(languageMode);
  builder.setOptions(options);
  return options;
}
Program: 27622
Project: 27622
Buggy source:
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}
Program: 27623
Project: 27623
Buggy source:
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD,true));
}

Fixed version (ground truth):
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)).setOutputTypes(true).setTypeRegistry(lastCompiler.getTypeRegistry()).build());
}
Program: 27624
Project: 27624
Buggy source:
private void assertPrettyPrint(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertPrettyPrint(String js,String expected,final CompilerOptionBuilder optionBuilder){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
      optionBuilder.setOptions(options);
    }
  }
)));
}
Program: 27625
Project: 27625
Buggy source:
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if (c == '"' && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}

Fixed version (ground truth):
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if ((c == '"' || c == '\'') && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}
Program: 27626
Project: 27626
Buggy source:
@Override void appendOp(String op,boolean binOp){
  if (binOp) {
    if (getLastChar() != ' ' && op.charAt(0) != ',') {
      append("String_Node_Str");
    }
    append(op);
    append("String_Node_Str");
  }
 else {
    append(op);
  }
}

Fixed version (ground truth):
@Override void appendOp(String op,boolean binOp){
  if (binOp) {
    if (getLastChar() != ' ' && op.charAt(0) != ',') {
      append("String_Node_Str");
    }
    append(op);
    append("String_Node_Str");
  }
 else {
    append("String_Node_Str");
    append(op);
  }
}
Program: 27627
Project: 27627
Buggy source:
public void testStrict(){
  String result=parsePrint("String_Node_Str",false,false,0,false,true);
  assertEquals("String_Node_Str",result);
}

Fixed version (ground truth):
public void testStrict(){
  String result=new CodePrinter.Builder(parse("String_Node_Str",true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(0);
    }
  }
)).setOutputTypes(false).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(true).build();
  assertEquals("String_Node_Str",result);
}
Program: 27628
Project: 27628
Buggy source:
String parsePrint(String js,boolean prettyprint,boolean lineBreak,int lineThreshold,boolean outputTypes,boolean tagAsStrict){
  return new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(prettyprint,lineThreshold,lineBreak)).setOutputTypes(outputTypes).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(tagAsStrict).build();
}

Fixed version (ground truth):
String parsePrint(String js,CompilerOptions options){
  return new CodePrinter.Builder(parse(js)).setCompilerOptions(options).build();
}
Program: 27629
Project: 27629
Buggy source:
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,10));
}

Fixed version (ground truth):
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(10);
    }
  }
)));
}
Program: 27630
Project: 27630
Buggy source:
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,false,false,false,30));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,false,false,true,30));
}

Fixed version (ground truth):
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(false);
    }
  }
)));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(true);
    }
  }
)));
}
Program: 27631
Project: 27631
Buggy source:
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}
Program: 27632
Project: 27632
Buggy source:
CompilerOptions newCompilerOptions(boolean prettyprint,int lineThreshold,boolean lineBreak){
  CompilerOptions options=newCompilerOptions(prettyprint,lineThreshold);
  options.setLineBreak(lineBreak);
  return options;
}

Fixed version (ground truth):
CompilerOptions newCompilerOptions(CompilerOptionBuilder builder){
  CompilerOptions options=new CompilerOptions();
  options.setTrustedStrings(trustedStrings);
  options.preserveTypeAnnotations=preserveTypeAnnotations;
  options.setLanguageOut(languageMode);
  builder.setOptions(options);
  return options;
}
Program: 27633
Project: 27633
Buggy source:
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}
Program: 27634
Project: 27634
Buggy source:
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD,true));
}

Fixed version (ground truth):
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)).setOutputTypes(true).setTypeRegistry(lastCompiler.getTypeRegistry()).build());
}
Program: 27635
Project: 27635
Buggy source:
private void assertPrettyPrint(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}

Fixed version (ground truth):
private void assertPrettyPrint(String js,String expected,final CompilerOptionBuilder optionBuilder){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
      optionBuilder.setOptions(options);
    }
  }
)));
}
Program: 27636
Project: 27636
Buggy source:
public FunctionType instantiateGenerics(Map<String,JSType> typeMap){
  return applyInstantiation(false,typeMap);
}

Fixed version (ground truth):
public FunctionType instantiateGenerics(Map<String,JSType> typeMap){
  Preconditions.checkNotNull(typeParameters);
  return substituteParametricGenerics(typeMap);
}
Program: 27637
Project: 27637
Buggy source:
/** 
 * FunctionType#substituteGenerics is called while instantiating prototype methods of generic nominal types.
 */
FunctionType substituteGenerics(Map<String,JSType> concreteTypes){
  Preconditions.checkState(outerVarPreconditions.isEmpty());
  Map<String,JSType> typeMap=concreteTypes;
  if (typeParameters != null) {
    ImmutableMap.Builder<String,JSType> builder=ImmutableMap.builder();
    for (    Map.Entry<String,JSType> concreteTypeEntry : concreteTypes.entrySet()) {
      if (!typeParameters.contains(concreteTypeEntry.getKey())) {
        builder.put(concreteTypeEntry);
      }
    }
    typeMap=builder.build();
  }
  return applyInstantiation(true,typeMap);
}

Fixed version (ground truth):
/** 
 * FunctionType#substituteGenerics is called while instantiating prototype methods of generic nominal types.
 */
FunctionType substituteGenerics(Map<String,JSType> concreteTypes){
  Preconditions.checkState(outerVarPreconditions.isEmpty());
  Map<String,JSType> typeMap=concreteTypes;
  if (typeParameters != null) {
    ImmutableMap.Builder<String,JSType> builder=ImmutableMap.builder();
    for (    Map.Entry<String,JSType> concreteTypeEntry : concreteTypes.entrySet()) {
      if (!typeParameters.contains(concreteTypeEntry.getKey())) {
        builder.put(concreteTypeEntry);
      }
    }
    typeMap=builder.build();
  }
  return substituteNominalGenerics(typeMap);
}
Program: 27638
Project: 27638
Buggy source:
public FunctionType instantiateGenericsFromArgumentTypes(List<JSType> argTypes){
  if (argTypes.size() < getMinArity() || argTypes.size() > getMaxArity()) {
    return null;
  }
  Multimap<String,JSType> typeMultimap=HashMultimap.create();
  for (int i=0, size=argTypes.size(); i < size; i++) {
    if (!this.getFormalType(i).unifyWith(argTypes.get(i),typeParameters,typeMultimap)) {
      return null;
    }
  }
  ImmutableMap.Builder<String,JSType> builder=ImmutableMap.builder();
  for (  String typeParam : typeParameters) {
    Collection<JSType> types=typeMultimap.get(typeParam);
    if (types.size() != 1) {
      return null;
    }
    builder.put(typeParam,Iterables.getOnlyElement(types));
  }
  return applyInstantiation(false,builder.build());
}

Fixed version (ground truth):
public FunctionType instantiateGenericsFromArgumentTypes(List<JSType> argTypes){
  Preconditions.checkNotNull(typeParameters);
  if (argTypes.size() < getMinArity() || argTypes.size() > getMaxArity()) {
    return null;
  }
  Multimap<String,JSType> typeMultimap=HashMultimap.create();
  for (int i=0, size=argTypes.size(); i < size; i++) {
    if (!this.getFormalType(i).unifyWith(argTypes.get(i),typeParameters,typeMultimap)) {
      return null;
    }
  }
  ImmutableMap.Builder<String,JSType> builder=ImmutableMap.builder();
  for (  String typeParam : typeParameters) {
    Collection<JSType> types=typeMultimap.get(typeParam);
    if (types.size() != 1) {
      return null;
    }
    builder.put(typeParam,Iterables.getOnlyElement(types));
  }
  return substituteParametricGenerics(builder.build());
}
Program: 27639
Project: 27639
Buggy source:
NominalType instantiateGenerics(Map<String,JSType> newTypeMap){
  if (newTypeMap.isEmpty()) {
    return this;
  }
  if (!this.rawType.isGeneric()) {
    return this.rawType.wrappedAsNominal;
  }
  ImmutableMap.Builder<String,JSType> builder=ImmutableMap.builder();
  if (!typeMap.isEmpty()) {
    for (    String oldKey : typeMap.keySet()) {
      builder.put(oldKey,typeMap.get(oldKey).substituteGenerics(newTypeMap));
    }
  }
 else {
    for (    String newKey : rawType.typeParameters) {
      if (newTypeMap.containsKey(newKey)) {
        builder.put(newKey,newTypeMap.get(newKey));
      }
    }
  }
  return new NominalType(builder.build(),this.rawType);
}

Fixed version (ground truth):
NominalType instantiateGenerics(Map<String,JSType> newTypeMap){
  if (newTypeMap.isEmpty()) {
    return this;
  }
  if (!this.rawType.isGeneric()) {
    return this.rawType.wrappedAsNominal;
  }
  ImmutableMap.Builder<String,JSType> builder=ImmutableMap.builder();
  ImmutableMap<String,JSType> resultMap;
  if (!typeMap.isEmpty()) {
    for (    String oldKey : typeMap.keySet()) {
      builder.put(oldKey,typeMap.get(oldKey).substituteGenerics(newTypeMap));
    }
    resultMap=builder.build();
  }
 else {
    for (    String newKey : rawType.typeParameters) {
      if (newTypeMap.containsKey(newKey)) {
        builder.put(newKey,newTypeMap.get(newKey));
      }
    }
    resultMap=builder.build();
    if (resultMap.isEmpty()) {
      return this;
    }
    if (resultMap.size() < rawType.typeParameters.size()) {
      return this;
    }
  }
  return new NominalType(resultMap,this.rawType);
}
Program: 27641
Project: 27641
Buggy source:
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if ((c == '"' || c == '\'') && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}

Fixed version (ground truth):
void add(String newcode){
  maybeEndStatement();
  if (newcode.isEmpty()) {
    return;
  }
  char c=newcode.charAt(0);
  if ((isWordChar(c) || c == '\\') && isWordChar(getLastChar())) {
    append("String_Node_Str");
  }
 else   if (c == '/' && getLastChar() == '/') {
    append("String_Node_Str");
  }
 else   if (c == '"' && isWordChar(getLastChar())) {
    maybeInsertSpace();
  }
  append(newcode);
}
Program: 27642
Project: 27642
Buggy source:
@Override void appendOp(String op,boolean binOp){
  if (getLastChar() != ' ' && op.charAt(0) != ',') {
    append("String_Node_Str");
  }
  append(op);
  if (binOp) {
    append("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override void appendOp(String op,boolean binOp){
  if (binOp) {
    if (getLastChar() != ' ' && op.charAt(0) != ',') {
      append("String_Node_Str");
    }
    append(op);
    append("String_Node_Str");
  }
 else {
    append(op);
  }
}
Program: 27643
Project: 27643
Buggy source:
public void testStrict(){
  String result=new CodePrinter.Builder(parse("String_Node_Str",true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(0);
    }
  }
)).setOutputTypes(false).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(true).build();
  assertEquals("String_Node_Str",result);
}

Fixed version (ground truth):
public void testStrict(){
  String result=parsePrint("String_Node_Str",false,false,0,false,true);
  assertEquals("String_Node_Str",result);
}
Program: 27644
Project: 27644
Buggy source:
String parsePrint(String js,CompilerOptions options){
  return new CodePrinter.Builder(parse(js)).setCompilerOptions(options).build();
}

Fixed version (ground truth):
String parsePrint(String js,boolean prettyprint,boolean lineBreak,int lineThreshold,boolean outputTypes,boolean tagAsStrict){
  return new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(prettyprint,lineThreshold,lineBreak)).setOutputTypes(outputTypes).setTypeRegistry(lastCompiler.getTypeRegistry()).setTagAsStrict(tagAsStrict).build();
}
Program: 27645
Project: 27645
Buggy source:
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(10);
    }
  }
)));
}

Fixed version (ground truth):
private void assertLineLength(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,10));
}
Program: 27646
Project: 27646
Buggy source:
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(false);
    }
  }
)));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(false);
      options.setLineLengthThreshold(30);
      options.setPreferLineBreakAtEndOfFile(true);
    }
  }
)));
}

Fixed version (ground truth):
private void assertLineBreakAtEndOfFile(String js,String expectedWithoutBreakAtEnd,String expectedWithBreakAtEnd){
  assertEquals(expectedWithoutBreakAtEnd,parsePrint(js,false,false,false,30));
  assertEquals(expectedWithBreakAtEnd,parsePrint(js,false,false,true,30));
}
Program: 27647
Project: 27647
Buggy source:
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}

Fixed version (ground truth):
private void assertPrint(String js,String expected){
  parse(expected);
  assertEquals(expected,parsePrint(js,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}
Program: 27648
Project: 27648
Buggy source:
CompilerOptions newCompilerOptions(CompilerOptionBuilder builder){
  CompilerOptions options=new CompilerOptions();
  options.setTrustedStrings(trustedStrings);
  options.preserveTypeAnnotations=preserveTypeAnnotations;
  options.setLanguageOut(languageMode);
  builder.setOptions(options);
  return options;
}

Fixed version (ground truth):
CompilerOptions newCompilerOptions(boolean prettyprint,int lineThreshold,boolean lineBreak){
  CompilerOptions options=newCompilerOptions(prettyprint,lineThreshold);
  options.setLineBreak(lineBreak);
  return options;
}
Program: 27649
Project: 27649
Buggy source:
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(false);
      options.setLineBreak(true);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)));
}

Fixed version (ground truth):
private void assertLineBreak(String js,String expected){
  assertEquals(expected,parsePrint(js,false,true,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}
Program: 27650
Project: 27650
Buggy source:
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,new CodePrinter.Builder(parse(js,true)).setCompilerOptions(newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
    }
  }
)).setOutputTypes(true).setTypeRegistry(lastCompiler.getTypeRegistry()).build());
}

Fixed version (ground truth):
private void assertTypeAnnotations(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD,true));
}
Program: 27651
Project: 27651
Buggy source:
private void assertPrettyPrint(String js,String expected,final CompilerOptionBuilder optionBuilder){
  assertEquals(expected,parsePrint(js,newCompilerOptions(new CompilerOptionBuilder(){
    @Override void setOptions(    CompilerOptions options){
      options.setPrettyPrint(true);
      options.setLineBreak(false);
      options.setLineLengthThreshold(CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD);
      optionBuilder.setOptions(options);
    }
  }
)));
}

Fixed version (ground truth):
private void assertPrettyPrint(String js,String expected){
  assertEquals(expected,parsePrint(js,true,false,CodePrinter.DEFAULT_LINE_LENGTH_THRESHOLD));
}
Program: 27652
Project: 27652
Buggy source:
private TypeEnv analyzeCallNodeArgumentsFwd(Node call,Node firstArg,FunctionType funType,List<JSType> argTypesForDeferredCheck,TypeEnv inEnv){
  TypeEnv env=inEnv;
  Node arg=firstArg;
  int i=0;
  while (arg != null) {
    JSType formalType=funType.getFormalType(i);
    if (formalType.isBottom()) {
      warnings.add(JSError.make(call,CALL_FUNCTION_WITH_BOTTOM_FORMAL,Integer.toString(i)));
      formalType=JSType.UNKNOWN;
    }
    EnvTypePair pair=analyzeExprFwd(arg,env,formalType);
    JSType argTypeForDeferredCheck=pair.type;
    if (funType.isOptionalArg(i) && pair.type.equals(JSType.UNDEFINED)) {
      argTypeForDeferredCheck=null;
    }
 else     if (!pair.type.isSubtypeOf(formalType)) {
      warnings.add(JSError.make(arg,INVALID_ARGUMENT_TYPE,Integer.toString(i + 1),"String_Node_Str",formalType.toString(),pair.type.toString()));
      argTypeForDeferredCheck=null;
    }
    argTypesForDeferredCheck.add(argTypeForDeferredCheck);
    env=pair.env;
    arg=arg.getNext();
    i++;
  }
  return env;
}

Fixed version (ground truth):
private TypeEnv analyzeCallNodeArgumentsFwd(Node call,Node firstArg,FunctionType funType,List<JSType> argTypesForDeferredCheck,TypeEnv inEnv){
  TypeEnv env=inEnv;
  Node arg=firstArg;
  int i=0;
  while (arg != null) {
    JSType formalType=funType.getFormalType(i);
    if (formalType.isBottom()) {
      warnings.add(JSError.make(call,CALL_FUNCTION_WITH_BOTTOM_FORMAL,Integer.toString(i)));
      formalType=JSType.UNKNOWN;
    }
    EnvTypePair pair=analyzeExprFwd(arg,env,formalType);
    JSType argTypeForDeferredCheck=pair.type;
    if (funType.isOptionalArg(i) && pair.type.equals(JSType.UNDEFINED)) {
      argTypeForDeferredCheck=null;
    }
 else     if (!pair.type.isSubtypeOf(formalType)) {
      String fnName=getReadableCalleeName(call.getFirstChild());
      warnings.add(JSError.make(arg,INVALID_ARGUMENT_TYPE,Integer.toString(i + 1),fnName,formalType.toString(),pair.type.toString()));
      argTypeForDeferredCheck=null;
    }
    argTypesForDeferredCheck.add(argTypeForDeferredCheck);
    env=pair.env;
    arg=arg.getNext();
    i++;
  }
  return env;
}
Program: 27653
Project: 27653
Buggy source:
private EnvTypePair analyzePropAccessBwd(Node receiver,String pname,TypeEnv outEnv,JSType requiredType){
  QualifiedName qname=new QualifiedName(pname);
  EnvTypePair pair=analyzeExprBwd(receiver,outEnv,pickReqObjType(receiver.getParent()).withLoose().withProperty(qname,requiredType));
  JSType receiverType=pair.type;
  JSType propAccessType=receiverType.mayHaveProp(qname) ? receiverType.getProp(qname) : requiredType;
  pair.type=propAccessType;
  return pair;
}

Fixed version (ground truth):
private EnvTypePair analyzePropAccessBwd(Node receiver,String pname,TypeEnv outEnv,JSType requiredType){
  Node propAccessNode=receiver.getParent();
  QualifiedName qname=new QualifiedName(pname);
  JSType reqObjType=pickReqObjType(propAccessNode).withLoose();
  if (!NodeUtil.isPropertyTest(compiler,propAccessNode)) {
    reqObjType=reqObjType.withProperty(qname,requiredType);
  }
  EnvTypePair pair=analyzeExprBwd(receiver,outEnv,reqObjType);
  JSType receiverType=pair.type;
  JSType propAccessType=receiverType.mayHaveProp(qname) ? receiverType.getProp(qname) : requiredType;
  pair.type=propAccessType;
  return pair;
}
Program: 27654
Project: 27654
Buggy source:
private void checkPropertyAccessHelper(JSType objectType,String propName,NodeTraversal t,Node n){
  if (!objectType.isEmptyType() && reportMissingProperties && (!isPropertyTest(n) || objectType.isStruct())) {
    if (!typeRegistry.canPropertyBeDefined(objectType,propName)) {
      boolean lowConfidence=objectType.isUnknownType() || objectType.isEquivalentTo(getNativeType(OBJECT_TYPE));
      SuggestionPair pair=null;
      if (!lowConfidence) {
        pair=getClosestPropertySuggestion(objectType,propName);
      }
      if (pair != null && pair.distance * 4 < propName.length()) {
        report(t,n.getLastChild(),INEXISTENT_PROPERTY_WITH_SUGGESTION,propName,validator.getReadableJSTypeName(n.getFirstChild(),true),pair.suggestion);
      }
 else {
        DiagnosticType reportType=lowConfidence ? POSSIBLE_INEXISTENT_PROPERTY : INEXISTENT_PROPERTY;
        report(t,n.getLastChild(),reportType,propName,validator.getReadableJSTypeName(n.getFirstChild(),true));
      }
    }
  }
}

Fixed version (ground truth):
private void checkPropertyAccessHelper(JSType objectType,String propName,NodeTraversal t,Node n){
  if (!objectType.isEmptyType() && reportMissingProperties && (!NodeUtil.isPropertyTest(compiler,n) || objectType.isStruct())) {
    if (!typeRegistry.canPropertyBeDefined(objectType,propName)) {
      boolean lowConfidence=objectType.isUnknownType() || objectType.isEquivalentTo(getNativeType(OBJECT_TYPE));
      SuggestionPair pair=null;
      if (!lowConfidence) {
        pair=getClosestPropertySuggestion(objectType,propName);
      }
      if (pair != null && pair.distance * 4 < propName.length()) {
        report(t,n.getLastChild(),INEXISTENT_PROPERTY_WITH_SUGGESTION,propName,validator.getReadableJSTypeName(n.getFirstChild(),true),pair.suggestion);
      }
 else {
        DiagnosticType reportType=lowConfidence ? POSSIBLE_INEXISTENT_PROPERTY : INEXISTENT_PROPERTY;
        report(t,n.getLastChild(),reportType,propName,validator.getReadableJSTypeName(n.getFirstChild(),true));
      }
    }
  }
}
Program: 27655
Project: 27655
Buggy source:
boolean isLooseSubtypeOf(ObjectType obj2){
  Preconditions.checkState(isLoose || obj2.isLoose);
  if (obj2 == TOP_OBJECT) {
    return true;
  }
  if (!isLoose) {
    if (!objectKind.isSubtypeOf(obj2.objectKind)) {
      return false;
    }
    for (    String pname : obj2.props.keySet()) {
      QualifiedName qname=new QualifiedName(pname);
      if (!mayHaveProp(qname) || !getProp(qname).isSubtypeOf(obj2.getProp(qname))) {
        return false;
      }
    }
  }
 else {
    for (    String pname : props.keySet()) {
      QualifiedName qname=new QualifiedName(pname);
      if (obj2.mayHaveProp(qname) && !getProp(qname).isSubtypeOf(obj2.getProp(qname))) {
        return false;
      }
    }
  }
  if (obj2.fn == null) {
    return this.fn == null || obj2.isLoose();
  }
 else   if (this.fn == null) {
    return false;
  }
  return fn.isLooseSubtypeOf(obj2.fn);
}

Fixed version (ground truth):
boolean isLooseSubtypeOf(ObjectType obj2){
  Preconditions.checkState(isLoose || obj2.isLoose);
  if (obj2 == TOP_OBJECT) {
    return true;
  }
  if (!isLoose) {
    if (!objectKind.isSubtypeOf(obj2.objectKind)) {
      return false;
    }
    for (    String pname : obj2.props.keySet()) {
      QualifiedName qname=new QualifiedName(pname);
      if (!mayHaveProp(qname) || !getProp(qname).isSubtypeOf(obj2.getProp(qname))) {
        return false;
      }
    }
  }
 else {
    for (    String pname : props.keySet()) {
      QualifiedName qname=new QualifiedName(pname);
      if (obj2.mayHaveProp(qname) && !getProp(qname).isSubtypeOf(obj2.getProp(qname))) {
        return false;
      }
    }
  }
  if (obj2.fn == null) {
    return this.fn == null || obj2.isLoose();
  }
 else   if (this.fn == null) {
    return isLoose;
  }
  return fn.isLooseSubtypeOf(obj2.fn);
}
Program: 27656
Project: 27656
Buggy source:
public void testLooseObjectSubtyping(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ImmutableList.of(NewTypeInference.INVALID_ARGUMENT_TYPE,NewTypeInference.MISTYPED_ASSIGN_RHS));
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
public void testLooseObjectSubtyping(){
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",ImmutableList.of(NewTypeInference.INVALID_ARGUMENT_TYPE,NewTypeInference.MISTYPED_ASSIGN_RHS));
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str",NewTypeInference.INVALID_ARGUMENT_TYPE);
  typeCheck("String_Node_Str" + "String_Node_Str" + "String_Node_Str",NewTypeInference.MISTYPED_ASSIGN_RHS);
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  checkNoWarnings("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 27657
Project: 27657
Buggy source:
/** 
 * Returns the array of warnings (never null).
 */
public JSError[] getWarnings(){
  return errorManager.getWarnings();
}

Fixed version (ground truth):
/** 
 * Returns the array of warnings (never null).
 */
public JSError[] getWarnings(){
  if (errorManager == null) {
    return new JSError[]{};
  }
  return errorManager.getWarnings();
}
Program: 27658
Project: 27658
Buggy source:
/** 
 * Returns the array of errors (never null).
 */
public JSError[] getErrors(){
  return errorManager.getErrors();
}

Fixed version (ground truth):
/** 
 * Returns the array of errors (never null).
 */
public JSError[] getErrors(){
  if (errorManager == null) {
    return new JSError[]{};
  }
  return errorManager.getErrors();
}
Program: 27659
Project: 27659
Buggy source:
/** 
 * Renames a given node to the provided name.
 * @param n The node to rename.
 * @param name The new name for the node.
 * @param replaceEntireName True to replace the entire name of the node. Thedefault is to replace just the last property in the node with the new name. For instance, if  {@code replaceEntireName} is false, then{@code this.foo()} will be renamed to {@code this.bar()}. However, if it is true, it will be renamed to   {@code bar()}.
 */
public Builder rename(Node n,String name,boolean replaceEntireName){
  Node nodeToRename=null;
  if (n.isCall()) {
    Node child=n.getFirstChild();
    nodeToRename=child;
    if (!replaceEntireName && child.isGetProp()) {
      nodeToRename=child.getLastChild();
    }
  }
 else   if (n.isGetProp()) {
    nodeToRename=n.getLastChild();
    if (replaceEntireName) {
      while (nodeToRename.getParent().isGetProp()) {
        nodeToRename=nodeToRename.getParent();
      }
    }
  }
 else   if (n.isStringKey()) {
    nodeToRename=n;
  }
 else {
    throw new UnsupportedOperationException("String_Node_Str" + n.getType());
  }
  replacements.put(nodeToRename.getSourceFileName(),new CodeReplacement(nodeToRename.getSourceOffset(),nodeToRename.getLength(),name));
  return this;
}

Fixed version (ground truth):
/** 
 * Renames a given node to the provided name.
 * @param n The node to rename.
 * @param name The new name for the node.
 * @param replaceEntireName True to replace the entire name of the node. Thedefault is to replace just the last property in the node with the new name. For instance, if  {@code replaceEntireName} is false, then{@code this.foo()} will be renamed to {@code this.bar()}. However, if it is true, it will be renamed to   {@code bar()}.
 */
public Builder rename(Node n,String name,boolean replaceEntireName){
  Node nodeToRename=null;
  if (n.isCall()) {
    Node child=n.getFirstChild();
    nodeToRename=child;
    if (!replaceEntireName && child.isGetProp()) {
      nodeToRename=child.getLastChild();
    }
  }
 else   if (n.isGetProp()) {
    nodeToRename=n.getLastChild();
    if (replaceEntireName) {
      while (nodeToRename.getParent().isGetProp()) {
        nodeToRename=nodeToRename.getParent();
      }
    }
  }
 else   if (n.isStringKey()) {
    nodeToRename=n;
  }
 else   if (n.isString()) {
    Preconditions.checkState(n.getParent().isGetProp());
    nodeToRename=n;
  }
 else {
    throw new UnsupportedOperationException("String_Node_Str" + n);
  }
  replacements.put(nodeToRename.getSourceFileName(),new CodeReplacement(nodeToRename.getSourceOffset(),nodeToRename.getLength(),name));
  return this;
}
Program: 27660
Project: 27660
Buggy source:
/** 
 * Applies the provided set of code replacements to the code and returns the transformed code. The code replacements may not have any overlap.
 */
public static String applyCodeReplacements(Iterable<CodeReplacement> replacements,String code){
  List<CodeReplacement> sortedReplacements=ORDER_CODE_REPLACEMENTS.sortedCopy(replacements);
  validateNoOverlaps(sortedReplacements);
  StringBuilder sb=new StringBuilder();
  int lastIndex=0;
  for (  CodeReplacement replacement : sortedReplacements) {
    sb.append(code,lastIndex,replacement.getStartPosition());
    sb.append(replacement.getNewContent());
    lastIndex=replacement.getStartPosition() + replacement.getLength();
  }
  if (lastIndex <= sb.length()) {
    sb.append(code.substring(lastIndex));
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Applies the provided set of code replacements to the code and returns the transformed code. The code replacements may not have any overlap.
 */
public static String applyCodeReplacements(Iterable<CodeReplacement> replacements,String code){
  List<CodeReplacement> sortedReplacements=ORDER_CODE_REPLACEMENTS.sortedCopy(replacements);
  validateNoOverlaps(sortedReplacements);
  StringBuilder sb=new StringBuilder();
  int lastIndex=0;
  for (  CodeReplacement replacement : sortedReplacements) {
    sb.append(code,lastIndex,replacement.getStartPosition());
    sb.append(replacement.getNewContent());
    lastIndex=replacement.getStartPosition() + replacement.getLength();
  }
  if (lastIndex <= code.length()) {
    sb.append(code.substring(lastIndex));
  }
  return sb.toString();
}