nus-yam/ex-repair huggingface dataset:
Program: 27795
Project: 27795
Buggy source:
/** 
 * Determines whether the given value is eligible to be moved across modules.
 */
private boolean canMoveValue(Node n){
  if (n == null || NodeUtil.isLiteralValue(n,true) || n.isFunction()) {
    return true;
  }
 else   if (n.isCall()) {
    Node functionName=n.getFirstChild();
    return functionName.isName() && (functionName.getString().equals(CrossModuleMethodMotion.STUB_METHOD_NAME) || functionName.getString().equals(CrossModuleMethodMotion.UNSTUB_METHOD_NAME));
  }
 else   if (n.isArrayLit() || n.isObjectLit()) {
    boolean isObjectLit=n.isObjectLit();
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!canMoveValue(isObjectLit ? child.getFirstChild() : child)) {
        return false;
      }
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Determines whether the given value is eligible to be moved across modules.
 */
private boolean canMoveValue(ReferenceCollectingCallback collector,Scope scope,Node n){
  if (n == null || NodeUtil.isLiteralValue(n,true) || n.isFunction()) {
    return true;
  }
 else   if (n.isCall()) {
    Node functionName=n.getFirstChild();
    return functionName.isName() && (functionName.getString().equals(CrossModuleMethodMotion.STUB_METHOD_NAME) || functionName.getString().equals(CrossModuleMethodMotion.UNSTUB_METHOD_NAME));
  }
 else   if (n.isArrayLit() || n.isObjectLit()) {
    boolean isObjectLit=n.isObjectLit();
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!canMoveValue(collector,scope,isObjectLit ? child.getFirstChild() : child)) {
        return false;
      }
    }
    return true;
  }
 else   if (n.isName()) {
    Var v=scope.getVar(n.getString());
    if (v != null && v.isGlobal()) {
      ReferenceCollection refCollection=collector.getReferences(v);
      if (refCollection != null && refCollection.isWellDefined() && refCollection.isAssignedOnceInLifetime()) {
        return true;
      }
    }
  }
  return false;
}
Program: 27796
Project: 27796
Buggy source:
/** 
 * FieldName := NameExpression | StringLiteral | NumberLiteral | ReservedIdentifier
 */
private Node parseFieldName(JsDocToken token){
switch (token) {
case STRING:
    String string=stream.getString();
  return newStringNode(string);
default :
return null;
}
}

Fixed version (ground truth):
/** 
 * FieldName := NameExpression | StringLiteral | NumberLiteral | ReservedIdentifier
 */
private Node parseFieldName(JsDocToken token){
switch (token) {
case STRING:
    String s=stream.getString();
  Node n=Node.newString(Token.STRING_KEY,s,stream.getLineno(),stream.getCharno()).clonePropsFrom(templateNode);
n.setLength(s.length());
return n;
default :
return null;
}
}
Program: 27797
Project: 27797
Buggy source:
private Node getBody(){
  if (root.isFunction()) {
    return NodeUtil.getFunctionBody(root);
  }
 else {
    return root;
  }
}

Fixed version (ground truth):
private Node getBody(){
  Preconditions.checkState(root.isFunction());
  return NodeUtil.getFunctionBody(root);
}
Program: 27804
Project: 27804
Buggy source:
/** 
 * Inline a function into the call site.
 */
private void inlineFunction(NodeTraversal t,Node callNode,FunctionState fs,InliningMode mode){
  Function fn=fs.getFn();
  String fnName=fn.getName();
  Node fnNode=fs.getSafeFnNode();
  t.getCompiler().reportChangeToEnclosingScope(callNode);
  injector.inline(callNode,fnName,fnNode,mode);
  t.getCompiler().addToDebugLog("String_Node_Str" + fn.getName());
}

Fixed version (ground truth):
/** 
 * Inline a function into the call site.
 */
private void inlineFunction(NodeTraversal t,Node callNode,FunctionState fs,InliningMode mode){
  Function fn=fs.getFn();
  String fnName=fn.getName();
  Node fnNode=fs.getSafeFnNode();
  Node newExpr=injector.inline(callNode,fnName,fnNode,mode);
  if (!newExpr.isEquivalentTo(callNode)) {
    t.getCompiler().reportChangeToEnclosingScope(newExpr);
  }
  t.getCompiler().addToDebugLog("String_Node_Str" + fn.getName());
}
Program: 27805
Project: 27805
Buggy source:
/** 
 * Creates a dotted namespace assignment expression (e.g. <code>foo.bar = {};</code>).
 */
private Node makeAssignmentExprNode(){
  Node decl=IR.exprResult(IR.assign(NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(),namespace,firstNode,namespace),createNamespaceLiteral()));
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  if (candidateDefinition == null) {
    decl.getFirstChild().setJSDocInfo(createConstantJsDoc());
  }
  Preconditions.checkState(isNamespacePlaceholder(decl));
  setSourceInfo(decl);
  return decl;
}

Fixed version (ground truth):
/** 
 * Creates a dotted namespace assignment expression (e.g. <code>foo.bar = {};</code>).
 */
private Node makeAssignmentExprNode(){
  Node decl=IR.exprResult(IR.assign(NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(),namespace,firstNode,namespace),createNamespaceLiteral()));
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  if (candidateDefinition == null) {
    decl.getFirstChild().setJSDocInfo(NodeUtil.createConstantJsDoc());
  }
  Preconditions.checkState(isNamespacePlaceholder(decl));
  setSourceInfo(decl);
  return decl;
}
Program: 27806
Project: 27806
Buggy source:
/** 
 * Creates a simple namespace variable declaration (e.g. <code>var foo = {};</code>).
 */
private Node makeVarDeclNode(){
  Node name=IR.name(namespace);
  name.addChildToFront(createNamespaceLiteral());
  Node decl=IR.var(name);
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  if (compiler.getCodingConvention().isConstant(namespace)) {
    name.putBooleanProp(Node.IS_CONSTANT_NAME,true);
  }
  if (candidateDefinition == null) {
    name.setJSDocInfo(createConstantJsDoc());
  }
  Preconditions.checkState(isNamespacePlaceholder(decl));
  setSourceInfo(decl);
  return decl;
}

Fixed version (ground truth):
/** 
 * Creates a simple namespace variable declaration (e.g. <code>var foo = {};</code>).
 */
