nus-yam/ex-repair huggingface dataset:
Program: 18844
Project: 18844
Buggy source:
/** 
 * Process an object literal and all the types on it.
 * @param objLit The OBJECTLIT node.
 * @param objLitType The type of the OBJECTLIT node. This might be a namedtype, because of the lends annotation.
 */
void processObjectLitProperties(NodeTraversal t,Node objLit,ObjectType objLitType){
  for (Node keyNode=objLit.getFirstChild(); keyNode != null; keyNode=keyNode.getNext()) {
    Node value=keyNode.getFirstChild();
    String memberName=NodeUtil.getObjectLitKeyName(keyNode);
    JSDocInfo info=keyNode.getJSDocInfo();
    JSType valueType=getDeclaredPropType(t,info,keyNode,value);
    JSType keyType=NodeUtil.getObjectLitKeyTypeFromValueType(keyNode,valueType);
    if (keyType != null) {
      String qualifiedName=getBestLValueName(keyNode);
      if (qualifiedName != null) {
        defineSlot(keyNode,objLit,qualifiedName,keyType,false);
      }
 else {
        setDeferredType(keyNode,keyType);
      }
      if (objLitType != null) {
        boolean isExtern=t.getInput() != null && t.getInput().isExtern();
        objLitType.defineDeclaredProperty(memberName,keyType,isExtern,keyNode);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Process an object literal and all the types on it.
 * @param objLit The OBJECTLIT node.
 * @param objLitType The type of the OBJECTLIT node. This might be a namedtype, because of the lends annotation.
 */
void processObjectLitProperties(NodeTraversal t,Node objLit,ObjectType objLitType){
  for (Node keyNode=objLit.getFirstChild(); keyNode != null; keyNode=keyNode.getNext()) {
    Node value=keyNode.getFirstChild();
    String memberName=NodeUtil.getObjectLitKeyName(keyNode);
    JSDocInfo info=keyNode.getJSDocInfo();
    JSType valueType=getDeclaredType(t.getSourceName(),info,keyNode,value);
    JSType keyType=NodeUtil.getObjectLitKeyTypeFromValueType(keyNode,valueType);
    if (keyType != null) {
      String qualifiedName=getBestLValueName(keyNode);
      if (qualifiedName != null) {
        defineSlot(keyNode,objLit,qualifiedName,keyType,false);
      }
 else {
        setDeferredType(keyNode,keyType);
      }
      if (objLitType != null) {
        boolean isExtern=t.getInput() != null && t.getInput().isExtern();
        objLitType.defineDeclaredProperty(memberName,keyType,isExtern,keyNode);
      }
    }
  }
}
Program: 18845
Project: 18845
Buggy source:
public void testConstructorAlias10() throws Exception {
  testTypes("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}

Fixed version (ground truth):
public void testConstructorAlias10() throws Exception {
  testTypes("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}
Program: 18846
Project: 18846
Buggy source:
public void testConstructorAlias9() throws Exception {
  testTypes("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}

Fixed version (ground truth):
public void testConstructorAlias9() throws Exception {
  testTypes("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}
Program: 18847
Project: 18847
Buggy source:
public void testConstructorAlias8() throws Exception {
  testTypes("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}

Fixed version (ground truth):
public void testConstructorAlias8() throws Exception {
  testTypes("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
}
Program: 18848
Project: 18848
Buggy source:
public void testStubFunctionDeclaration8() throws Exception {
  testFunctionType("String_Node_Str","String_Node_Str",createNullableType(U2U_CONSTRUCTOR_TYPE).restrictByNotNullOrUndefined().toString());
}

Fixed version (ground truth):
public void testStubFunctionDeclaration8() throws Exception {
  testFunctionType("String_Node_Str","String_Node_Str",createOptionalType(createNullableType(U2U_CONSTRUCTOR_TYPE)).toString());
}
Program: 18849
Project: 18849
Buggy source:
public void testStubFunctionDeclaration8() throws Exception {
  testFunctionType("String_Node_Str","String_Node_Str",createNullableType(U2U_CONSTRUCTOR_TYPE).restrictByNotNullOrUndefined().toString());
}

Fixed version (ground truth):
public void testStubFunctionDeclaration8() throws Exception {
  testFunctionType("String_Node_Str","String_Node_Str",createNullableType(U2U_CONSTRUCTOR_TYPE).toString());
}
Program: 18850
Project: 18850
Buggy source:
/** 
 * Gets the value of a node as a Number, or null if it cannot be converted. When it returns a non-null Double, this method effectively emulates the <code>Number()</code> JavaScript cast function.
 */
static Double getNumberValue(Node n){
switch (n.getType()) {
case Token.TRUE:
    return 1.0;
case Token.FALSE:
case Token.NULL:
  return 0.0;
case Token.NUMBER:
return n.getDouble();
case Token.VOID:
if (mayHaveSideEffects(n.getFirstChild())) {
return null;
}
 else {
return Double.NaN;
}
case Token.NAME:
String name=n.getString();
if (name.equals("String_Node_Str")) {
return Double.NaN;
}
if (name.equals("String_Node_Str")) {
return Double.NaN;
}
if (name.equals("String_Node_Str")) {
return Double.POSITIVE_INFINITY;
}
return null;
case Token.NEG:
if (n.getChildCount() == 1 && n.getFirstChild().getType() == Token.NAME && n.getFirstChild().getString().equals("String_Node_Str")) {
return Double.NEGATIVE_INFINITY;
}
return null;
case Token.NOT:
TernaryValue child=getBooleanValue(n.getFirstChild());
if (child != TernaryValue.UNKNOWN) {
return child.toBoolean(true) ? 0.0 : 1.0;
}
break;
case Token.STRING:
String s=trimJsWhiteSpace(n.getString());
if (s.length() == 0) {
return 0.0;
}
if (s.length() > 2 && s.charAt(0) == '0' && (s.charAt(1) == 'x' || s.charAt(1) == 'X')) {
try {
return Double.valueOf(Integer.parseInt(s.substring(2),16));
}
 catch (NumberFormatException e) {
return Double.NaN;
}
}
if (s.length() > 3 && (s.charAt(0) == '-' || s.charAt(0) == '+') && s.charAt(1) == '0' && (s.charAt(2) == 'x' || s.charAt(2) == 'X')) {
return null;
}
if (s.equals("String_Node_Str") || s.equals("String_Node_Str") || s.equals("String_Node_Str")) {
return null;
}
try {
return Double.parseDouble(s);
}
 catch (NumberFormatException e) {
return Double.NaN;
}
}
return null;
}

Fixed version (ground truth):
/** 
 * Gets the value of a node as a Number, or null if it cannot be converted. When it returns a non-null Double, this method effectively emulates the <code>Number()</code> JavaScript cast function.
 */
static Double getNumberValue(Node n){
switch (n.getType()) {
case Token.TRUE:
    return 1.0;
case Token.FALSE:
case Token.NULL:
  return 0.0;
case Token.NUMBER:
return n.getDouble();
case Token.VOID:
if (mayHaveSideEffects(n.getFirstChild())) {
return null;
}
 else {
return Double.NaN;
}
case Token.NAME:
String name=n.getString();
if (name.equals("String_Node_Str")) {
return Double.NaN;
}
if (name.equals("String_Node_Str")) {
return Double.NaN;
}
if (name.equals("String_Node_Str")) {
return Double.POSITIVE_INFINITY;
}
return null;
case Token.NEG:
if (n.getChildCount() == 1 && n.getFirstChild().getType() == Token.NAME && n.getFirstChild().getString().equals("String_Node_Str")) {
return Double.NEGATIVE_INFINITY;
}
return null;
case Token.NOT:
TernaryValue child=getBooleanValue(n.getFirstChild());
if (child != TernaryValue.UNKNOWN) {
return child.toBoolean(true) ? 0.0 : 1.0;
}
break;
case Token.STRING:
return getStringNumberValue(n.getString());
case Token.ARRAYLIT:
case Token.OBJECTLIT:
String value=getStringValue(n);
return value != null ? getStringNumberValue(value) : null;
}
return null;
}
Program: 18851
Project: 18851
Buggy source:
/** 
 * Gets the value of a node as a String, or null if it cannot be converted. When it returns a non-null String, this method effectively emulates the <code>String()</code> JavaScript cast function.
 */
static String getStringValue(Node n){
switch (n.getType()) {
case Token.STRING:
    return n.getString();
case Token.NAME:
  String name=n.getString();
if ("String_Node_Str".equals(name) || "String_Node_Str".equals(name) || "String_Node_Str".equals(name)) {
  return name;
}
break;
case Token.NUMBER:
double value=n.getDouble();
long longValue=(long)value;
if (longValue == value) {
return Long.toString(longValue);
}
 else {
return Double.toString(n.getDouble());
}
case Token.FALSE:
case Token.TRUE:
case Token.NULL:
return Node.tokenToName(n.getType());
case Token.VOID:
return "String_Node_Str";
case Token.NOT:
TernaryValue child=getBooleanValue(n.getFirstChild());
if (child != TernaryValue.UNKNOWN) {
return child.toBoolean(true) ? "String_Node_Str" : "String_Node_Str";
}
break;
}
return null;
}

Fixed version (ground truth):
/** 
 * Gets the value of a node as a String, or null if it cannot be converted. When it returns a non-null String, this method effectively emulates the <code>String()</code> JavaScript cast function.
 */
static String getStringValue(Node n){
switch (n.getType()) {
case Token.STRING:
    return n.getString();
case Token.NAME:
  String name=n.getString();
if ("String_Node_Str".equals(name) || "String_Node_Str".equals(name) || "String_Node_Str".equals(name)) {
  return name;
}
break;
case Token.NUMBER:
double value=n.getDouble();
long longValue=(long)value;
if (longValue == value) {
return Long.toString(longValue);
}
 else {
return Double.toString(n.getDouble());
}
case Token.FALSE:
case Token.TRUE:
case Token.NULL:
return Node.tokenToName(n.getType());
case Token.VOID:
return "String_Node_Str";
case Token.NOT:
TernaryValue child=getBooleanValue(n.getFirstChild());
if (child != TernaryValue.UNKNOWN) {
return child.toBoolean(true) ? "String_Node_Str" : "String_Node_Str";
}
break;
case Token.ARRAYLIT:
return arrayToString(n);
case Token.OBJECTLIT:
return "String_Node_Str";
}
return null;
}
Program: 18853
Project: 18853
Buggy source:
public void testGetStringValue(){
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals(null,NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals(null,NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals(null,NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals(null,NodeUtil.getStringValue(getNode("String_Node_Str")));
}

Fixed version (ground truth):
public void testGetStringValue(){
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals(null,NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals("String_Node_Str",NodeUtil.getStringValue(getNode("String_Node_Str")));
  assertEquals(null,NodeUtil.getStringValue(getNode("String_Node_Str")));
}
Program: 18854
Project: 18854
Buggy source:
public void testStringJoinAdd(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public void testStringJoinAdd(){
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
  foldSame("String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  fold("String_Node_Str","String_Node_Str");
  foldSame("String_Node_Str");
}
Program: 18855
Project: 18855
Buggy source:
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.getType() != Token.NAME) {
    return;
  }
  String name=n.getString();
  if (name.length() == 0) {
    return;
  }
  Scope.Var var=t.getScope().getVar(name);
  boolean local=(var != null) && var.isLocal();
  if (!local && localRenamingOnly) {
    reservedNames.add(name);
    return;
  }
  if (preserveFunctionExpressionNames && var != null && NodeUtil.isFunctionExpression(var.getParentNode())) {
    reservedNames.add(name);
    return;
  }
  if (!okToRenameVar(name,local)) {
    if (local) {
      String newName=MakeDeclaredNamesUnique.ContextualRenameInverter.getOrginalName(name);
      if (!newName.equals(name)) {
        n.setString(newName);
      }
    }
    return;
  }
  if (isExternsPass_) {
    if (!local) {
      externNames.add(name);
    }
    return;
  }
  if (pseudoNameMap != null) {
    recordPseudoName(n);
  }
  if (local) {
    String tempName=LOCAL_VAR_PREFIX + var.getLocalVarIndex();
    incCount(tempName,null);
    localNameNodes.add(n);
    n.setString(tempName);
  }
 else   if (var != null) {
    incCount(name,var.input);
    globalNameNodes.add(n);
  }
}

Fixed version (ground truth):
@Override public void visit(NodeTraversal t,Node n,Node parent){
  if (n.getType() != Token.NAME) {
    return;
  }
  String name=n.getString();
  if (name.length() == 0) {
    return;
  }
  Scope.Var var=t.getScope().getVar(name);
  boolean local=(var != null) && var.isLocal() && (!var.scope.getParent().isGlobal() || !var.isBleedingFunction());
  if (!local && localRenamingOnly) {
    reservedNames.add(name);
    return;
  }
  if (preserveFunctionExpressionNames && var != null && NodeUtil.isFunctionExpression(var.getParentNode())) {
    reservedNames.add(name);
    return;
  }
  if (!okToRenameVar(name,local)) {
    if (local) {
      String newName=MakeDeclaredNamesUnique.ContextualRenameInverter.getOrginalName(name);
      if (!newName.equals(name)) {
        n.setString(newName);
      }
    }
    return;
  }
  if (isExternsPass_) {
    if (!local) {
      externNames.add(name);
    }
    return;
  }
  if (pseudoNameMap != null) {
    recordPseudoName(n);
  }
  if (local) {
    String tempName=LOCAL_VAR_PREFIX + var.getLocalVarIndex();
    incCount(tempName,null);
    localNameNodes.add(n);
    n.setString(tempName);
  }
 else   if (var != null) {
    incCount(name,var.input);
    globalNameNodes.add(n);
  }
}
Program: 18857
Project: 18857
Buggy source:
TernaryValue testForEqualityHelper(JSType aType,JSType bType){
  if (bType.isAllType() || bType.isEmptyType() || bType.isUnknownType()) {
    return UNKNOWN;
  }
  if (aType.isFunctionType() || bType.isFunctionType()) {
    JSType otherType=aType.isFunctionType() ? bType : aType;
    if (otherType.isSubtype(getNativeType(JSTypeNative.OBJECT_TYPE))) {
      return TernaryValue.UNKNOWN;
    }
 else {
      return TernaryValue.FALSE;
    }
  }
  if (bType.isEnumElementType() || bType.isUnionType()) {
    return bType.testForEquality(aType);
  }
  return null;
}

Fixed version (ground truth):
TernaryValue testForEqualityHelper(JSType aType,JSType bType){
  if (bType.isAllType() || bType.isEmptyType() || bType.isUnknownType()|| aType.isAllType()|| aType.isEmptyType()|| aType.isUnknownType()) {
    return UNKNOWN;
  }
  if (aType.isFunctionType() || bType.isFunctionType()) {
    JSType otherType=aType.isFunctionType() ? bType : aType;
    if (!otherType.getGreatestSubtype(getNativeType(JSTypeNative.OBJECT_TYPE)).isEmptyType()) {
      return TernaryValue.UNKNOWN;
    }
 else {
      return TernaryValue.FALSE;
    }
  }
  if (bType.isEnumElementType() || bType.isUnionType()) {
    return bType.testForEquality(aType);
  }
  return null;
}
Program: 18859
Project: 18859
Buggy source:
@Override public int parseArguments(Parameters params) throws CmdLineException {
  String param=params.getParameter(0);
  if (param == null) {
    setter.addValue(true);
    return 0;
  }
 else {
    String lowerParam=param.toLowerCase();
    if (TRUES.contains(lowerParam)) {
      setter.addValue(true);
    }
 else     if (FALSES.contains(lowerParam)) {
      setter.addValue(false);
    }
 else {
      setter.addValue(true);
      return 0;
    }
    return 1;
  }
}

Fixed version (ground truth):
@Override public int parseArguments(Parameters params) throws CmdLineException {
  String param=null;
  try {
    param=params.getParameter(0);
  }
 catch (  CmdLineException e) {
  }
  if (param == null) {
    setter.addValue(true);
    return 0;
  }
 else {
    String lowerParam=param.toLowerCase();
    if (TRUES.contains(lowerParam)) {
      setter.addValue(true);
    }
 else     if (FALSES.contains(lowerParam)) {
      setter.addValue(false);
    }
 else {
      setter.addValue(true);
      return 0;
    }
    return 1;
  }
}
Program: 18860
Project: 18860
Buggy source:
@Override public void setUp() throws Exception {
  super.setUp();
  externs=DEFAULT_EXTERNS;
  lastCompiler=null;
  outReader=new ByteArrayOutputStream();
  errReader=new ByteArrayOutputStream();
  useStringComparison=false;
  useModules=ModulePattern.NONE;
  args.clear();
  exitCodes=Lists.newArrayList();
}

Fixed version (ground truth):
@Override public void setUp() throws Exception {
  super.setUp();
  externs=DEFAULT_EXTERNS;
  lastCompiler=null;
  lastArg=null;
  outReader=new ByteArrayOutputStream();
  errReader=new ByteArrayOutputStream();
  useStringComparison=false;
  useModules=ModulePattern.NONE;
  args.clear();
  exitCodes=Lists.newArrayList();
}
Program: 18861
Project: 18861
Buggy source:
private CommandLineRunner createCommandLineRunner(String[] original){
  for (int i=0; i < original.length; i++) {
    args.add("String_Node_Str");
    args.add("String_Node_Str" + i + "String_Node_Str");
    if (useModules == ModulePattern.CHAIN) {
      args.add("String_Node_Str");
      args.add("String_Node_Str" + i + "String_Node_Str"+ (i > 0 ? ("String_Node_Str" + (i - 1)) : "String_Node_Str"));
    }
 else     if (useModules == ModulePattern.STAR) {
      args.add("String_Node_Str");
      args.add("String_Node_Str" + i + "String_Node_Str"+ (i > 0 ? "String_Node_Str" : "String_Node_Str"));
    }
  }
  String[] argStrings=args.toArray(new String[]{});
  return new CommandLineRunner(argStrings,new PrintStream(outReader),new PrintStream(errReader));
}

Fixed version (ground truth):
private CommandLineRunner createCommandLineRunner(String[] original){
  for (int i=0; i < original.length; i++) {
    args.add("String_Node_Str");
    args.add("String_Node_Str" + i + "String_Node_Str");
    if (useModules == ModulePattern.CHAIN) {
      args.add("String_Node_Str");
      args.add("String_Node_Str" + i + "String_Node_Str"+ (i > 0 ? ("String_Node_Str" + (i - 1)) : "String_Node_Str"));
    }
 else     if (useModules == ModulePattern.STAR) {
      args.add("String_Node_Str");
      args.add("String_Node_Str" + i + "String_Node_Str"+ (i > 0 ? "String_Node_Str" : "String_Node_Str"));
    }
  }
  if (lastArg != null) {
    args.add(lastArg);
  }
  String[] argStrings=args.toArray(new String[]{});
  return new CommandLineRunner(argStrings,new PrintStream(outReader),new PrintStream(errReader));
}
Program: 18862
Project: 18862
Buggy source:
/** 
 * Determines whether two slots are meaningfully different for the purposes of data flow analysis.
 */
private boolean diffSlots(StaticSlot<JSType> slotA,StaticSlot<JSType> slotB){
  boolean aIsNull=slotA == null || slotA.getType() == null;
  boolean bIsNull=slotB == null || slotB.getType() == null;
  if (aIsNull && bIsNull) {
    return false;
  }
 else   if (aIsNull ^ bIsNull) {
    return true;
  }
  JSType aType=slotA.getType();
  JSType bType=slotB.getType();
  if (aType.isNoType() || bType.isNoType()) {
    return false;
  }
  return aType.differsFrom(bType);
}

Fixed version (ground truth):
/** 
 * Determines whether two slots are meaningfully different for the purposes of data flow analysis.
 */
private boolean diffSlots(StaticSlot<JSType> slotA,StaticSlot<JSType> slotB){
  boolean aIsNull=slotA == null || slotA.getType() == null;
  boolean bIsNull=slotB == null || slotB.getType() == null;
  if (aIsNull && bIsNull) {
    return false;
  }
 else   if (aIsNull ^ bIsNull) {
    return true;
  }
  return slotA.getType().differsFrom(slotB.getType());
}
Program: 18863
Project: 18863
Buggy source:
/** 
 * @return The expression node.
 */
private Node getBlockExpression(Node n){
  Preconditions.checkState(isExpressBlock(n));
  return n.getFirstChild();
}

Fixed version (ground truth):
/** 
 * @return The expression node.
 */
private Node getBlockExpression(Node n){
  Preconditions.checkState(isFoldableExpressBlock(n));
  return n.getFirstChild();
}
Program: 18865
Project: 18865
Buggy source:
@Override JSType resolveInternal(ErrorReporter t,StaticScope<JSType> scope){
  setResolvedTypeInternal(this);
  if (implicitPrototype != null && !implicitPrototype.isNativeObjectType()) {
    implicitPrototype=(ObjectType)implicitPrototype.resolve(t,scope);
  }
  for (  Property prop : properties.values()) {
    prop.type=safeResolve(prop.type,t,scope);
  }
  return this;
}

Fixed version (ground truth):
@Override JSType resolveInternal(ErrorReporter t,StaticScope<JSType> scope){
  setResolvedTypeInternal(this);
  ObjectType implicitPrototype=getImplicitPrototype();
  if (implicitPrototype != null) {
    implicitPrototypeFallback=(ObjectType)implicitPrototype.resolve(t,scope);
  }
  for (  Property prop : properties.values()) {
    prop.type=safeResolve(prop.type,t,scope);
  }
  return this;
}
Program: 18866
Project: 18866
Buggy source:
/** 
 * This should only be reset on the FunctionPrototypeType, only to fix an incorrectly established prototype chain due to the user having a mismatch in super class declaration, and only before properties on that type are processed.
 */
void setImplicitPrototype(ObjectType implicitPrototype){
  checkState(!hasCachedValues());
  this.implicitPrototype=implicitPrototype;
}

Fixed version (ground truth):
/** 
 * This should only be reset on the FunctionPrototypeType, only to fix an incorrectly established prototype chain due to the user having a mismatch in super class declaration, and only before properties on that type are processed.
 */
final void setImplicitPrototype(ObjectType implicitPrototype){
  checkState(!hasCachedValues());
  this.implicitPrototypeFallback=implicitPrototype;
}
Program: 18867
Project: 18867
Buggy source:
@Override public ObjectType getImplicitPrototype(){
  return implicitPrototype;
}

Fixed version (ground truth):
@Override public ObjectType getImplicitPrototype(){
  return implicitPrototypeFallback;
}
Program: 18868
Project: 18868
Buggy source:
/** 
 * Creates an object type, allowing specification of the implicit prototype when creating native objects.
 */
PrototypeObjectType(JSTypeRegistry registry,String className,ObjectType implicitPrototype,boolean nativeType){
  super(registry);
  this.properties=Maps.newTreeMap();
  this.className=className;
  this.nativeType=nativeType;
  if (nativeType) {
    this.implicitPrototype=implicitPrototype;
  }
 else   if (implicitPrototype == null) {
    this.implicitPrototype=registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE);
  }
 else {
    this.implicitPrototype=implicitPrototype;
  }
}

Fixed version (ground truth):
/** 
 * Creates an object type, allowing specification of the implicit prototype when creating native objects.
 */
PrototypeObjectType(JSTypeRegistry registry,String className,ObjectType implicitPrototype,boolean nativeType){
  super(registry);
  this.properties=Maps.newTreeMap();
  this.className=className;
  this.nativeType=nativeType;
  if (nativeType || implicitPrototype != null) {
    setImplicitPrototype(implicitPrototype);
  }
 else {
    setImplicitPrototype(registry.getNativeObjectType(JSTypeNative.OBJECT_TYPE));
  }
}
Program: 18870
Project: 18870
Buggy source:
/** 
 * Creates a dotted namespace assignment expression (e.g. <code>foo.bar = {};</code>).
 * @param namespace A dotted namespace
 * @param node A node from which to copy source info.
 */
private Node makeAssignmentExprNode(String namespace,Node node){
  Node decl=new Node(Token.EXPR_RESULT,new Node(Token.ASSIGN,NodeUtil.newQualifiedNameNode(namespace,node,namespace),new Node(Token.OBJECTLIT)));
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  Preconditions.checkState(isNamespacePlaceholder(decl));
  decl.copyInformationFromForTree(node);
  return decl;
}

Fixed version (ground truth):
/** 
 * Creates a dotted namespace assignment expression (e.g. <code>foo.bar = {};</code>).
 * @param namespace A dotted namespace
 * @param node A node from which to copy source info.
 */
private Node makeAssignmentExprNode(String namespace,Node node){
  Node decl=new Node(Token.EXPR_RESULT,new Node(Token.ASSIGN,NodeUtil.newQualifiedNameNode(namespace,node,namespace),createNamespaceLiteral()));
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  Preconditions.checkState(isNamespacePlaceholder(decl));
  decl.copyInformationFromForTree(node);
  return decl;
}
Program: 18871
Project: 18871
Buggy source:
/** 
 * Creates a simple namespace variable declaration (e.g. <code>var foo = {};</code>).
 * @param namespace A simple namespace (must be a valid js identifier)
 * @param sourceNode The node to get source information from.
 */
private Node makeVarDeclNode(String namespace,Node sourceNode){
  Node name=Node.newString(Token.NAME,namespace);
  name.addChildToFront(new Node(Token.OBJECTLIT));
  Node decl=new Node(Token.VAR,name);
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  if (compiler.getCodingConvention().isConstant(namespace)) {
    name.putBooleanProp(Node.IS_CONSTANT_NAME,true);
  }
  Preconditions.checkState(isNamespacePlaceholder(decl));
  decl.copyInformationFromForTree(sourceNode);
  return decl;
}

Fixed version (ground truth):
/** 
 * Creates a simple namespace variable declaration (e.g. <code>var foo = {};</code>).
 * @param namespace A simple namespace (must be a valid js identifier)
 * @param sourceNode The node to get source information from.
 */
private Node makeVarDeclNode(String namespace,Node sourceNode){
  Node name=Node.newString(Token.NAME,namespace);
  name.addChildToFront(createNamespaceLiteral());
  Node decl=new Node(Token.VAR,name);
  decl.putBooleanProp(Node.IS_NAMESPACE,true);
  if (compiler.getCodingConvention().isConstant(namespace)) {
    name.putBooleanProp(Node.IS_CONSTANT_NAME,true);
  }
  Preconditions.checkState(isNamespacePlaceholder(decl));
  decl.copyInformationFromForTree(sourceNode);
  return decl;
}
Program: 18872
Project: 18872
Buggy source:
private FlowScope traverseObjectLiteral(Node n,FlowScope scope){
  ObjectType objectType=(ObjectType)n.getJSType();
  if (objectType == null) {
    return scope;
  }
  if (objectType.hasReferenceName()) {
    return scope;
  }
  for (Node name=n.getFirstChild(); name != null; name=name.getNext().getNext()) {
    Node value=name.getNext();
    scope=traverse(name,scope);
    scope=traverse(value,scope);
    String memberName=NodeUtil.getStringValue(name);
    if (memberName != null) {
      objectType.defineInferredProperty(memberName,getJSType(value),false);
    }
 else {
      n.setJSType(getNativeType(UNKNOWN_TYPE));
      return scope;
    }
  }
  return scope;
}

Fixed version (ground truth):
private FlowScope traverseObjectLiteral(Node n,FlowScope scope){
  ObjectType objectType=(ObjectType)n.getJSType();
  Preconditions.checkNotNull(objectType);
  if (objectType.hasReferenceName()) {
    return scope;
  }
  for (Node name=n.getFirstChild(); name != null; name=name.getNext().getNext()) {
    Node value=name.getNext();
    scope=traverse(name,scope);
    scope=traverse(value,scope);
    String memberName=NodeUtil.getStringValue(name);
    if (memberName != null) {
      objectType.defineInferredProperty(memberName,getJSType(value),false);
    }
 else {
      n.setJSType(getNativeType(UNKNOWN_TYPE));
      return scope;
    }
  }
  return scope;
}
Program: 18873
Project: 18873
Buggy source:
private void attachLiteralTypes(Node n){
switch (n.getType()) {
case Token.NULL:
    n.setJSType(getNativeType(NULL_TYPE));
  break;
case Token.VOID:
n.setJSType(getNativeType(VOID_TYPE));
break;
case Token.STRING:
n.setJSType(getNativeType(STRING_TYPE));
break;
case Token.NUMBER:
n.setJSType(getNativeType(NUMBER_TYPE));
break;
case Token.TRUE:
case Token.FALSE:
n.setJSType(getNativeType(BOOLEAN_TYPE));
break;
case Token.REGEXP:
n.setJSType(getNativeType(REGEXP_TYPE));
break;
case Token.REF_SPECIAL:
n.setJSType(getNativeType(UNKNOWN_TYPE));
break;
case Token.OBJECTLIT:
n.setJSType(typeRegistry.createAnonymousObjectType());
break;
}
}

Fixed version (ground truth):
private void attachLiteralTypes(Node n){
switch (n.getType()) {
case Token.NULL:
    n.setJSType(getNativeType(NULL_TYPE));
  break;
case Token.VOID:
n.setJSType(getNativeType(VOID_TYPE));
break;
case Token.STRING:
n.setJSType(getNativeType(STRING_TYPE));
break;
case Token.NUMBER:
n.setJSType(getNativeType(NUMBER_TYPE));
break;
case Token.TRUE:
case Token.FALSE:
n.setJSType(getNativeType(BOOLEAN_TYPE));
break;
case Token.REGEXP:
n.setJSType(getNativeType(REGEXP_TYPE));
break;
case Token.REF_SPECIAL:
n.setJSType(getNativeType(UNKNOWN_TYPE));
break;
case Token.OBJECTLIT:
if (n.getJSType() == null) {
n.setJSType(typeRegistry.createAnonymousObjectType());
}
break;
}
}
Program: 18874
Project: 18874
Buggy source:
@Override public boolean apply(Node node){
  return NodeUtil.isCall(node) || NodeUtil.isNew(node) || NodeUtil.isFunction(node)|| NodeUtil.isName(node)|| (NodeUtil.isString(node) && NodeUtil.isGet(node.getParent()));
}

Fixed version (ground truth):
@Override public boolean apply(Node node){
  return NodeUtil.isCall(node) || NodeUtil.isNew(node) || NodeUtil.isFunction(node)|| NodeUtil.isName(node)|| NodeUtil.isGet(node)|| (NodeUtil.isString(node) && NodeUtil.isGet(node.getParent()));
}
Program: 18875
Project: 18875
Buggy source:
void addGuard(WarningsGuard guard){
  if (guard instanceof ComposeWarningsGuard) {
    addGuards(((ComposeWarningsGuard)guard).guards);
  }
 else {
    int index=Collections.binarySearch(this.guards,guard,guardComparator);
    if (index < 0) {
      index=-index - 1;
    }
    this.guards.add(index,guard);
  }
}

Fixed version (ground truth):
void addGuard(WarningsGuard guard){
  if (guard instanceof ComposeWarningsGuard) {
    addGuards(Iterables.reverse(((ComposeWarningsGuard)guard).guards));
  }
 else {
    int index=Collections.binarySearch(this.guards,guard,guardComparator);
    if (index < 0) {
      index=-index - 1;
    }
    this.guards.add(index,guard);
  }
}
Program: 18876
Project: 18876
Buggy source:
/** 
 * Determines whether this guard will "elevate" the status of any disabled diagnostic type in the group to a warning or an error.
 */
@Override public boolean enables(DiagnosticGroup group){
  for (  WarningsGuard guard : guards) {
    if (guard.enables(group)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Determines whether this guard will "elevate" the status of any disabled diagnostic type in the group to a warning or an error.
 */
@Override public boolean enables(DiagnosticGroup group){
  for (  WarningsGuard guard : guards) {
    if (guard.enables(group)) {
      return true;
    }
 else     if (guard.disables(group)) {
      return false;
    }
  }
  return false;
}
Program: 18877
Project: 18877
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) || n.getType() == Token.FUNCTION) {
    return true;
  }
 else   if (n.getType() == Token.CALL) {
    Node functionName=n.getFirstChild();
    return functionName.getType() == Token.NAME && (functionName.getString().equals(CrossModuleMethodMotion.STUB_METHOD_NAME) || functionName.getString().equals(CrossModuleMethodMotion.UNSTUB_METHOD_NAME));
  }
 else   if (n.getType() == Token.ARRAYLIT || n.getType() == Token.OBJECTLIT) {
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!canMoveValue(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(Node n){
  if (n == null || NodeUtil.isLiteralValue(n,true) || n.getType() == Token.FUNCTION) {
    return true;
  }
 else   if (n.getType() == Token.CALL) {
    Node functionName=n.getFirstChild();
    return functionName.getType() == Token.NAME && (functionName.getString().equals(CrossModuleMethodMotion.STUB_METHOD_NAME) || functionName.getString().equals(CrossModuleMethodMotion.UNSTUB_METHOD_NAME));
  }
 else   if (n.getType() == Token.ARRAYLIT || n.getType() == Token.OBJECTLIT) {
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!canMoveValue(child)) {
        return false;
      }
    }
    return true;
  }
  return false;
}
Program: 18878
Project: 18878
Buggy source:
@Override void visit(NodeTraversal t,Node callNode,Node parent,String callName){
  if (externMethods.contains(callName) || nonMethodProperties.contains(callName)) {
    return;
  }
  Collection<Node> definitions=methodDefinitions.get(callName);
  if (definitions == null || definitions.size() == 0) {
    return;
  }
  Node firstDefinition=definitions.iterator().next();
  if (definitions.size() == 1 || allDefinitionsEquivalent(definitions)) {
    if (!argsMayHaveSideEffects(callNode)) {
      Node returned=returnedExpression(firstDefinition);
      if (returned != null) {
        if (isPropertyTree(returned)) {
          logger.fine("String_Node_Str" + callName);
          inlinePropertyReturn(parent,callNode,returned);
        }
 else         if (NodeUtil.isLiteralValue(returned) && !NodeUtil.mayHaveSideEffects(callNode.getFirstChild())) {
          logger.fine("String_Node_Str" + callName);
          inlineConstReturn(parent,callNode,returned);
        }
      }
 else       if (isEmptyMethod(firstDefinition) && !NodeUtil.mayHaveSideEffects(callNode.getFirstChild())) {
        logger.fine("String_Node_Str" + callName);
        inlineEmptyMethod(t,parent,callNode);
      }
    }
  }
 else {
    logger.fine("String_Node_Str" + callName + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override void visit(NodeTraversal t,Node callNode,Node parent,String callName){
  if (externMethods.contains(callName) || nonMethodProperties.contains(callName)) {
    return;
  }
  Collection<Node> definitions=methodDefinitions.get(callName);
  if (definitions == null || definitions.size() == 0) {
    return;
  }
  Node firstDefinition=definitions.iterator().next();
  if (definitions.size() == 1 || allDefinitionsEquivalent(definitions)) {
    if (!argsMayHaveSideEffects(callNode)) {
      Node returned=returnedExpression(firstDefinition);
      if (returned != null) {
        if (isPropertyTree(returned)) {
          logger.fine("String_Node_Str" + callName);
          inlinePropertyReturn(parent,callNode,returned);
        }
 else         if (NodeUtil.isLiteralValue(returned,false) && !NodeUtil.mayHaveSideEffects(callNode.getFirstChild())) {
          logger.fine("String_Node_Str" + callName);
          inlineConstReturn(parent,callNode,returned);
        }
      }
 else       if (isEmptyMethod(firstDefinition) && !NodeUtil.mayHaveSideEffects(callNode.getFirstChild())) {
        logger.fine("String_Node_Str" + callName);
        inlineEmptyMethod(t,parent,callNode);
      }
    }
  }
 else {
    logger.fine("String_Node_Str" + callName + "String_Node_Str");
  }
}
Program: 18879
Project: 18879
Buggy source:
/** 
 * If the value is a literal, we can cross more boundaries to inline it.
 */
private boolean canMoveAggressively(Node value){
  return NodeUtil.isLiteralValue(value) || value.getType() == Token.FUNCTION;
}

Fixed version (ground truth):
/** 
 * If the value is a literal, we can cross more boundaries to inline it.
 */
private boolean canMoveAggressively(Node value){
  return NodeUtil.isLiteralValue(value,true) || value.getType() == Token.FUNCTION;
}
Program: 18880
Project: 18880
Buggy source:
/** 
 * If the value of a variable is not constant, then it may read or modify state. Therefore it cannot be moved past anything else that may modify the value being read or read values that are modified.
 */
private boolean canMoveModerately(Reference initialization,Reference reference){
  Iterator<Node> it;
  if (initialization.getParent().getType() == Token.VAR) {
    it=NodeIterators.LocalVarMotion.forVar(initialization.getNameNode(),initialization.getParent(),initialization.getGrandparent());
  }
 else   if (initialization.getParent().getType() == Token.ASSIGN) {
    Preconditions.checkState(initialization.getGrandparent().getType() == Token.EXPR_RESULT);
    it=NodeIterators.LocalVarMotion.forAssign(initialization.getNameNode(),initialization.getParent(),initialization.getGrandparent(),initialization.getGrandparent().getParent());
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
  Node targetName=reference.getNameNode();
  while (it.hasNext()) {
    Node curNode=it.next();
    if (curNode == targetName) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * If the value of a variable is not constant, then it may read or modify state. Therefore it cannot be moved past anything else that may modify the value being read or read values that are modified.
 */
private boolean canMoveModerately(Reference initialization,Reference reference){
  Iterator<Node> it;
  if (initialization.getParent().getType() == Token.VAR) {
    it=NodeIterators.LocalVarMotion.forVar(initialization.getNameNode(),initialization.getParent(),initialization.getGrandparent());
  }
 else   if (initialization.getParent().getType() == Token.ASSIGN) {
    Preconditions.checkState(initialization.getGrandparent().getType() == Token.EXPR_RESULT);
    it=NodeIterators.LocalVarMotion.forAssign(initialization.getNameNode(),initialization.getParent(),initialization.getGrandparent(),initialization.getGrandparent().getParent());
  }
 else {
    throw new IllegalStateException("String_Node_Str" + initialization.getParent().toStringTree());
  }
  Node targetName=reference.getNameNode();
  while (it.hasNext()) {
    Node curNode=it.next();
    if (curNode == targetName) {
      return true;
    }
  }
  return false;
}
Program: 18881
Project: 18881
Buggy source:
/** 
 * Returns true if this is a literal value. We define a literal value as any node that evaluates to the same thing regardless of when or where it is evaluated. So /xyz/ and [3, 5] are literals, but function() { return a; } is not.
 */
static boolean isLiteralValue(Node n){
switch (n.getType()) {
case Token.ARRAYLIT:
case Token.OBJECTLIT:
case Token.REGEXP:
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!isLiteralValue(child)) {
        return false;
      }
    }
  return true;
default :
return isImmutableValue(n);
}
}

Fixed version (ground truth):
/** 
 * Returns true if this is a literal value. We define a literal value as any node that evaluates to the same thing regardless of when or where it is evaluated. So /xyz/ and [3, 5] are literals, but the name a is not. Function literals do not meet this definition, because they lexically capture variables. For example, if you have <code> function() { return a; } </code> If it is evaluated in a different scope, then it captures a different variable. Even if the function did not read any captured vairables directly, it would still fail this definition, because it affects the lifecycle of variables in the enclosing scope. However, a function literal with respect to a particular scope is a literal.
 * @param includeFunctions If true, all function expressions will betreated as literals.
 */
static boolean isLiteralValue(Node n,boolean includeFunctions){
switch (n.getType()) {
case Token.ARRAYLIT:
case Token.OBJECTLIT:
case Token.REGEXP:
    for (Node child=n.getFirstChild(); child != null; child=child.getNext()) {
      if (!isLiteralValue(child,includeFunctions)) {
        return false;
      }
    }
  return true;
case Token.FUNCTION:
return includeFunctions && !NodeUtil.isFunctionDeclaration(n);
default :
return isImmutableValue(n);
}
}
Program: 18883
Project: 18883
Buggy source:
private void buildParameterList(List<Parameter> parameters,Node cur){
  while ((cur=cur.getNext()) != null) {
    parameters.add(new Parameter(cur,NodeUtil.isLiteralValue(cur)));
  }
}

Fixed version (ground truth):
private void buildParameterList(List<Parameter> parameters,Node cur){
  while ((cur=cur.getNext()) != null) {
    parameters.add(new Parameter(cur,NodeUtil.isLiteralValue(cur,false)));
  }
}
Program: 18884
Project: 18884
Buggy source:
private Node tryFoldAdd(Node node,Node left,Node right){
  Preconditions.checkArgument(node.getType() == Token.ADD);
  if (NodeUtil.isLiteralValue(left) && NodeUtil.isLiteralValue(right)) {
    return tryFoldAddConstant(node,left,right);
  }
 else {
    return tryFoldLeftChildAdd(node,left,right);
  }
}

Fixed version (ground truth):
private Node tryFoldAdd(Node node,Node left,Node right){
  Preconditions.checkArgument(node.getType() == Token.ADD);
  if (NodeUtil.isLiteralValue(left,false) && NodeUtil.isLiteralValue(right,false)) {
    return tryFoldAddConstant(node,left,right);
  }
 else {
    return tryFoldLeftChildAdd(node,left,right);
  }
}
Program: 18885
Project: 18885
Buggy source:
/** 
 * Expressions such as [foo() + 'a' + 'b'] generate parse trees where no node has two const children ((foo() + 'a') + 'b'), so tryFoldAdd() won't fold it -- tryFoldLeftChildAdd() will (for Strings). Specifically it folds Add exprssions where: - The left child is also and add expression - The right child is a constant value - The left child's right child is a STRING constant. WARNING: If javascript ever adds operator overloading, this will probably stop being correct.
 */
private Node tryFoldLeftChildAdd(Node n,Node left,Node right){
  if (NodeUtil.isLiteralValue(right) && left.getType() == Token.ADD && left.getChildCount() == 2) {
    Node ll=left.getFirstChild();
    Node lr=ll.getNext();
    if (lr.getType() != Token.STRING) {
      return n;
    }
    String leftString=NodeUtil.getStringValue(lr);
    String rightString=NodeUtil.getStringValue(right);
    if (leftString != null && rightString != null) {
      left.removeChild(ll);
      String result=leftString + rightString;
      n.replaceChild(left,ll);
      n.replaceChild(right,Node.newString(result));
      reportCodeChange();
    }
  }
  return n;
}

Fixed version (ground truth):
/** 
 * Expressions such as [foo() + 'a' + 'b'] generate parse trees where no node has two const children ((foo() + 'a') + 'b'), so tryFoldAdd() won't fold it -- tryFoldLeftChildAdd() will (for Strings). Specifically it folds Add exprssions where: - The left child is also and add expression - The right child is a constant value - The left child's right child is a STRING constant. WARNING: If javascript ever adds operator overloading, this will probably stop being correct.
 */
private Node tryFoldLeftChildAdd(Node n,Node left,Node right){
  if (NodeUtil.isLiteralValue(right,false) && left.getType() == Token.ADD && left.getChildCount() == 2) {
    Node ll=left.getFirstChild();
    Node lr=ll.getNext();
    if (lr.getType() != Token.STRING) {
      return n;
    }
    String leftString=NodeUtil.getStringValue(lr);
    String rightString=NodeUtil.getStringValue(right);
    if (leftString != null && rightString != null) {
      left.removeChild(ll);
      String result=leftString + rightString;
      n.replaceChild(left,ll);
      n.replaceChild(right,Node.newString(result));
      reportCodeChange();
    }
  }
  return n;
}