nus-yam/ex-repair huggingface dataset:
Program: 27996
Project: 27996
Buggy source:
/** 
 * Given the name of a native object property, checks whether the property is present on the object and different from the native one.
 */
private boolean hasOverridenNativeProperty(String propertyName){
  if (isNativeObjectType()) {
    return false;
  }
  JSType propertyType=getPropertyType(propertyName);
  ObjectType nativeType=this.isFunctionType() ? registry.getNativeObjectType(JSTypeNative.FUNCTION_PROTOTYPE) : registry.getNativeObjectType(JSTypeNative.OBJECT_PROTOTYPE);
  JSType nativePropertyType=nativeType.getPropertyType(propertyName);
  return propertyType != nativePropertyType;
}

Fixed version (ground truth):
/** 
 * Given the name of a native object property, checks whether the property is present on the object and different from the native one.
 */
private boolean hasOverridenNativeProperty(String propertyName){
  if (isNativeObjectType()) {
    return false;
  }
  JSType propertyType=getPropertyType(propertyName);
  ObjectType nativeType=isFunctionType() ? registry.getNativeObjectType(JSTypeNative.FUNCTION_PROTOTYPE) : registry.getNativeObjectType(JSTypeNative.OBJECT_PROTOTYPE);
  JSType nativePropertyType=nativeType.getPropertyType(propertyName);
  return propertyType != nativePropertyType;
}
Program: 27997
Project: 27997
Buggy source:
@Override public boolean isSubtype(JSType that){
  if (JSType.isSubtypeHelper(this,that)) {
    return true;
  }
  if (that.isUnionType()) {
    return false;
  }
  if (that.isRecordType()) {
    return RecordType.isSubtype(this,that.toMaybeRecordType());
  }
  ObjectType thatObj=that.toObjectType();
  FunctionType thatCtor=thatObj == null ? null : thatObj.getConstructor();
  if (getConstructor() != null && getConstructor().isInterface()) {
    for (    ObjectType thisInterface : getCtorExtendedInterfaces()) {
      if (thisInterface.isSubtype(that)) {
        return true;
      }
    }
  }
 else   if (thatCtor != null && thatCtor.isInterface()) {
    Iterable<ObjectType> thisInterfaces=getCtorImplementedInterfaces();
    for (    ObjectType thisInterface : thisInterfaces) {
      if (thisInterface.isSubtype(that)) {
        return true;
      }
    }
  }
  if (isUnknownType() || implicitPrototypeChainIsUnknown()) {
    return true;
  }
  return thatObj != null && this.isImplicitPrototype(thatObj);
}

Fixed version (ground truth):
@Override public boolean isSubtype(JSType that){
  if (JSType.isSubtypeHelper(this,that)) {
    return true;
  }
  if (that.isUnionType()) {
    return false;
  }
  if (that.isRecordType()) {
    return RecordType.isSubtype(this,that.toMaybeRecordType());
  }
  ObjectType thatObj=that.toObjectType();
  FunctionType thatCtor=thatObj == null ? null : thatObj.getConstructor();
  if (getConstructor() != null && getConstructor().isInterface()) {
    for (    ObjectType thisInterface : getCtorExtendedInterfaces()) {
      if (thisInterface.isSubtype(that)) {
        return true;
      }
    }
  }
 else   if (thatCtor != null && thatCtor.isInterface()) {
    Iterable<ObjectType> thisInterfaces=getCtorImplementedInterfaces();
    for (    ObjectType thisInterface : thisInterfaces) {
      if (thisInterface.isSubtype(that)) {
        return true;
      }
    }
  }
  if (isUnknownType() || implicitPrototypeChainIsUnknown()) {
    return true;
  }
  return thatObj != null && isImplicitPrototype(thatObj);
}
Program: 28000
Project: 28000
Buggy source:
public void setImplementedInterfaces(List<ObjectType> implementedInterfaces){
  for (  ObjectType type : implementedInterfaces) {
    registry.registerTypeImplementingInterface(this,type);
  }
  this.implementedInterfaces=ImmutableList.copyOf(implementedInterfaces);
}

Fixed version (ground truth):
public void setImplementedInterfaces(List<ObjectType> implementedInterfaces){
  if (isConstructor()) {
    for (    ObjectType type : implementedInterfaces) {
      registry.registerTypeImplementingInterface(this,type);
    }
    this.implementedInterfaces=ImmutableList.copyOf(implementedInterfaces);
  }
 else {
    throw new UnsupportedOperationException();
  }
}
Program: 28001
Project: 28001
Buggy source:
private void addExpr(Node n,int minPrecedence,Context context){
  if ((NodeUtil.precedence(n.getType()) < minPrecedence) || ((context == Context.IN_FOR_INIT_CLAUSE) && (n.isIn()))) {
    add("String_Node_Str");
    add(n,clearContextForNoInOperator(context));
    add("String_Node_Str");
  }
 else {
    add(n,context);
  }
}