private Node makeVarDeclNode(){
  Node name=IR.name(namespace);
  name.addChildToFront(createNamespaceLiteral());
  Node decl=IR.var(name);
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  if (compiler.getCodingConvention().isConstant(namespace)) {
    name.putBooleanProp(Node.IS_CONSTANT_NAME,true);
  }
  if (candidateDefinition == null) {
    name.setJSDocInfo(NodeUtil.createConstantJsDoc());
  }
  Preconditions.checkState(isNamespacePlaceholder(decl));
  setSourceInfo(decl);
  return decl;
}
Program: 27807
Project: 27807
Buggy source:
/** 
 * Emit goog.provide and add suffix to all global vars to avoid conflicts with other modules.
 */
private void visitScript(NodeTraversal t,Node script){
  Preconditions.checkArgument(scriptNodeCount == 1,"String_Node_Str" + "String_Node_Str");
  String moduleName=guessCJSModuleName(script.getSourceFileName());
  script.addChildToFront(IR.var(IR.name(moduleName),IR.objectlit()).copyInformationFromForTree(script));
  if (reportDependencies) {
    CompilerInput ci=t.getInput();
    ci.addProvide(moduleName);
    JSModule m=new JSModule(moduleName);
    m.addAndOverrideModule(ci);
    module=m;
  }
  script.addChildToFront(IR.exprResult(IR.call(IR.getprop(IR.name("String_Node_Str"),IR.string("String_Node_Str")),IR.string(moduleName))).copyInformationFromForTree(script));
  emitOptionalModuleExportsOverride(script,moduleName);
  NodeTraversal.traverse(compiler,script,new SuffixVarsCallback(moduleName));
  compiler.reportCodeChange();
}

Fixed version (ground truth):
/** 
 * Emit goog.provide and add suffix to all global vars to avoid conflicts with other modules.
 */
private void visitScript(NodeTraversal t,Node script){
  Preconditions.checkArgument(scriptNodeCount == 1,"String_Node_Str" + "String_Node_Str");
  String moduleName=guessCJSModuleName(script.getSourceFileName());
  NodeTraversal.traverse(compiler,script,new SuffixVarsCallback(moduleName));
  processExports(script,moduleName);
  moduleExportRefs.clear();
  exportRefs.clear();
  if (reportDependencies) {
    CompilerInput ci=t.getInput();
    ci.addProvide(moduleName);
    JSModule m=new JSModule(moduleName);
    m.addAndOverrideModule(ci);
    module=m;
  }
  script.addChildToFront(IR.exprResult(IR.call(IR.getprop(IR.name("String_Node_Str"),IR.string("String_Node_Str")),IR.string(moduleName))).copyInformationFromForTree(script));
  compiler.reportCodeChange();
}
Program: 27808
Project: 27808
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName()) {
    String name=n.getString();
    if (suffix.equals(name)) {
      return;
    }
    if (EXPORTS.equals(name)) {
      n.setString(suffix);
      n.putProp(Node.ORIGINALNAME_PROP,EXPORTS);
    }
 else {
      Scope.Var var=t.getScope().getVar(name);
      if (var != null && var.isGlobal()) {
        n.setString(name + "String_Node_Str" + suffix);
        n.putProp(Node.ORIGINALNAME_PROP,name);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.isName()) {
    String name=n.getString();
    if (suffix.equals(name)) {
      return;
    }
    if (EXPORTS.equals(name)) {
      return;
    }
    Scope.Var var=t.getScope().getVar(name);
    if (var != null && var.isGlobal()) {
      n.setString(name + "String_Node_Str" + suffix);
      n.putProp(Node.ORIGINALNAME_PROP,name);
    }
  }
}
Program: 27809
Project: 27809
Buggy source:
/** 
 * When define is called with an object literal, assign it to exports and we're done.
 */
private void handleDefineObjectLiteral(Node parent,Node onlyExport,Node script){
  onlyExport.getParent().removeChild(onlyExport);
  script.replaceChild(parent,IR.exprResult(IR.assign(IR.name("String_Node_Str"),onlyExport)).copyInformationFromForTree(onlyExport));
  compiler.reportCodeChange();
}

Fixed version (ground truth):
/** 
 * When define is called with an object literal, assign it to module.exports and we're done.
 */
private void handleDefineObjectLiteral(Node parent,Node onlyExport,Node script){
  onlyExport.getParent().removeChild(onlyExport);
  script.replaceChild(parent,IR.exprResult(IR.assign(NodeUtil.newQualifiedNameNode(compiler.getCodingConvention(),"String_Node_Str"),onlyExport)).copyInformationFromForTree(onlyExport));
  compiler.reportCodeChange();
}
Program: 27813
Project: 27813
Buggy source:
private Logger getLogger(){
  if (logger == null) {
    logger=Logger.getLogger(Driver.class.getName());
    logger.setLevel(level.getLevel());
  }
  return logger;
}

Fixed version (ground truth):
private Logger getLogger(){
  if (logger == null) {
    logger=Logger.getLogger(Driver.class.getName());
    logger.setLevel(level.getLevel());
    for (    Handler handler : logger.getHandlers()) {
      handler.setLevel(Level.ALL);
    }
  }
  return logger;
}
Program: 27814
Project: 27814
Buggy source:
private void run(){
  if (seed != -1) {
    numberOfRuns=1;
  }
  for (int i=0; forever() || i < numberOfRuns; i++) {
    getLogger().info("String_Node_Str" + i + "String_Node_Str"+ numberOfRuns+ "String_Node_Str");
    Node script=fuzz();
    if (script == null) {
      if (forever()) {
        break;
      }
    }
    String code1=ScriptFuzzer.getPrettyCode(script);
    StringBuffer sb=new StringBuffer("String_Node_Str").append(seed);
    sb.append("String_Node_Str").append(code1);
    String debugInfo=sb.toString();
    try {
      Result result=compile(script);
      if (result.success && result.warnings.length == 0) {
        getLogger().info("String_Node_Str");
        getLogger().info(debugInfo);
      }
 else {
        getLogger().warning("String_Node_Str");
        getLogger().info(debugInfo);
      }
    }
 catch (    Exception e) {
      getLogger().log(Level.SEVERE,"String_Node_Str",e);
      getLogger().warning(debugInfo);
      if (forever()) {
        break;
      }
    }
    String code2=ScriptFuzzer.getPrettyCode(script);
    getLogger().info("String_Node_Str" + code2);
    if (execute) {
      if (!executeJS(code1,code2) && forever()) {
        break;
      }
    }
  }
}

Fixed version (ground truth):
private void run(){
  if (seed != -1) {
    numberOfRuns=1;
  }
  for (int i=0; forever() || i < numberOfRuns; i++) {
    getLogger().info("String_Node_Str" + i + "String_Node_Str"+ numberOfRuns+ "String_Node_Str");
    Node script=fuzz();
    if (script == null) {
      if (forever()) {
        break;
      }
    }
    String code1=ScriptFuzzer.getPrettyCode(script);
    StringBuffer sb=new StringBuffer("String_Node_Str").append(seed);
    sb.append("String_Node_Str").append(code1);
    String debugInfo=sb.toString();
    try {
      Result result=compile(script);
      if (result.success) {
        if (result.warnings.length == 0) {
          getLogger().info(debugInfo);
        }
 else {
          getLogger().warning(debugInfo);
        }
      }
 else {
        getLogger().severe(debugInfo);
        if (forever()) {
          break;
        }
      }
    }
 catch (    Exception e) {
      getLogger().log(Level.SEVERE,"String_Node_Str",e);
      getLogger().severe(debugInfo);
      if (forever()) {
        break;
      }
    }
    String code2=ScriptFuzzer.getPrettyCode(script);
    getLogger().info("String_Node_Str" + code2);
    if (execute) {
      if (!executeJS(code1,code2) && forever()) {
        break;
      }
    }
  }
}
Program: 27815
Project: 27815
Buggy source:
private JSONObject getConfig(){
  File file=new File(configFileName);
  try {
    return new JSONObject(Files.toString(file,StandardCharsets.UTF_8));
  }
 catch (  JSONException|IOException e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
private JSONObject getConfig(){
  if (config == null) {
    File file=new File(configFileName);
    try {
      config=new JSONObject(Files.toString(file,StandardCharsets.UTF_8));
    }
 catch (    JSONException|IOException e) {
      e.printStackTrace();
    }
  }
  return config;
}
Program: 27816
Project: 27816
Buggy source:
public static boolean isSame(String error1,String error2){
  if (error1 == null && error2 == null) {
    return true;
  }
 else   if (error1 == null || error2 == null) {
    return false;
  }
 else {
    if (error1.equals(error2)) {
      return true;
    }
    String lineSeparator=System.getProperty("String_Node_Str");
    String[] lines1=error1.trim().split(lineSeparator);
    String[] lines2=error2.trim().split(lineSeparator);
    if (lines1.length == lines2.length && lines1[1].trim().startsWith("String_Node_Str") && lines2[1].trim().startsWith("String_Node_Str")) {
      return true;
    }
    if (error1.contains("String_Node_Str") && error2.contains("String_Node_Str")) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean isSame(String error1,String error2){
  if (error1 == null && error2 == null) {
    return true;
  }
 else   if (error1 == null || error2 == null) {
    return false;
  }
 else {
    if (error1.equals(error2)) {
      return true;
    }
    String lineSeparator=System.getProperty("String_Node_Str");
    String[] lines1=error1.trim().split(lineSeparator);
    String[] lines2=error2.trim().split(lineSeparator);
    if (lines1.length == lines2.length && lines1[1].trim().contains("String_Node_Str") && lines2[1].trim().contains("String_Node_Str")) {
      return true;
    }
    if (error1.contains("String_Node_Str") && error2.contains("String_Node_Str")) {
      return true;
    }
    if (error1.contains("String_Node_Str") && error2.contains("String_Node_Str")) {
      return true;
    }
  }
  return false;
}
Program: 27817
Project: 27817
Buggy source:
private boolean forever(){
  return numberOfRuns < 1;
}

Fixed version (ground truth):
private boolean forever(){
  return numberOfRuns == -1;
}
Program: 27818
Project: 27818
Buggy source:
@Override protected Node generate(int budget){
  String name=null;
  if (scopeManager.hasNonLocals() && random.nextDouble() < config.optJSONObject("String_Node_Str").optDouble("String_Node_Str")) {
    name=scopeManager.getRandomSymbol(true).name;
  }
  if (name == null) {
    name="String_Node_Str" + snGenerator.getNextNumber();
  }
  scopeManager.addSymbol(new Symbol(name));
  return Node.newString(Token.NAME,name);
}

Fixed version (ground truth):
@Override protected Node generate(int budget){
  String name=null;
  if (scopeManager.hasNonLocals() && random.nextDouble() < config.optJSONObject("String_Node_Str").optDouble("String_Node_Str")) {
    Symbol symbol=scopeManager.getRandomSymbol(true);
    if (symbol != null) {
      name=symbol.name;
    }
  }
  if (name == null) {
    name="String_Node_Str" + snGenerator.getNextNumber();
  }
  scopeManager.addSymbol(new Symbol(name));
  return Node.newString(Token.NAME,name);
}
Program: 27819
Project: 27819
Buggy source:
public ScopeManager(Random random){
  this.random=random;
  Scope globalScope=new Scope();
  globalScope.symbols=Lists.newArrayList(new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.OBJECT),new Symbol("String_Node_Str",Type.FUNCTION));
  numSym=globalScope.symbols.size();
  scopeStack.push(globalScope);
}

Fixed version (ground truth):
public ScopeManager(Random random){
  this.random=random;
  Scope globalScope=new Scope();
  globalScope.symbols=Lists.newArrayList(new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.FUNCTION),new Symbol("String_Node_Str",Type.OBJECT),new Symbol("String_Node_Str",Type.OBJECT),new Symbol("String_Node_Str",Type.FUNCTION));
  numSym=globalScope.symbols.size();
  scopeStack.push(globalScope);
}
Program: 27820
Project: 27820
Buggy source:
public Symbol getRandomSymbol(Type type,boolean excludeLocal){
  if (excludeLocal) {
    Preconditions.checkArgument(getNumScopes() > 1);
  }
 else {
    Preconditions.checkArgument(getNumScopes() > 0);
  }
  List<Symbol> symbols=new ArrayList<>();
  ArrayList<Scope> scopes=new ArrayList<Scope>(scopeStack);
  int i;
  if (excludeLocal) {
    i=1;
  }
 else {
    i=0;
  }
  while (i < scopes.size()) {
    Scope scope=scopes.get(i);
    for (    Symbol s : scope.symbols) {
      if (type == null || s.type == type) {
        symbols.add(s);
      }
    }
    i++;
  }
  int numCandidates=symbols.size();
  if (numCandidates == 0) {
    return null;
  }
  Symbol sym=symbols.get(random.nextInt(numCandidates));
  if (excludeLocal && localSymbols().indexOf(sym) != -1) {
    return null;
  }
 else {
    return sym;
  }
}

Fixed version (ground truth):
public Symbol getRandomSymbol(Type type,boolean excludeLocal){
  if (excludeLocal) {
    Preconditions.checkArgument(getNumScopes() > 1);
  }
 else {
    Preconditions.checkArgument(getNumScopes() > 0);
  }
  List<Symbol> symbols=new ArrayList<>();
  ArrayList<Scope> scopes=new ArrayList<Scope>(scopeStack);
  int i;
  if (excludeLocal) {
    i=1;
  }
 else {
    i=0;
  }
  while (i < scopes.size()) {
    Scope scope=scopes.get(i);
    for (    Symbol s : scope.symbols) {
      if (type == null || s.type == type) {
        symbols.add(s);
      }
    }
    i++;
  }
  int numCandidates=symbols.size();
  if (numCandidates == 0) {
    return null;
  }
  Symbol sym=symbols.get(random.nextInt(numCandidates));
  if (excludeLocal && searchLocalFor(sym.name) != null) {
    return null;
  }
 else {
    return sym;
  }
}
Program: 27821
Project: 27821
Buggy source:
public void removeSymbol(String symbolName){
  Symbol symbol=null;
  for (  Symbol s : localSymbols()) {
    if (s.name.equals(symbolName)) {
      symbol=s;
      break;
    }
  }
  if (symbol != null && localSymbols().remove(symbol)) {
    numSym--;
  }
}

Fixed version (ground truth):
public void removeSymbol(String symbolName){
  Symbol symbol=searchLocalFor(symbolName);
  if (symbol != null && localSymbols().remove(symbol)) {
    numSym--;
  }
}
Program: 27822
Project: 27822
Buggy source:
@Override protected CompilerOptions createOptions(){
  CompilerOptions options=new CompilerOptions();
  if (flags.processJqueryPrimitives) {
    options.setCodingConvention(new JqueryCodingConvention());
  }
 else {
    options.setCodingConvention(new ClosureCodingConvention());
  }
  options.setExtraAnnotationNames(flags.extraAnnotationName);
  CompilationLevel level=flags.compilationLevel;
  level.setOptionsForCompilationLevel(options);
  if (flags.debug) {
    level.setDebugOptionsForCompilationLevel(options);
  }
  if (flags.useTypesForOptimization) {
    level.setTypeBasedOptimizationOptions(options);
  }
  if (flags.generateExports) {
    options.setGenerateExports(flags.generateExports);
  }
  WarningLevel wLevel=flags.warningLevel;
  wLevel.setOptionsForWarningLevel(options);
  for (  FormattingOption formattingOption : flags.formatting) {
    formattingOption.applyToOptions(options);
  }
  options.closurePass=flags.processClosurePrimitives;
  options.jqueryPass=CompilationLevel.ADVANCED_OPTIMIZATIONS == level && flags.processJqueryPrimitives;
  options.angularPass=flags.angularPass;
  if (!flags.translationsFile.isEmpty()) {
    try {
      options.messageBundle=new XtbMessageBundle(new FileInputStream(flags.translationsFile),flags.translationsProject);
    }
 catch (    IOException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
 else   if (CompilationLevel.ADVANCED_OPTIMIZATIONS == level) {
    options.messageBundle=new EmptyMessageBundle();
  }
  return options;
}

Fixed version (ground truth):
@Override protected CompilerOptions createOptions(){
  CompilerOptions options=new CompilerOptions();
  if (flags.processJqueryPrimitives) {
    options.setCodingConvention(new JqueryCodingConvention());
  }
 else {
    options.setCodingConvention(new ClosureCodingConvention());
  }
  options.setExtraAnnotationNames(flags.extraAnnotationName);
  CompilationLevel level=flags.compilationLevel;
  level.setOptionsForCompilationLevel(options);
  if (flags.debug) {
    level.setDebugOptionsForCompilationLevel(options);
  }
  if (flags.useTypesForOptimization) {
    level.setTypeBasedOptimizationOptions(options);
  }
  if (flags.generateExports) {
    options.setGenerateExports(flags.generateExports);
  }
  WarningLevel wLevel=flags.warningLevel;
  wLevel.setOptionsForWarningLevel(options);
  for (  FormattingOption formattingOption : flags.formatting) {
    formattingOption.applyToOptions(options);
  }
  options.closurePass=flags.processClosurePrimitives;
  options.jqueryPass=CompilationLevel.ADVANCED_OPTIMIZATIONS == level && flags.processJqueryPrimitives;
  options.angularPass=flags.angularPass;
  if (!flags.translationsFile.isEmpty()) {
    try {
      options.messageBundle=new XtbMessageBundle(new FileInputStream(flags.translationsFile),flags.translationsProject);
    }
 catch (    IOException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
 else   if (CompilationLevel.ADVANCED_OPTIMIZATIONS == level) {
    options.messageBundle=new EmptyMessageBundle();
    options.setWarningLevel(JsMessageVisitor.MSG_CONVENTIONS,CheckLevel.OFF);
  }
  return options;
}
Program: 27823
Project: 27823
Buggy source:
/** 
 * Updates the scope according to the result of a type change, like an assignment or a type cast.
 */
private void updateScopeForTypeChange(FlowScope scope,Node left,JSType leftType,JSType resultType){
  Preconditions.checkNotNull(resultType);
switch (left.getType()) {
case Token.NAME:
    String varName=left.getString();
  Var var=syntacticScope.getVar(varName);
boolean isVarDeclaration=left.hasChildren();
if (!isVarDeclaration || var == null || var.isTypeInferred()) {
redeclareSimpleVar(scope,left,resultType);
}
left.setJSType(isVarDeclaration || leftType == null ? resultType : null);
if (var != null && var.isTypeInferred()) {
JSType oldType=var.getType();
var.setType(oldType == null ? resultType : oldType.getLeastSupertype(resultType));
}
break;
case Token.GETPROP:
String qualifiedName=left.getQualifiedName();
if (qualifiedName != null) {
scope.inferQualifiedSlot(left,qualifiedName,leftType == null ? unknownType : leftType,resultType);
}
left.setJSType(resultType);
ensurePropertyDefined(left,resultType);
break;
}
}

Fixed version (ground truth):
/** 
 * Updates the scope according to the result of a type change, like an assignment or a type cast.
 */
private void updateScopeForTypeChange(FlowScope scope,Node left,JSType leftType,JSType resultType){
  Preconditions.checkNotNull(resultType);
switch (left.getType()) {
case Token.NAME:
    String varName=left.getString();
  Var var=syntacticScope.getVar(varName);
JSType varType=var == null ? null : var.getType();
boolean isVarDeclaration=left.hasChildren() && varType != null && !var.isTypeInferred();
boolean isVarTypeBetter=isVarDeclaration && !resultType.isNullType() && !resultType.isVoidType();
if (isVarTypeBetter) {
redeclareSimpleVar(scope,left,varType);
}
 else {
redeclareSimpleVar(scope,left,resultType);
}
left.setJSType(resultType);
if (var != null && var.isTypeInferred()) {
JSType oldType=var.getType();
var.setType(oldType == null ? resultType : oldType.getLeastSupertype(resultType));
}
break;
case Token.GETPROP:
String qualifiedName=left.getQualifiedName();
if (qualifiedName != null) {
scope.inferQualifiedSlot(left,qualifiedName,leftType == null ? unknownType : leftType,resultType);
}
left.setJSType(resultType);
ensurePropertyDefined(left,resultType);
break;
}
}
Program: 27825
Project: 27825
Buggy source:
@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;
  }
}

Fixed version (ground truth):
@Override public void exitScope(NodeTraversal t){
  if (t.getScopeDepth() > 2) {
    findNamespaceShadows(t);
  }
  if (t.getScopeDepth() == 2) {
    renameNamespaceShadows(t);
    injectedDecls.clear();
    aliases.clear();
    forbiddenLocals.clear();
    transformation=null;
    hasNamespaceShadows=false;
  }
}
Program: 27826
Project: 27826
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (isCallToScopeMethod(n)) {
    validateScopeCall(t,n,n.getParent());
  }
  if (t.getScopeDepth() < 2) {
    return;
  }
  int type=n.getType();
  Var aliasVar=null;
  if (type == Token.NAME) {
    String name=n.getString();
    Var lexicalVar=t.getScope().getVar(n.getString());
    if (lexicalVar != null && lexicalVar == aliases.get(name)) {
      aliasVar=lexicalVar;
    }
  }
  if (t.getScopeDepth() == 2) {
    if (aliasVar != null && NodeUtil.isLValue(n)) {
      if (aliasVar.getNode() == n) {
        aliasDefinitionsInOrder.add(n);
        return;
      }
 else {
        report(t,n,GOOG_SCOPE_ALIAS_REDEFINED,n.getString());
      }
    }
    if (type == Token.RETURN) {
      report(t,n,GOOG_SCOPE_USES_RETURN);
    }
 else     if (type == Token.THIS) {
      report(t,n,GOOG_SCOPE_REFERENCES_THIS);
    }
 else     if (type == Token.THROW) {
      report(t,n,GOOG_SCOPE_USES_THROW);
    }
  }
  if (t.getScopeDepth() >= 2) {
    if (aliasVar != null) {
      aliasUsages.add(new AliasedNode(aliasVar,n));
    }
    JSDocInfo info=n.getJSDocInfo();
    if (info != null) {
      for (      Node node : info.getTypeNodes()) {
        fixTypeNode(node);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (isCallToScopeMethod(n)) {
    validateScopeCall(t,n,n.getParent());
  }
  if (t.getScopeDepth() < 2) {
    return;
  }
  int type=n.getType();
  Var aliasVar=null;
  if (type == Token.NAME) {
    String name=n.getString();
    Var lexicalVar=t.getScope().getVar(n.getString());
    if (lexicalVar != null && lexicalVar == aliases.get(name)) {
      aliasVar=lexicalVar;
    }
  }
  if (t.getScopeDepth() == 2) {
    if (aliasVar != null && NodeUtil.isLValue(n)) {
      if (aliasVar.getNode() == n) {
        aliasDefinitionsInOrder.add(n);
        return;
      }
 else {
        report(t,n,GOOG_SCOPE_ALIAS_REDEFINED,n.getString());
      }
    }
    if (type == Token.RETURN) {
      report(t,n,GOOG_SCOPE_USES_RETURN);
    }
 else     if (type == Token.THIS) {
      report(t,n,GOOG_SCOPE_REFERENCES_THIS);
    }
 else     if (type == Token.THROW) {
      report(t,n,GOOG_SCOPE_USES_THROW);
    }
  }
  if (t.getScopeDepth() >= 2) {
    if (aliasVar != null) {
      aliasUsages.add(new AliasedNode(aliasVar,n));
    }
    JSDocInfo info=n.getJSDocInfo();
    if (info != null && !injectedDecls.contains(n)) {
      for (      Node node : info.getTypeNodes()) {
        fixTypeNode(node);
      }
    }
  }
}
Program: 27827
Project: 27827
Buggy source:
public static void main(String[] args){
  int numberOfRuns=1;
  if (args.length >= 1) {
    numberOfRuns=Integer.valueOf(args[0]);
  }
  int maxASTSize=10;
  if (args.length >= 2) {
    maxASTSize=Integer.valueOf(args[1]);
  }
  Driver driver=new Driver();
  for (int i=0; i < numberOfRuns; i++) {
    long seed=System.currentTimeMillis();
    Random random=new Random(seed);
    System.out.println("String_Node_Str" + seed);
    Fuzzer fuzzer=new Fuzzer(random);
    Node[] nodes=fuzzer.generateProgram(maxASTSize);
    Node script=driver.getScript(nodes);
    String code=Fuzzer.getPrettyCode(script);
    System.out.println(code.trim());
    Compiler compiler=driver.compile(script);
    Result result=compiler.getResult();
    if (result.success) {
      System.out.println("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  int numberOfRuns=1;
  if (args.length >= 1) {
    numberOfRuns=Integer.valueOf(args[0]);
  }
  int maxASTSize=10;
  if (args.length >= 2) {
    maxASTSize=Integer.valueOf(args[1]);
  }
  Driver driver=new Driver();
  for (int i=0; i < numberOfRuns; i++) {
    long seed=System.currentTimeMillis();
    Random random=new Random(seed);
    System.out.println("String_Node_Str" + seed);
    Fuzzer fuzzer=new Fuzzer(random);
    Node[] nodes=fuzzer.generateProgram(maxASTSize);
    Node script=Fuzzer.buildScript(nodes);
    String code=Fuzzer.getPrettyCode(script);
    System.out.println(code.trim());
    Compiler compiler=driver.compile(script);
    Result result=compiler.getResult();
    if (result.success) {
      System.out.println("String_Node_Str");
    }
  }
}
Program: 27828
Project: 27828
Buggy source:
Node generateExpression(int budget){
  Preconditions.checkArgument(budget >= 1);
  Map<Expression,Double> pmf=Maps.newHashMap();
  for (  Expression expr : Expression.values()) {
    if (expr.minBudget <= budget) {
      if (expr == Expression.FUNCTION_CALL && symbolTable.getSize() == 0 && budget < 4) {
        continue;
      }
 else {
        pmf.put(expr,expr.weight);
      }
    }
  }
  DiscreteDistribution<Expression> dd=new DiscreteDistribution<Expression>(random,pmf);
  Expression expr=dd.nextItem();
switch (expr) {
case LITERAL:
    return generateLiteral(budget);
case FUNCTION_CALL:
  return generateFunctionCall(budget);
case UNARY_EXPR:
return generateUnaryExpression(budget);
case BINARY_EXPR:
return generateBinaryExpression(budget);
case FUNCTION_EXPR:
return generateFunctionExpression(budget);
case TERNARY_EXPR:
return generateTernaryExpression(budget);
}
return null;
}

Fixed version (ground truth):
Node generateExpression(int budget){
  Preconditions.checkArgument(budget >= 1);
  Map<Expression,Double> pmf=Maps.newHashMap();
  for (  Expression expr : Expression.values()) {
    if (expr.minBudget <= budget) {
      if (expr == Expression.FUNCTION_CALL && symbolTable.getSize() == 0 && budget < 4) {
        continue;
      }
 else       if (expr == Expression.IDENTIFIER && symbolTable.getSize() == 0) {
        continue;
      }
 else {
        pmf.put(expr,expr.weight);
      }
    }
  }
  DiscreteDistribution<Expression> dd=new DiscreteDistribution<Expression>(random,pmf);
  Expression expr=dd.nextItem();
switch (expr) {
case THIS:
    return generateThis(budget);
case IDENTIFIER:
  return generateIdentifier(budget,true);
case LITERAL:
return generateLiteral(budget);
case FUNCTION_CALL:
return generateFunctionCall(budget);
case UNARY_EXPR:
return generateUnaryExpression(budget);
case BINARY_EXPR:
return generateBinaryExpression(budget);
case FUNCTION_EXPR:
return generateFunctionExpression(budget);
case TERNARY_EXPR:
return generateTernaryExpression(budget);
}
return null;
}
Program: 27829
Project: 27829
Buggy source:
private Node generateFunction(int budget,boolean anonymous){
  int remainingBudget;
  Node name;
  if (anonymous) {
    Preconditions.checkArgument(budget >= 3);
    name=Node.newString(Token.NAME,"String_Node_Str");
    remainingBudget=budget - 3;
  }
 else {
    Preconditions.checkArgument(budget >= 4);
    name=generateIdentifier(1,false);
    remainingBudget=budget - 4;
  }
  functionNesting++;
  symbolTable.addScope();
  Node paramList=new Node(Token.PARAM_LIST);
  Node body=new Node(Token.BLOCK);
  int numComponents=random.nextInt(remainingBudget + 1);
  if (numComponents > 0) {
    int[] componentBudgets=distribute(remainingBudget + 1,numComponents,1);
    componentBudgets[0]--;
    for (int i=0; i < componentBudgets[0]; i++) {
      paramList.addChildToBack(generateIdentifier(1,false));
    }
    for (int i=1; i < numComponents; i++) {
      body.addChildToBack(generateSourceElement(componentBudgets[i]));
    }
    symbolTable.removeScope();
    functionNesting--;
  }
  Node function=new Node(Token.FUNCTION,name,paramList,body);
  return function;
}

Fixed version (ground truth):
private Node generateFunction(int budget,boolean anonymous){
  int remainingBudget;
  Node name;
  if (anonymous) {
    Preconditions.checkArgument(budget >= 3);
    name=Node.newString(Token.NAME,"String_Node_Str");
    remainingBudget=budget - 3;
  }
 else {
    Preconditions.checkArgument(budget >= 4);
    name=generateIdentifier(1,false);
    remainingBudget=budget - 4;
  }
  functionNesting++;
  symbolTable.addScope();
  Node paramList=new Node(Token.PARAM_LIST);
  Node body=new Node(Token.BLOCK);
  int numComponents=random.nextInt(remainingBudget + 1);
  if (numComponents > 0) {
    int[] componentBudgets=distribute(remainingBudget + 1,numComponents,1);
    componentBudgets[0]--;
    for (int i=0; i < componentBudgets[0]; i++) {
      paramList.addChildToBack(generateIdentifier(1,false));
    }
    for (int i=1; i < numComponents; i++) {
      body.addChildToBack(generateSourceElement(componentBudgets[i]));
    }
  }
  symbolTable.removeScope();
  functionNesting--;
  Node function=new Node(Token.FUNCTION,name,paramList,body);
  return function;
}
Program: 27830
Project: 27830
Buggy source:
Node[] generateProgram(int budget){
  int numElements=random.nextInt(budget) + 1;
  if (numElements > 0) {
    int[] elemBudgets=distribute(budget,numElements,1);
    Node[] elements=new Node[numElements];
    for (int i=0; i < numElements; i++) {
      elements[i]=generateSourceElement(elemBudgets[i]);
    }
    return elements;
  }
 else {
    return new Node[]{generateEmptyStatement(budget)};
  }
}

Fixed version (ground truth):
Node[] generateProgram(int budget){
  int numElements=random.nextInt(budget) / 5 + 1;
  if (numElements > 0) {
    int[] elemBudgets=distribute(budget,numElements,1);
    Node[] elements=new Node[numElements];
    for (int i=0; i < numElements; i++) {
      elements[i]=generateSourceElement(elemBudgets[i]);
    }
    return elements;
  }
 else {
    return new Node[]{generateEmptyStatement(budget)};
  }
}
Program: 27831
Project: 27831
Buggy source:
public void testExpression(){
  Random random=new Random();
  Fuzzer fuzzer=spy(new Fuzzer(random));
  int budget=1;
  fuzzer.generateExpression(budget);
  verify(fuzzer).generateLiteral(budget);
  verify(fuzzer,never()).generateFunctionCall(budget);
  verify(fuzzer,never()).generateUnaryExpression(budget);
  budget=2;
  fuzzer.generateExpression(budget);
  verify(fuzzer,never()).generateBinaryExpression(budget);
  verify(fuzzer,never()).generateFunctionExpression(budget);
  budget=3;
  verify(fuzzer,never()).generateTernaryExpression(budget);
}

Fixed version (ground truth):
public void testExpression(){
  Random random=new Random();
  Fuzzer fuzzer=spy(new Fuzzer(random));
  int budget=1;
  fuzzer.generateExpression(budget);
  verify(fuzzer,never()).generateIdentifier(budget,true);
  verify(fuzzer,never()).generateFunctionCall(budget);
  verify(fuzzer,never()).generateUnaryExpression(budget);
  budget=2;
  fuzzer.generateExpression(budget);
  verify(fuzzer,never()).generateBinaryExpression(budget);
  verify(fuzzer,never()).generateFunctionExpression(budget);
  budget=3;
  verify(fuzzer,never()).generateTernaryExpression(budget);
}
Program: 27833
Project: 27833
Buggy source:
/** 
 * Create a diagnostic group that matches only the given type. 
 */
public static DiagnosticGroup forType(DiagnosticType type){
  if (!singletons.containsKey(type)) {
    singletons.put(type,new DiagnosticGroup(type));
  }
  return singletons.get(type);
}

Fixed version (ground truth):
/** 
 * Create a diagnostic group that matches only the given type. 
 */
public static synchronized DiagnosticGroup forType(DiagnosticType type){
  if (!singletons.containsKey(type)) {
    singletons.put(type,new DiagnosticGroup(type));
  }
  return singletons.get(type);
}
Program: 27835
Project: 27835
Buggy source:
public void testGoogIsArray2() throws Exception {
  testClosureFunction("String_Node_Str",ALL_TYPE,ALL_TYPE,ALL_TYPE);
}

Fixed version (ground truth):
public void testGoogIsArray2() throws Exception {
  testClosureFunction("String_Node_Str",ALL_TYPE,ARRAY_TYPE,ALL_TYPE);
}
Program: 27836
Project: 27836
Buggy source:
private int position2charno(int position){
  int lineIndex=sourceString.lastIndexOf('\n',position);
  if (lineIndex == -1) {
    return position;
  }
 else {
    return position - lineIndex - 1;
  }
}

Fixed version (ground truth):
private int position2charno(int position){
  int newlineIndex=Collections.binarySearch(newlines,position);
  int lineIndex=-1;
  if (newlineIndex >= 0) {
    lineIndex=newlines.get(newlineIndex);
  }
 else   if (newlineIndex <= -2) {
    lineIndex=newlines.get(-newlineIndex - 2);
  }
  if (lineIndex == -1) {
    return position;
  }
 else {
    return position - lineIndex - 1;
  }
}
Program: 27837
Project: 27837
Buggy source:
private IRFactory(String sourceString,StaticSourceFile sourceFile,Config config,ErrorReporter errorReporter){
  this.sourceString=sourceString;
  this.sourceFile=sourceFile;
  this.sourceName=sourceFile == null ? null : sourceFile.getName();
  this.config=config;
  this.errorReporter=errorReporter;
  this.transformDispatcher=new TransformDispatcher();
  this.templateNode=createTemplateNode();
switch (config.languageMode) {
case ECMASCRIPT3:
    reservedKeywords=null;
  break;
case ECMASCRIPT5:
reservedKeywords=ES5_RESERVED_KEYWORDS;
break;
case ECMASCRIPT5_STRICT:
reservedKeywords=ES5_STRICT_RESERVED_KEYWORDS;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
}

Fixed version (ground truth):
private IRFactory(String sourceString,StaticSourceFile sourceFile,Config config,ErrorReporter errorReporter){
  this.sourceString=sourceString;
  this.newlines=Lists.newArrayList();
  this.sourceFile=sourceFile;
  for (int charNo=0; true; charNo++) {
    charNo=sourceString.indexOf('\n',charNo);
    if (charNo == -1)     break;
    newlines.add(Integer.valueOf(charNo));
  }
  this.sourceName=sourceFile == null ? null : sourceFile.getName();
  this.config=config;
  this.errorReporter=errorReporter;
  this.transformDispatcher=new TransformDispatcher();
  this.templateNode=createTemplateNode();
switch (config.languageMode) {
case ECMASCRIPT3:
    reservedKeywords=null;
  break;
case ECMASCRIPT5:
reservedKeywords=ES5_RESERVED_KEYWORDS;
break;
case ECMASCRIPT5_STRICT:
reservedKeywords=ES5_STRICT_RESERVED_KEYWORDS;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
}
Program: 27839
Project: 27839
Buggy source:
public Node getChildBefore(Node child){
  if (child == first) {
    return null;
  }
  Node n=first;
  while (n.next != child) {
    n=n.next;
    if (n == null) {
      throw new RuntimeException("String_Node_Str");
    }
  }
  return n;
}

Fixed version (ground truth):
public Node getChildBefore(Node child){
  if (child == first) {
    return null;
  }
  Node n=first;
  if (n == null) {
    throw new RuntimeException("String_Node_Str");
  }
  while (n.next != child) {
    n=n.next;
    if (n == null) {
      throw new RuntimeException("String_Node_Str");
    }
  }
  return n;
}
Program: 27841
Project: 27841
Buggy source:
/** 
 * Handles a goog.require call.
 */
private void processRequireCall(NodeTraversal t,Node n,Node parent){
  Node left=n.getFirstChild();
  Node arg=left.getNext();
  if (verifyLastArgumentIsString(t,left,arg)) {
    String ns=arg.getString();
    ProvidedName provided=providedNames.get(ns);
    if (provided == null || !provided.isExplicitlyProvided()) {
      unrecognizedRequires.add(new UnrecognizedRequire(n,ns,t.getSourceName()));
    }
 else {
      JSModule providedModule=provided.explicitModule;
      Preconditions.checkNotNull(providedModule);
      JSModule module=t.getModule();
      if (moduleGraph != null && module != providedModule && !moduleGraph.dependsOn(module,providedModule)) {
        compiler.report(t.makeError(n,XMODULE_REQUIRE_ERROR,ns,providedModule.getName(),module.getName()));
      }
    }
    maybeAddToSymbolTable(left);
    maybeAddStringNodeToSymbolTable(arg);
    if (provided != null || requiresLevel.isOn()) {
      parent.detachFromParent();
      compiler.reportCodeChange();
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles a goog.require call.
 */
private void processRequireCall(NodeTraversal t,Node n,Node parent){
  Node left=n.getFirstChild();
  Node arg=left.getNext();
  if (verifyLastArgumentIsString(t,left,arg)) {
    String ns=arg.getString();
    ProvidedName provided=providedNames.get(ns);
    if (provided == null || !provided.isExplicitlyProvided()) {
      unrecognizedRequires.add(new UnrecognizedRequire(n,ns,t.getSourceName()));
    }
 else {
      JSModule providedModule=provided.explicitModule;
      Preconditions.checkNotNull(providedModule);
      JSModule module=t.getModule();
      if (moduleGraph != null && module != providedModule && !moduleGraph.dependsOn(module,providedModule)) {
        compiler.report(t.makeError(n,XMODULE_REQUIRE_ERROR,ns,providedModule.getName(),module.getName()));
      }
    }
    maybeAddToSymbolTable(left);
    maybeAddStringNodeToSymbolTable(arg);
    if (provided != null) {
      parent.detachFromParent();
      compiler.reportCodeChange();
    }
  }
}
Program: 27842
Project: 27842
Buggy source:
/** 
 * Given a FUNCTION node returns array of STRING nodes representing function parameters.
 * @param n the FUNCTION node.
 * @return STRING nodes.
 */
private List<Node> createDependenciesList(Node n){
  Preconditions.checkArgument(n.isFunction());
  Node params=NodeUtil.getFunctionParameters(n);
  if (params != null) {
    return createStringsFromParamList(params);
  }
  return Lists.newArrayList();
}

Fixed version (ground truth):
/** 
 * Given a FUNCTION node returns array of STRING nodes representing function parameters.
 * @param n the FUNCTION node.
 * @return STRING nodes.
 */
private static List<Node> createDependenciesList(Node n){
  Preconditions.checkArgument(n.isFunction());
  Node params=NodeUtil.getFunctionParameters(n);
  if (params != null) {
    return createStringsFromParamList(params);
  }
  return Lists.newArrayList();
}
Program: 27843
Project: 27843
Buggy source:
/** 
 * Given a PARAM_LIST node creates an array of corresponding STRING nodes.
 * @param params PARAM_LIST node.
 * @return array of STRING nodes.
 */
private List<Node> createStringsFromParamList(Node params){
  Node param=params.getFirstChild();
  ArrayList<Node> names=Lists.newArrayList();
  while (param != null && param.isName()) {
    names.add(IR.string(param.getString()).srcref(param));
    param=param.getNext();
  }
  return names;
}

Fixed version (ground truth):
/** 
 * Given a PARAM_LIST node creates an array of corresponding STRING nodes.
 * @param params PARAM_LIST node.
 * @return array of STRING nodes.
 */
private static List<Node> createStringsFromParamList(Node params){
  Node param=params.getFirstChild();
  ArrayList<Node> names=Lists.newArrayList();
  while (param != null && param.isName()) {
    names.add(IR.string(param.getString()).srcref(param));
    param=param.getNext();
  }
  return names;
}
Program: 27844
Project: 27844
Buggy source:
/** 
 * Given a VAR node (variable declaration) returns the node of initial value. <pre>  {@code var x;  // null var y = "value"; // STRING "value" node}var z = x = y = function()  ; // FUNCTION node }</pre>
 * @param n VAR node.
 * @return the assigned intial value, or the rightmost rvalue of an assignmentchain, or null.
 */
private Node getDeclarationRValue(Node n){
  Preconditions.checkNotNull(n);
  Preconditions.checkArgument(n.isVar());
  n=n.getFirstChild().getFirstChild();
  if (n == null) {
    return null;
  }
  while (n.isAssign()) {
    n=n.getLastChild();
  }
  return n;
}

Fixed version (ground truth):
/** 
 * Given a VAR node (variable declaration) returns the node of initial value. <pre>  {@code var x;  // null var y = "value"; // STRING "value" node}var z = x = y = function()  ; // FUNCTION node }</pre>
 * @param n VAR node.
 * @return the assigned intial value, or the rightmost rvalue of an assignmentchain, or null.
 */
private static Node getDeclarationRValue(Node n){
  Preconditions.checkNotNull(n);
  Preconditions.checkArgument(n.isVar());
  n=n.getFirstChild().getFirstChild();
  if (n == null) {
    return null;
  }
  while (n.isAssign()) {
    n=n.getLastChild();
  }
  return n;
}
Program: 27845
Project: 27845
Buggy source:
/** 
 * @param compiler the compiler that owns/creates this.
 * @param tracker an optional performance tracker
 * @param progressRange the progress range for the process function or nullif progress should not be reported.
 */
PhaseOptimizer(AbstractCompiler comp,PerformanceTracker tracker,ProgressRange range){
  this.compiler=comp;
  this.jsRoot=comp.getJsRoot();
  this.tracker=tracker;
  this.passes=Lists.newArrayList();
  this.progressRange=range;
  this.inLoop=false;
  this.crossScopeReporting=false;
  this.timestamp=this.lastChange=START_TIME;
}

Fixed version (ground truth):
/** 
 * @param comp the compiler that owns/creates this.
 * @param tracker an optional performance tracker
 * @param range the progress range for the process function or nullif progress should not be reported.
 */
PhaseOptimizer(AbstractCompiler comp,PerformanceTracker tracker,ProgressRange range){
  this.compiler=comp;
  this.jsRoot=comp.getJsRoot();
  this.tracker=tracker;
  this.passes=Lists.newArrayList();
  this.progressRange=range;
  this.inLoop=false;
  this.crossScopeReporting=false;
  this.timestamp=this.lastChange=START_TIME;
}
Program: 27846
Project: 27846
Buggy source:
private boolean isJSDocString(int c){
switch (c) {
case '@':
case '*':
case ',':
case '>':
case ':':
case '(':
case ')':
case '{':
case '}':
case '[':
case ']':
case '?':
case '!':
case '|':
case '=':
case EOF_CHAR:
case '\n':
    return false;
default :
  return !isJSSpace(c);
}
}

Fixed version (ground truth):
private static boolean isJSDocString(int c){
switch (c) {
case '@':
case '*':
case ',':
case '>':
case ':':
case '(':
case ')':
case '{':
case '}':
case '[':
case ']':
case '?':
case '!':
case '|':
case '=':
case EOF_CHAR:
case '\n':
    return false;
default :
  return !isJSSpace(c);
}
}