Fixed version (ground truth):
private void addExpr(Node n,int minPrecedence,Context context){
  if ((NodeUtil.precedence(n.getType()) < minPrecedence) || ((context == Context.IN_FOR_INIT_CLAUSE) && n.isIn())) {
    add("String_Node_Str");
    add(n,Context.OTHER);
    add("String_Node_Str");
  }
 else {
    add(n,context);
  }
}
Program: 28002
Project: 28002
Buggy source:
public void testObjectLit(){
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testObjectLit(){
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
  assertPrint("String_Node_Str","String_Node_Str");
}
Program: 28003
Project: 28003
Buggy source:
private void traverse(Node node){
  if (!shouldVisit(node)) {
    return;
  }
  int visits=0;
  do {
    for (Node c=node.getFirstChild(); c != null; c=c.getNext()) {
      traverse(c);
    }
    visit(node);
    visits++;
    Preconditions.checkState(visits < 10000,"String_Node_Str");
  }
 while (shouldRetraverse(node));
  exitNode(node);
}

Fixed version (ground truth):
private void traverse(Node node){
  if (!shouldVisit(node)) {
    return;
  }
  int visits=0;
  do {
    Node c=node.getFirstChild();
    while (c != null) {
      Node next=c.getNext();
      traverse(c);
      c=next;
    }
    visit(node);
    visits++;
    Preconditions.checkState(visits < 10000,"String_Node_Str");
  }
 while (shouldRetraverse(node));
  exitNode(node);
}
Program: 28004
Project: 28004
Buggy source:
public void testSuppressEs5StrictWarning(){
  CompilerOptions options=createCompilerOptions();
  options.setWarningLevel(DiagnosticGroups.ES5_STRICT,CheckLevel.WARNING);
  testSame(options,"String_Node_Str" + "String_Node_Str");
}

Fixed version (ground truth):
public void testSuppressEs5StrictWarning(){
  CompilerOptions options=createCompilerOptions();
  options.setWarningLevel(DiagnosticGroups.ES5_STRICT,CheckLevel.WARNING);
  test(options,"String_Node_Str" + "String_Node_Str","String_Node_Str");
}
Program: 28005
Project: 28005
Buggy source:
public void testVarDeclarationsIntoFor(){
  CompilerOptions options=createCompilerOptions();
  options.collapseVariableDeclarations=false;
  String code="String_Node_Str";
  testSame(options,code);
  options.collapseVariableDeclarations=false;
  test(options,code,"String_Node_Str");
}

Fixed version (ground truth):
public void testVarDeclarationsIntoFor(){
  CompilerOptions options=createCompilerOptions();
  options.collapseVariableDeclarations=false;
  String code="String_Node_Str";
  testSame(options,code);
  options.collapseVariableDeclarations=true;
  test(options,code,"String_Node_Str");
}
Program: 28006
Project: 28006
Buggy source:
protected Node parse(String[] original,CompilerOptions options){
  Compiler compiler=new Compiler();
  List<SourceFile> inputs=Lists.newArrayList();
  for (int i=0; i < original.length; i++) {
    inputs.add(SourceFile.fromCode("String_Node_Str" + i,original[i]));
  }
  compiler.init(externs,inputs,options);
  checkUnexpectedErrorsOrWarnings(compiler,0);
  Node all=compiler.parseInputs();
  checkUnexpectedErrorsOrWarnings(compiler,0);
  Node n=all.getLastChild();
  Node externs=all.getFirstChild();
  (new CreateSyntheticBlocks(compiler,"String_Node_Str","String_Node_Str")).process(externs,n);
  (new Normalize(compiler,false)).process(externs,n);
  (MakeDeclaredNamesUnique.getContextualRenameInverter(compiler)).process(externs,n);
  (new Denormalize(compiler)).process(externs,n);
  return n;
}

Fixed version (ground truth):
protected Node parse(String[] original,CompilerOptions options){
  Compiler compiler=new Compiler();
  List<SourceFile> inputs=Lists.newArrayList();
  for (int i=0; i < original.length; i++) {
    inputs.add(SourceFile.fromCode("String_Node_Str" + i,original[i]));
  }
  compiler.init(externs,inputs,options);
  checkUnexpectedErrorsOrWarnings(compiler,0);
  Node all=compiler.parseInputs();
  checkUnexpectedErrorsOrWarnings(compiler,0);
  Node n=all.getLastChild();
  Node externs=all.getFirstChild();
  (new CreateSyntheticBlocks(compiler,"String_Node_Str","String_Node_Str")).process(externs,n);
  return n;
}
Program: 28008
Project: 28008
Buggy source:
Candidate(String varName,Node defCfgNode,Node use,Node useCfgNode){
  Preconditions.checkArgument(use.isName());
  this.varName=varName;
  this.defCfgNode=defCfgNode;
  this.use=use;
  this.useCfgNode=useCfgNode;
}

Fixed version (ground truth):
Candidate(String varName,Definition defMetadata,Node use,Node useCfgNode){
  Preconditions.checkArgument(use.isName());
  this.varName=varName;
  this.defMetadata=defMetadata;
  this.use=use;
  this.useCfgNode=useCfgNode;
}
Program: 28010
Project: 28010
Buggy source:
@Override public void enterScope(NodeTraversal t){
  if (t.inGlobalScope()) {
    return;
  }
  if (LiveVariablesAnalysis.MAX_VARIABLES_TO_ANALYZE < t.getScope().getVarCount()) {
    return;
  }
  ControlFlowAnalysis cfa=new ControlFlowAnalysis(compiler,false,true);
  Preconditions.checkState(t.getScopeRoot().isFunction());
  cfa.process(null,t.getScopeRoot().getLastChild());
  cfg=cfa.getCfg();
  reachingDef=new MustBeReachingVariableDef(cfg,t.getScope(),compiler);
  reachingDef.analyze();
  candidates=Lists.newLinkedList();
  new NodeTraversal(compiler,new GatherCandiates()).traverse(t.getScopeRoot().getLastChild());
  reachingUses=new MaybeReachingVariableUse(cfg,t.getScope(),compiler);
  reachingUses.analyze();
  for (  Candidate c : candidates) {
    if (c.canInline()) {
      c.inlineVariable();
    }
  }
}

Fixed version (ground truth):
@Override public void enterScope(NodeTraversal t){
  if (t.inGlobalScope()) {
    return;
  }
  if (LiveVariablesAnalysis.MAX_VARIABLES_TO_ANALYZE < t.getScope().getVarCount()) {
    return;
  }
  ControlFlowAnalysis cfa=new ControlFlowAnalysis(compiler,false,true);
  Preconditions.checkState(t.getScopeRoot().isFunction());
  cfa.process(null,t.getScopeRoot().getLastChild());
  cfg=cfa.getCfg();
  reachingDef=new MustBeReachingVariableDef(cfg,t.getScope(),compiler);
  reachingDef.analyze();
  candidates=Lists.newLinkedList();
  new NodeTraversal(compiler,new GatherCandiates()).traverse(t.getScopeRoot().getLastChild());
  reachingUses=new MaybeReachingVariableUse(cfg,t.getScope(),compiler);
  reachingUses.analyze();
  for (  Candidate c : candidates) {
    if (c.canInline()) {
      c.inlineVariable();
      if (!c.defMetadata.depends.isEmpty()) {
        inlinedNewDependencies.add(t.getScope().getVar(c.varName));
      }
    }
  }
}
Program: 28011
Project: 28011
Buggy source:
/** 
 * Gets the must reaching definition of a given node. The node must be one of the control flow graph nodes.
 * @param name name of the variable. It can only be names of local variablethat are not function parameters, escaped variables or variables declared in catch.
 * @param useNode the location of the use where the definition reaches.
 */
Node getDef(String name,Node useNode){
  Preconditions.checkArgument(getCfg().hasNode(useNode));
  GraphNode<Node,Branch> n=getCfg().getNode(useNode);
  FlowState<MustDef> state=n.getAnnotation();
  Definition def=state.getIn().reachingDef.get(jsScope.getVar(name));
  if (def == null) {
    return null;
  }
 else {
    return def.node;
  }
}

Fixed version (ground truth):
/** 
 * Gets the must reaching definition of a given node.
 * @param name name of the variable. It can only be names of local variablethat are not function parameters, escaped variables or variables declared in catch.
 * @param useNode the location of the use where the definition reaches.
 */
Definition getDef(String name,Node useNode){
  Preconditions.checkArgument(getCfg().hasNode(useNode));
  GraphNode<Node,Branch> n=getCfg().getNode(useNode);
  FlowState<MustDef> state=n.getAnnotation();
  return state.getIn().reachingDef.get(jsScope.getVar(name));
}
Program: 28012
Project: 28012
Buggy source:
boolean dependsOnOuterScopeVars(String name,Node useNode){
  Preconditions.checkArgument(getCfg().hasNode(useNode));
  GraphNode<Node,Branch> n=getCfg().getNode(useNode);
  FlowState<MustDef> state=n.getAnnotation();
  Definition def=state.getIn().reachingDef.get(jsScope.getVar(name));
  if (def.unknownDependencies) {
    return true;
  }
  for (  Var s : def.depends) {
    if (s.scope != jsScope) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
boolean dependsOnOuterScopeVars(Definition def){
  if (def.unknownDependencies) {
    return true;
  }
  for (  Var s : def.depends) {
    if (s.scope != jsScope) {
      return true;
    }
  }
  return false;
}
Program: 28013
Project: 28013
Buggy source:
public void testFunctionParams1(){
  computeDefUse("String_Node_Str");
  assertSame(def,defUse.getDef("String_Node_Str",use));
}

Fixed version (ground truth):
public void testFunctionParams1(){
  computeDefUse("String_Node_Str");
  assertSame(def,defUse.getDefNode("String_Node_Str",use));
}
Program: 28014
Project: 28014
Buggy source:
public void testFunctionParams2(){
  computeDefUse("String_Node_Str");
  assertNotSame(def,defUse.getDef("String_Node_Str",use));
}

Fixed version (ground truth):
public void testFunctionParams2(){
  computeDefUse("String_Node_Str");
  assertNotSame(def,defUse.getDefNode("String_Node_Str",use));
}
Program: 28015
Project: 28015
Buggy source:
/** 
 * The use of x at U: is the definition of x at D:.
 */
private void assertMatch(String src){
  computeDefUse(src);
  assertSame(def,defUse.getDef("String_Node_Str",use));
}

Fixed version (ground truth):
/** 
 * The use of x at U: is the definition of x at D:.
 */
private void assertMatch(String src){
  computeDefUse(src);
  assertSame(def,defUse.getDefNode("String_Node_Str",use));
}
Program: 28016
Project: 28016
Buggy source:
public void testArgumentsObjectEscaped(){
  computeDefUse("String_Node_Str");
  assertNotSame(def,defUse.getDef("String_Node_Str",use));
}

Fixed version (ground truth):
public void testArgumentsObjectEscaped(){
  computeDefUse("String_Node_Str");
  assertNotSame(def,defUse.getDefNode("String_Node_Str",use));
}
Program: 28017
Project: 28017
Buggy source:
/** 
 * The use of x at U: is not the definition of x at D:.
 */
private void assertNotMatch(String src){
  computeDefUse(src);
  assertNotSame(def,defUse.getDef("String_Node_Str",use));
}

Fixed version (ground truth):
/** 
 * The use of x at U: is not the definition of x at D:.
 */
private void assertNotMatch(String src){
  computeDefUse(src);
  assertNotSame(def,defUse.getDefNode("String_Node_Str",use));
}
Program: 28018
Project: 28018
Buggy source:
public void testArgumentsObjectModifications(){
  computeDefUse("String_Node_Str");
  assertNotSame(def,defUse.getDef("String_Node_Str",use));
}

Fixed version (ground truth):
public void testArgumentsObjectModifications(){
  computeDefUse("String_Node_Str");
  assertNotSame(def,defUse.getDefNode("String_Node_Str",use));
}
Program: 28019
Project: 28019
Buggy source:
@Override public void addDeclaredName(String name){
  Preconditions.checkState(!name.equals(ARGUMENTS));
  if (!declarations.containsKey(name)) {
    declarations.put(name,getUniqueName(name));
  }
}

Fixed version (ground truth):
@Override public void addDeclaredName(String name){
  if (whitelist.contains(name)) {
    delegate.addDeclaredName(name);
  }
}
Program: 28020
Project: 28020
Buggy source:
@Override public String getReplacementName(String oldName){
  return declarations.get(oldName);
}

Fixed version (ground truth):
@Override public String getReplacementName(String oldName){
  return whitelist.contains(oldName) ? delegate.getReplacementName(oldName) : null;
}
Program: 28021
Project: 28021
Buggy source:
@Override public boolean stripConstIfReplaced(){
  return removeConstness;
}

Fixed version (ground truth):
@Override public boolean stripConstIfReplaced(){
  return delegate.stripConstIfReplaced();
}
Program: 28022
Project: 28022
Buggy source:
@Override public Renamer forChildScope(){
  return new InlineRenamer(uniqueIdSupplier,idPrefix,false);
}

Fixed version (ground truth):
@Override public Renamer forChildScope(){
  return new WhitelistedRenamer(delegate.forChildScope(),whitelist);
}
Program: 28023
Project: 28023
Buggy source:
private void findAliases(NodeTraversal t){
  Scope scope=t.getScope();
  for (  Var v : scope.getVarIterable()) {
    Node n=v.getNode();
    int type=n.getType();
    Node parent=n.getParent();
    if (parent.isVar() && n.hasChildren() && n.getFirstChild().isQualifiedName()) {
      String name=n.getString();
      Var aliasVar=scope.getVar(name);
      aliases.put(name,aliasVar);
      String qualifiedName=aliasVar.getInitialValue().getQualifiedName();
      transformation.addAlias(name,qualifiedName);
    }
 else     if (v.isBleedingFunction()) {
    }
 else     if (parent.getType() == Token.LP) {
    }
 else {
      report(t,n,GOOG_SCOPE_NON_ALIAS_LOCAL,n.getString());
    }
  }
}

Fixed version (ground truth):
private void findAliases(NodeTraversal t){
  Scope scope=t.getScope();
  for (  Var v : scope.getVarIterable()) {
    Node n=v.getNode();
    int type=n.getType();
    Node parent=n.getParent();
    if (parent.isVar() && n.hasChildren() && n.getFirstChild().isQualifiedName()) {
      String name=n.getString();
      Var aliasVar=scope.getVar(name);
      aliases.put(name,aliasVar);
      String qualifiedName=aliasVar.getInitialValue().getQualifiedName();
      transformation.addAlias(name,qualifiedName);
      int rootIndex=qualifiedName.indexOf("String_Node_Str");
      if (rootIndex != -1) {
        String qNameRoot=qualifiedName.substring(0,rootIndex);
        if (!aliases.containsKey(qNameRoot)) {
          forbiddenLocals.add(qNameRoot);
        }
      }
    }
 else     if (v.isBleedingFunction()) {
    }
 else     if (parent.getType() == Token.LP) {
    }
 else {
      report(t,n,GOOG_SCOPE_NON_ALIAS_LOCAL,n.getString());
    }
  }
}
Program: 28024
Project: 28024
Buggy source:
@Override public void exitScope(NodeTraversal t){
  if (t.getScopeDepth() == 2) {
    aliases.clear();
    transformation=null;
  }
}

Fixed version (ground truth):
@Override public void exitScope(NodeTraversal t){
  if (t.getScopeDepth() > 2) {
    findNamespaceShadows(t);
  }
  if (t.getScopeDepth() == 2) {
    renameNamespaceShadows(t);
    aliases.clear();
    forbiddenLocals.clear();
    transformation=null;
    hasNamespaceShadows=false;
  }
}
Program: 28025
Project: 28025
Buggy source:
/** 
 * @param iterator The to use while inspecting the nodebeginning with the deepest ancestor.
 */
private LocalVarMotion(Node nameNode,FunctionlessLocalScope iterator){
  Preconditions.checkArgument(nameNode.isName());
  Node valueNode=NodeUtil.getAssignedValue(nameNode);
  this.varName=nameNode.getString();
  this.valueHasSideEffects=valueNode != null && NodeUtil.mayHaveSideEffects(valueNode);
  this.iterator=iterator;
  advanceLookAhead(true);
}

Fixed version (ground truth):
/** 
 * @param iterator The iterator to use while inspecting the nodebeginning with the deepest ancestor.
 */
private LocalVarMotion(Node nameNode,FunctionlessLocalScope iterator){
  Preconditions.checkArgument(nameNode.isName());
  Node valueNode=NodeUtil.getAssignedValue(nameNode);
  this.varName=nameNode.getString();
  this.valueHasSideEffects=valueNode != null && NodeUtil.mayHaveSideEffects(valueNode);
  this.iterator=iterator;
  advanceLookAhead(true);
}
Program: 28026
Project: 28026
Buggy source:
private void advanceLookAhead(boolean atStart){
  if (!atStart) {
    if (lookAhead == null) {
      return;
    }
    Node curNode=iterator.current();
    if (curNode.isName() && varName.equals(curNode.getString())) {
      lookAhead=null;
      return;
    }
  }
  if (!iterator.hasNext()) {
    lookAhead=null;
    return;
  }
  Node nextNode=iterator.next();
  Node nextParent=iterator.currentParent();
  int type=nextNode.getType();
  if (valueHasSideEffects) {
    if (type == Token.NAME && !varName.equals(nextNode.getString())) {
      boolean blocked=false;
      if (nextParent == null) {
        blocked=true;
      }
 else {
        boolean assignsName=(nextParent.isAssign() && nextNode == nextParent.getFirstChild());
        boolean isVarDeclaration=(nextParent.isVar());
        if (!assignsName && !isVarDeclaration) {
          blocked=true;
        }
      }
      if (blocked) {
        lookAhead=null;
        return;
      }
    }
  }
  if (NodeUtil.nodeTypeMayHaveSideEffects(nextNode) && type != Token.NAME || type == Token.NAME && nextParent.isCatch()) {
    lookAhead=null;
    return;
  }
  lookAhead=nextNode;
}

Fixed version (ground truth):
private void advanceLookAhead(boolean atStart){
  if (!atStart) {
    if (lookAhead == null) {
      return;
    }
    Node curNode=iterator.current();
    if (curNode.isName() && varName.equals(curNode.getString())) {
      lookAhead=null;
      return;
    }
  }
  if (!iterator.hasNext()) {
    lookAhead=null;
    return;
  }
  Node nextNode=iterator.next();
  Node nextParent=iterator.currentParent();
  int type=nextNode.getType();
  if (valueHasSideEffects) {
    boolean readsState=false;
    if ((nextNode.isName() && !varName.equals(nextNode.getString())) || (nextNode.isGetProp() || nextNode.isGetElem())) {
      if (nextParent == null || !NodeUtil.isVarOrSimpleAssignLhs(nextNode,nextParent)) {
        readsState=true;
      }
    }
 else     if (nextNode.isCall() || nextNode.isNew()) {
      readsState=true;
    }
    if (readsState) {
      lookAhead=null;
      return;
    }
  }
  if (NodeUtil.nodeTypeMayHaveSideEffects(nextNode) && type != Token.NAME || type == Token.NAME && nextParent.isCatch()) {
    lookAhead=null;
    return;
  }
  lookAhead=nextNode;
}
Program: 28027
Project: 28027
Buggy source:
/** 
 * Returns a   {@code CompilerEnvirons} suitable for using Rhinoin an IDE environment.  Most features are enabled by default. The  {@link ErrorReporter} is set to an {@link ErrorCollector}.
 */
public static CompilerEnvirons ideEnvirons(){
  CompilerEnvirons env=new CompilerEnvirons();
  env.setRecoverFromErrors(true);
  env.setRecordingComments(true);
  env.setStrictMode(true);
  env.setWarnTrailingComma(true);
  env.setLanguageVersion(170);
  env.setReservedKeywordAsIdentifier(true);
  env.setAllowKeywordAsObjectPropertyName(true);
  env.setIdeMode(true);
  env.setErrorReporter(new ErrorCollector());
  return env;
}

Fixed version (ground truth):
/** 
 * Returns a   {@code CompilerEnvirons} suitable for using Rhinoin an IDE environment.  Most features are enabled by default. The  {@link ErrorReporter} is set to an {@link ErrorCollector}.
 */
public static CompilerEnvirons ideEnvirons(){
  CompilerEnvirons env=new CompilerEnvirons();
  env.setRecoverFromErrors(true);
  env.setRecordingComments(true);
  env.setStrictMode(true);
  env.setWarnTrailingComma(true);
  env.setLanguageVersion(170);
  env.setReservedKeywordAsIdentifier(true);
  env.setIdeMode(true);
  env.setErrorReporter(new ErrorCollector());
  return env;
}
Program: 28028
Project: 28028
Buggy source:
public CompilerEnvirons(){
  errorReporter=DefaultErrorReporter.instance;
  languageVersion=Context.VERSION_DEFAULT;
  generateDebugInfo=true;
  reservedKeywordAsIdentifier=true;
  allowKeywordAsObjectPropertyName=false;
  allowMemberExprAsFunctionName=false;
  xmlAvailable=true;
  optimizationLevel=0;
  generatingSource=true;
  strictMode=false;
  warningAsError=false;
  generateObserverCount=false;
  allowSharpComments=false;
}

Fixed version (ground truth):
public CompilerEnvirons(){
  errorReporter=DefaultErrorReporter.instance;
  languageVersion=Context.VERSION_DEFAULT;
  generateDebugInfo=true;
  reservedKeywordAsIdentifier=true;
  allowMemberExprAsFunctionName=false;
  xmlAvailable=true;
  optimizationLevel=0;
  generatingSource=true;
  strictMode=false;
  warningAsError=false;
  generateObserverCount=false;
  allowSharpComments=false;
}
Program: 28029
Project: 28029
Buggy source:
public void initFromContext(Context cx){
  setErrorReporter(cx.getErrorReporter());
  languageVersion=cx.getLanguageVersion();
  generateDebugInfo=(!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug());
  reservedKeywordAsIdentifier=cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
  allowKeywordAsObjectPropertyName=(languageVersion >= Context.VERSION_1_8);
  allowMemberExprAsFunctionName=cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
  strictMode=cx.hasFeature(Context.FEATURE_STRICT_MODE);
  warningAsError=cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR);
  xmlAvailable=cx.hasFeature(Context.FEATURE_E4X);
  optimizationLevel=cx.getOptimizationLevel();
  generatingSource=cx.isGeneratingSource();
  activationNames=cx.activationNames;
  generateObserverCount=cx.generateObserverCount;
}

Fixed version (ground truth):
public void initFromContext(Context cx){
  setErrorReporter(cx.getErrorReporter());
  languageVersion=cx.getLanguageVersion();
  generateDebugInfo=(!cx.isGeneratingDebugChanged() || cx.isGeneratingDebug());
  reservedKeywordAsIdentifier=cx.hasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
  allowMemberExprAsFunctionName=cx.hasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
  strictMode=cx.hasFeature(Context.FEATURE_STRICT_MODE);
  warningAsError=cx.hasFeature(Context.FEATURE_WARNING_AS_ERROR);
  xmlAvailable=cx.hasFeature(Context.FEATURE_E4X);
  optimizationLevel=cx.getOptimizationLevel();
  generatingSource=cx.isGeneratingSource();
  activationNames=cx.activationNames;
  generateObserverCount=cx.generateObserverCount;
}
Program: 28032
Project: 28032
Buggy source:
@Override protected void setUp() throws Exception {
  super.setUp();
  allowKeywordsAsObjectLiteralsKeys=false;
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  super.setUp();
  environment=new CompilerEnvirons();
}
Program: 28033
Project: 28033
Buggy source:
public void testParseObjectLiteral2(){
  expectParseErrors("String_Node_Str",new String[]{"String_Node_Str"});
  allowKeywordsAsObjectLiteralsKeys=true;
  parse("String_Node_Str");
}

Fixed version (ground truth):
public void testParseObjectLiteral2(){
  environment.setReservedKeywordAsIdentifier(false);
  expectParseErrors("String_Node_Str",new String[]{"String_Node_Str"});
  environment.setReservedKeywordAsIdentifier(true);
  parse("String_Node_Str");
}
Program: 28034
Project: 28034
Buggy source:
public void testParseObjectLiteral1(){
  allowKeywordsAsObjectLiteralsKeys=true;
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
}

Fixed version (ground truth):
public void testParseObjectLiteral1(){
  environment.setReservedKeywordAsIdentifier(true);
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
  parse("String_Node_Str");
}
Program: 28035
Project: 28035
Buggy source:
private AstRoot parseAsReader(String string) throws IOException {
  CompilerEnvirons environment=new CompilerEnvirons();
  TestErrorReporter testErrorReporter=new TestErrorReporter(null,null);
  environment.setErrorReporter(testErrorReporter);
  environment.setRecordingComments(true);
  environment.setRecordingLocalJsDocComments(true);
  Parser p=new Parser(environment,testErrorReporter);
  AstRoot script=p.parse(new StringReader(string),null,0);
  assertTrue(testErrorReporter.hasEncounteredAllErrors());
  assertTrue(testErrorReporter.hasEncounteredAllWarnings());
  return script;
}

Fixed version (ground truth):
private AstRoot parseAsReader(String string) throws IOException {
  TestErrorReporter testErrorReporter=new TestErrorReporter(null,null);
  environment.setErrorReporter(testErrorReporter);
  environment.setRecordingComments(true);
  environment.setRecordingLocalJsDocComments(true);
  Parser p=new Parser(environment,testErrorReporter);
  AstRoot script=p.parse(new StringReader(string),null,0);
  assertTrue(testErrorReporter.hasEncounteredAllErrors());
  assertTrue(testErrorReporter.hasEncounteredAllWarnings());
  return script;
}
Program: 28036
Project: 28036
Buggy source:
public void testParseKeywordPropertyAccess(){
  allowKeywordsAsObjectLiteralsKeys=true;
  parse("String_Node_Str");
  parse("String_Node_Str");
}

Fixed version (ground truth):
public void testParseKeywordPropertyAccess(){
  environment.setReservedKeywordAsIdentifier(true);
  parse("String_Node_Str");
  parse("String_Node_Str");
}
Program: 28037
Project: 28037
Buggy source:
private AstRoot parse(String string,final String[] errors,final String[] warnings,boolean jsdoc){
  CompilerEnvirons environment=new CompilerEnvirons();
  environment.setReservedKeywordAsIdentifier(allowKeywordsAsObjectLiteralsKeys);
  TestErrorReporter testErrorReporter=new TestErrorReporter(errors,warnings){
    @Override public EvaluatorException runtimeError(    String message,    String sourceName,    int line,    String lineSource,    int lineOffset){
      if (errors == null) {
        throw new UnsupportedOperationException();
      }
      return new EvaluatorException(message,sourceName,line,lineSource,lineOffset);
    }
  }
;
  environment.setErrorReporter(testErrorReporter);
  environment.setRecordingComments(true);
  environment.setRecordingLocalJsDocComments(jsdoc);
  Parser p=new Parser(environment,testErrorReporter);
  AstRoot script=null;
  try {
    script=p.parse(string,null,0);
  }
 catch (  EvaluatorException e) {
    if (errors == null) {
      throw e;
    }
  }
  assertTrue(testErrorReporter.hasEncounteredAllErrors());
  assertTrue(testErrorReporter.hasEncounteredAllWarnings());
  return script;
}

Fixed version (ground truth):
private AstRoot parse(String string,final String[] errors,final String[] warnings,boolean jsdoc){
  TestErrorReporter testErrorReporter=new TestErrorReporter(errors,warnings){
    @Override public EvaluatorException runtimeError(    String message,    String sourceName,    int line,    String lineSource,    int lineOffset){
      if (errors == null) {
        throw new UnsupportedOperationException();
      }
      return new EvaluatorException(message,sourceName,line,lineSource,lineOffset);
    }
  }
;
  environment.setErrorReporter(testErrorReporter);
  environment.setRecordingComments(true);
  environment.setRecordingLocalJsDocComments(jsdoc);
  Parser p=new Parser(environment,testErrorReporter);
  AstRoot script=null;
  try {
    script=p.parse(string,null,0);
  }
 catch (  EvaluatorException e) {
    if (errors == null) {
      throw e;
    }
  }
  assertTrue(testErrorReporter.hasEncounteredAllErrors());
  assertTrue(testErrorReporter.hasEncounteredAllWarnings());
  return script;
}
Program: 28039
Project: 28039
Buggy source:
private FlowScope traverseNew(Node n,FlowScope scope){
  Node constructor=n.getFirstChild();
  scope=traverse(constructor,scope);
  JSType constructorType=constructor.getJSType();
  JSType type=null;
  if (constructorType != null) {
    constructorType=constructorType.restrictByNotNullOrUndefined();
    if (constructorType.isUnknownType()) {
      type=getNativeType(UNKNOWN_TYPE);
    }
 else {
      FunctionType ct=constructorType.toMaybeFunctionType();
      if (ct == null && constructorType instanceof FunctionType) {
        ct=(FunctionType)constructorType;
      }
      if (ct != null && ct.isConstructor()) {
        type=ct.getInstanceType();
      }
    }
  }
  n.setJSType(type);
  for (Node arg=constructor.getNext(); arg != null; arg=arg.getNext()) {
    scope=traverse(arg,scope);
  }
  return scope;
}

Fixed version (ground truth):
private FlowScope traverseNew(Node n,FlowScope scope){
  scope=traverseChildren(n,scope);
  Node constructor=n.getFirstChild();
  JSType constructorType=constructor.getJSType();
  JSType type=null;
  if (constructorType != null) {
    constructorType=constructorType.restrictByNotNullOrUndefined();
    if (constructorType.isUnknownType()) {
      type=getNativeType(UNKNOWN_TYPE);
    }
 else {
      FunctionType ct=constructorType.toMaybeFunctionType();
      if (ct == null && constructorType instanceof FunctionType) {
        ct=(FunctionType)constructorType;
      }
      if (ct != null && ct.isConstructor()) {
        type=ct.getInstanceType();
        backwardsInferenceFromCallSite(n,ct);
      }
    }
  }
  n.setJSType(type);
  return scope;
}
Program: 28040
Project: 28040
Buggy source:
/** 
 * Gets the type of   {@code this} in this function.
 */
@Override public ObjectType getTypeOfThis(){
  return typeOfThis.isNoObjectType() ? registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE) : typeOfThis;
}

Fixed version (ground truth):
/** 
 * Gets the type of   {@code this} in this function.
 */
@Override public ObjectType getTypeOfThis(){
  return typeOfThis.isNoObjectType() ? registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE) : typeOfThis;
}
Program: 28041
Project: 28041
Buggy source:
@Override public void process(Node externs,Node root){
  (new NodeTraversal(compiler,this)).traverse(root);
}

Fixed version (ground truth):
@Override public void process(Node externs,Node root){
  (new NodeTraversal(compiler,this)).traverseRoots(externs,root);
}
Program: 28042
Project: 28042
Buggy source:
boolean dependsOnOuterScopeVars(String name,Node useNode){
  Preconditions.checkArgument(getCfg().hasNode(useNode));
  GraphNode<Node,Branch> n=getCfg().getNode(useNode);
  FlowState<MustDef> state=n.getAnnotation();
  Definition def=state.getIn().reachingDef.get(jsScope.getVar(name));
  for (  Var s : def.depends) {
    if (s.scope != jsScope) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
boolean dependsOnOuterScopeVars(String name,Node useNode){
  Preconditions.checkArgument(getCfg().hasNode(useNode));
  GraphNode<Node,Branch> n=getCfg().getNode(useNode);
  FlowState<MustDef> state=n.getAnnotation();
  Definition def=state.getIn().reachingDef.get(jsScope.getVar(name));
  if (def.unknownDependencies) {
    return true;
  }
  for (  Var s : def.depends) {
    if (s.scope != jsScope) {
      return true;
    }
  }
  return false;
}
Program: 28043
Project: 28043
Buggy source:
/** 
 * Computes all the local variables that rValue reads from and store that in the def's depends set.
 */
private void computeDependence(final Definition def,Node rValue){
  NodeTraversal.traverse(compiler,rValue,new AbstractCfgNodeTraversalCallback(){
    @Override public void visit(    NodeTraversal t,    Node n,    Node parent){
      if (n.isName() && jsScope.isDeclared(n.getString(),true)) {
        def.depends.add(jsScope.getVar(n.getString()));
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Computes all the local variables that rValue reads from and store that in the def's depends set.
 */
private void computeDependence(final Definition def,Node rValue){
  NodeTraversal.traverse(compiler,rValue,new AbstractCfgNodeTraversalCallback(){
    @Override public void visit(    NodeTraversal t,    Node n,    Node parent){
      if (n.isName()) {
        Var dep=jsScope.getVar(n.getString());
        if (dep == null) {
          def.unknownDependencies=true;
        }
 else {
          def.depends.add(dep);
        }
      }
    }
  }
);
}
Program: 28044
Project: 28044
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName() && jsScope.isDeclared(n.getString(),true)) {
    def.depends.add(jsScope.getVar(n.getString()));
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName()) {
    Var dep=jsScope.getVar(n.getString());
    if (dep == null) {
      def.unknownDependencies=true;
    }
 else {
      def.depends.add(dep);
    }
  }
}
Program: 28045
Project: 28045
Buggy source:
public void testInlineAcrossSideEffect1(){
  inline("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testInlineAcrossSideEffect1(){
  noInline("String_Node_Str");
}
Program: 28046
Project: 28046
Buggy source:
public void testInlineExpression9(){
  inline("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testInlineExpression9(){
  inline("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str");
}
Program: 28047
Project: 28047
Buggy source:
public void testInlineExpression8(){
  inline("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testInlineExpression8(){
  inline("String_Node_Str" + "String_Node_Str","String_Node_Str" + "String_Node_Str");
}
Program: 28048
Project: 28048
Buggy source:
public void testCanInlineAcrossNoSideEffect(){
  inline("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testCanInlineAcrossNoSideEffect(){
  noInline("String_Node_Str");
}
Program: 28050
Project: 28050
Buggy source:
void setPrototypeBasedOn(ObjectType baseType,Node propertyNode){
  if (baseType.hasReferenceName() || isNativeObjectType() || baseType.isFunctionPrototypeType()|| !(baseType instanceof PrototypeObjectType)) {
    baseType=new PrototypeObjectType(registry,this.getReferenceName() + "String_Node_Str",baseType);
  }
  setPrototype((PrototypeObjectType)baseType,propertyNode);
}

Fixed version (ground truth):
void setPrototypeBasedOn(ObjectType baseType,Node propertyNode){
  if (baseType.hasReferenceName() || isNativeObjectType() || baseType.isFunctionPrototypeType()) {
    baseType=new PrototypeObjectType(registry,this.getReferenceName() + "String_Node_Str",baseType);
  }
  setPrototype(baseType,propertyNode);
}
Program: 28051
Project: 28051
Buggy source:
@Override public void clearCachedValues(){
  super.clearCachedValues();
  if (subTypes != null) {
    for (    FunctionType subType : subTypes) {
      subType.clearCachedValues();
    }
  }
  if (!isNativeObjectType()) {
    if (hasInstanceType()) {
      getInstanceType().clearCachedValues();
    }
    if (prototypeSlot != null) {
      ((PrototypeObjectType)prototypeSlot.getType()).clearCachedValues();
    }
  }
}

Fixed version (ground truth):
@Override public void clearCachedValues(){
  super.clearCachedValues();
  if (subTypes != null) {
    for (    FunctionType subType : subTypes) {
      subType.clearCachedValues();
    }
  }
  if (!isNativeObjectType()) {
    if (hasInstanceType()) {
      getInstanceType().clearCachedValues();
    }
    if (prototypeSlot != null) {
      ((ObjectType)prototypeSlot.getType()).clearCachedValues();
    }
  }
}
Program: 28052
Project: 28052
Buggy source:
/** 
 * Gets the   {@code prototype} property of this function type. This isequivalent to  {@code (ObjectType) getPropertyType("prototype")}.
 */
public ObjectType getPrototype(){
  if (prototypeSlot == null) {
    setPrototype(new PrototypeObjectType(registry,this.getReferenceName() + "String_Node_Str",registry.getNativeObjectType(OBJECT_TYPE),isNativeObjectType()),null);
  }
  return (ObjectType)prototypeSlot.getType();
}

Fixed version (ground truth):
/** 
 * Gets the   {@code prototype} property of this function type. This isequivalent to  {@code (ObjectType) getPropertyType("prototype")}.
 */
public ObjectType getPrototype(){
  if (prototypeSlot == null) {
    String refName=getReferenceName();
    if (refName == null) {
      setPrototype(registry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE),null);
    }
 else {
      setPrototype(new PrototypeObjectType(registry,this.getReferenceName() + "String_Node_Str",registry.getNativeObjectType(OBJECT_TYPE),isNativeObjectType()),null);
    }
  }
  return (ObjectType)prototypeSlot.getType();
}
Program: 28053
Project: 28053
Buggy source:
/** 
 * Sets the prototype.
 * @param prototype the prototype. If this value is {@code null} it willsilently be discarded.
 */
boolean setPrototype(PrototypeObjectType prototype,Node propertyNode){
  if (prototype == null) {
    return false;
  }
  if (isConstructor() && prototype == getInstanceType()) {
    return false;
  }
  PrototypeObjectType oldPrototype=prototypeSlot == null ? null : (PrototypeObjectType)prototypeSlot.getType();
  boolean replacedPrototype=oldPrototype != null;
  this.prototypeSlot=new Property("String_Node_Str",prototype,true,propertyNode == null ? source : propertyNode);
  prototype.setOwnerFunction(this);
  if (oldPrototype != null) {
    oldPrototype.setOwnerFunction(null);
  }
  if (isConstructor() || isInterface()) {
    FunctionType superClass=getSuperClassConstructor();
    if (superClass != null) {
      superClass.addSubType(this);
    }
    if (isInterface()) {
      for (      ObjectType interfaceType : getExtendedInterfaces()) {
        if (interfaceType.getConstructor() != null) {
          interfaceType.getConstructor().addSubType(this);
        }
      }
    }
  }
  if (replacedPrototype) {
    clearCachedValues();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Sets the prototype.
 * @param prototype the prototype. If this value is {@code null} it willsilently be discarded.
 */
boolean setPrototype(ObjectType prototype,Node propertyNode){
  if (prototype == null) {
    return false;
  }
  if (isConstructor() && prototype == getInstanceType()) {
    return false;
  }
  ObjectType oldPrototype=prototypeSlot == null ? null : (ObjectType)prototypeSlot.getType();
  boolean replacedPrototype=oldPrototype != null;
  this.prototypeSlot=new Property("String_Node_Str",prototype,true,propertyNode == null ? source : propertyNode);
  prototype.setOwnerFunction(this);
  if (oldPrototype != null) {
    oldPrototype.setOwnerFunction(null);
  }
  if (isConstructor() || isInterface()) {
    FunctionType superClass=getSuperClassConstructor();
    if (superClass != null) {
      superClass.addSubType(this);
    }
    if (isInterface()) {
      for (      ObjectType interfaceType : getExtendedInterfaces()) {
        if (interfaceType.getConstructor() != null) {
          interfaceType.getConstructor().addSubType(this);
        }
      }
    }
  }
  if (replacedPrototype) {
    clearCachedValues();
  }
  return true;
}
Program: 28054
Project: 28054
Buggy source:
/** 
 * Tests that defining a property of a function's   {@code prototype} adds theproperty to it instance type.
 */
public void testFunctionPrototypeAndImplicitPrototype1(){
  FunctionType constructor=registry.createConstructorType(null,null,null,null);
  ObjectType instance=constructor.getInstanceType();
  ObjectType prototype=(ObjectType)constructor.getPropertyType("String_Node_Str");
  prototype.defineDeclaredProperty("String_Node_Str",DATE_TYPE,null);
  assertEquals(NATIVE_PROPERTIES_COUNT + 1,instance.getPropertiesCount());
}

Fixed version (ground truth):
/** 
 * Tests that defining a property of a function's   {@code prototype} adds theproperty to it instance type.
 */
public void testFunctionPrototypeAndImplicitPrototype1(){
  FunctionType constructor=registry.createConstructorType("String_Node_Str",null,null,null);
  ObjectType instance=constructor.getInstanceType();
  ObjectType prototype=(ObjectType)constructor.getPropertyType("String_Node_Str");
  prototype.defineDeclaredProperty("String_Node_Str",DATE_TYPE,null);
  assertEquals(NATIVE_PROPERTIES_COUNT + 1,instance.getPropertiesCount());
}
Program: 28055
Project: 28055
Buggy source:
@Override public void matchConstraint(ObjectType constraintObj){
  if (constraintObj.isRecordType()) {
    for (    String prop : constraintObj.getOwnPropertyNames()) {
      JSType propType=constraintObj.getPropertyType(prop);
      if (!isPropertyTypeDeclared(prop)) {
        JSType typeToInfer=propType;
        if (!hasProperty(prop)) {
          typeToInfer=getNativeType(JSTypeNative.VOID_TYPE).getLeastSupertype(propType);
        }
        defineInferredProperty(prop,typeToInfer,null);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void matchConstraint(ObjectType constraintObj){
  if (hasReferenceName()) {
    return;
  }
  if (constraintObj.isRecordType()) {
    for (    String prop : constraintObj.getOwnPropertyNames()) {
      JSType propType=constraintObj.getPropertyType(prop);
      if (!isPropertyTypeDeclared(prop)) {
        JSType typeToInfer=propType;
        if (!hasProperty(prop)) {
          typeToInfer=getNativeType(JSTypeNative.VOID_TYPE).getLeastSupertype(propType);
        }
        defineInferredProperty(prop,typeToInfer,null);
      }
    }
  }
}
Program: 28056
Project: 28056
Buggy source:
@Override void endFile(){
  super.endFile();
  if (!preferLineBreakAtEndOfFile) {
    return;
  }
  if (lineLength > lineLengthThreshold / 2) {
    append("String_Node_Str");
    startNewLine();
  }
 else   if (prevCutPosition > 0) {
    for (int i=prevCutPosition; i < code.length() - 1; i++) {
      code.setCharAt(i,code.charAt(i + 1));
    }
    code.setLength(code.length() - 1);
    lineStartPosition=prevLineStartPosition;
    lineLength=code.length() - lineStartPosition;
    reportLineCut(lineIndex,prevCutPosition,false);
    lineIndex--;
    prevCutPosition=0;
    prevLineStartPosition=0;
    append("String_Node_Str");
    startNewLine();
  }
 else {
  }
}

Fixed version (ground truth):
@Override void endFile(){
  super.endFile();
  if (!preferLineBreakAtEndOfFile) {
    return;
  }
  if (lineLength > lineLengthThreshold / 2) {
    append("String_Node_Str");
    startNewLine();
  }
 else   if (prevCutPosition > 0) {
    code.setCharAt(prevCutPosition,' ');
    lineStartPosition=prevLineStartPosition;
    lineLength=code.length() - lineStartPosition;
    reportLineCut(lineIndex,prevCutPosition + 1,false);
    lineIndex--;
    prevCutPosition=0;
    prevLineStartPosition=0;
    append("String_Node_Str");
    startNewLine();
  }
 else {
  }
}
Program: 28057
Project: 28057
Buggy source:
public void testPreferLineBreakAtEndOfFile(){
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testPreferLineBreakAtEndOfFile(){
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
  assertLineBreakAtEndOfFile("String_Node_Str","String_Node_Str","String_Node_Str");
}