nus-yam/ex-repair huggingface dataset:
Program: 29377
Project: 29377
Buggy source:
@Override protected String getCommonSuperClass(String left,String right){
  boolean leftIsGenerated=left.startsWith(Names.INTERNAL_CLASS_PREFIX);
  boolean rightIsGenerated=right.startsWith(Names.INTERNAL_CLASS_PREFIX);
  if (!leftIsGenerated & !rightIsGenerated) {
    return super.getCommonSuperClass(left,right);
  }
  return OBJECT.internalName();
}

Fixed version (ground truth):
@Override protected String getCommonSuperClass(String left,String right){
  boolean leftIsGenerated=left.startsWith(Names.INTERNAL_CLASS_PREFIX);
  boolean rightIsGenerated=right.startsWith(Names.INTERNAL_CLASS_PREFIX);
  if (!leftIsGenerated && !rightIsGenerated) {
    if ((left.equals(PROTO_EXTENDABLE_BUILDER) && right.endsWith("String_Node_Str")) || (right.equals(PROTO_EXTENDABLE_BUILDER) && left.endsWith("String_Node_Str"))) {
      return PROTO_EXTENDABLE_BUILDER;
    }
    try {
      return super.getCommonSuperClass(left,right);
    }
 catch (    RuntimeException re) {
      throw new RuntimeException("String_Node_Str" + left + "String_Node_Str"+ right);
    }
  }
  return OBJECT.internalName();
}
Program: 29378
Project: 29378
Buggy source:
private static PrimitiveSoyType protoType(SoyProtoType soyType){
  return new PrimitiveSoyType(soyType,Type.getType('L' + soyType.getNameForBackend(SoyBackendKind.JBC_SRC).replace('.','/') + ';'),BytecodeUtils.SOY_PROTO_VALUE_TYPE);
}

Fixed version (ground truth):
private static PrimitiveSoyType protoType(SoyProtoType soyType){
  return new PrimitiveSoyType(soyType,Type.getType('L' + soyType.getNameForBackend(SoyBackendKind.JBC_SRC).replace('.','/') + ';'),BytecodeUtils.SOY_PROTO_VALUE_IMPL_TYPE);
}
Program: 29379
Project: 29379
Buggy source:
/** 
 * Creates a code chunk declaring an automatically-named variable initialized to the given value.
 */
public VariableDeclaration declare(CodeChunk.WithValue rhs){
  return CodeChunk.declare(newVarName(),rhs);
}

Fixed version (ground truth):
/** 
 * Creates a code chunk declaring an automatically-named variable with no initializer. 
 */
public VariableDeclaration declare(){
  return VariableDeclaration.create(newVarName(),null);
}
Program: 29380
Project: 29380
Buggy source:
/** 
 * Creates a code chunk representing a JavaScript number literal. 
 */
public static WithValue number(double value){
  return Leaf.create(Double.toString(value));
}

Fixed version (ground truth):
/** 
 * Creates a code chunk representing a JavaScript number literal. 
 */
public static WithValue number(double value){
  return Leaf.create(Double.toString(value),true);
}
Program: 29381
Project: 29381
Buggy source:
/** 
 * Creates a code chunk representing a JavaScript identifier.
 * @throws IllegalArgumentException if {@code id} is not a valid JavaScript identifier.
 */
static WithValue id(String id,Iterable<GoogRequire> requires){
  CodeChunkUtils.checkId(id);
  return Leaf.create(id,requires);
}

Fixed version (ground truth):
/** 
 * Creates a code chunk representing a JavaScript identifier.
 * @throws IllegalArgumentException if {@code id} is not a valid JavaScript identifier.
 */
static WithValue id(String id,Iterable<GoogRequire> requires){
  CodeChunkUtils.checkId(id);
  return Leaf.create(id,true,requires);
}
Program: 29382
Project: 29382
Buggy source:
/** 
 * Creates a code chunk representing a JavaScript string literal.
 * @param contents The contents of the string literal. The contents will be escaped appropriatelyand embedded inside single quotes.
 */
public static WithValue stringLiteral(String contents){
  String escaped=BaseUtils.escapeToSoyString(contents,true);
  escaped=escaped.replace("String_Node_Str","String_Node_Str");
  return Leaf.create(escaped);
}

Fixed version (ground truth):
/** 
 * Creates a code chunk representing a JavaScript string literal.
 * @param contents The contents of the string literal. The contents will be escaped appropriatelyand embedded inside single quotes.
 */
public static WithValue stringLiteral(String contents){
  String escaped=BaseUtils.escapeToSoyString(contents,true);
  escaped=escaped.replace("String_Node_Str","String_Node_Str");
  return Leaf.create(escaped,true);
}
Program: 29383
Project: 29383
Buggy source:
/** 
 * Creates a new code chunk from the given expression. The expression's precedence is preserved.
 */
public static WithValue fromExpr(JsExpr expr,Iterable<GoogRequire> requires){
  return Leaf.create(expr,requires);
}

Fixed version (ground truth):
/** 
 * Creates a new code chunk from the given expression. The expression's precedence is preserved.
 */
public static WithValue fromExpr(JsExpr expr,Iterable<GoogRequire> requires){
  return Leaf.create(expr,false,requires);
}
Program: 29384
Project: 29384
Buggy source:
/** 
 * If every branch in an   {@code if}-  {@code else if}-  {@code else} statement represents a value, thewhole statement represents a value, namely that of the taken branch. Make this explicit by declaring a variable before the statement and assigning into it in every branch.
 */
CodeChunk.WithValue asConditionalExpression(CodeChunk.Generator codeGenerator){
  Preconditions.checkState(everyBranchHasAValue());
  VariableDeclaration decl=codeGenerator.declare(WithValue.LITERAL_NULL);
  CodeChunk.WithValue var=decl.ref();
  ConditionalBuilder builder=null;
  for (  IfThenPair oldCondition : conditions()) {
    CodeChunk.WithValue newConsequent=var.assign((CodeChunk.WithValue)oldCondition.consequent);
    if (builder == null) {
      builder=CodeChunk.ifStatement(oldCondition.predicate,newConsequent);
    }
 else {
      builder.elseif_(oldCondition.predicate,newConsequent);
    }
  }
  if (trailingElse() != null) {
    builder.else_(var.assign((CodeChunk.WithValue)trailingElse()));
  }
  return var.withInitialStatements(ImmutableList.of(decl,builder.build()));
}

Fixed version (ground truth):
/** 
 * If every branch in an   {@code if}-  {@code else if}-  {@code else} statement represents a value, thewhole statement represents a value, namely that of the taken branch. Make this explicit by declaring a variable before the statement and assigning into it in every branch.
 */
CodeChunk.WithValue asConditionalExpression(CodeChunk.Generator codeGenerator){
  Preconditions.checkState(everyBranchHasAValue());
  VariableDeclaration decl=codeGenerator.declare();
  CodeChunk.WithValue var=decl.ref();
  ConditionalBuilder builder=null;
  for (  IfThenPair oldCondition : conditions()) {
    CodeChunk.WithValue newConsequent=var.assign((CodeChunk.WithValue)oldCondition.consequent);
    if (builder == null) {
      builder=CodeChunk.ifStatement(oldCondition.predicate,newConsequent);
    }
 else {
      builder.elseif_(oldCondition.predicate,newConsequent);
    }
  }
  if (trailingElse() != null) {
    builder.else_(var.assign((CodeChunk.WithValue)trailingElse()));
  }
  return var.withInitialStatements(ImmutableList.of(decl,builder.build()));
}
Program: 29385
Project: 29385
Buggy source:
static Leaf create(JsExpr value,Iterable<GoogRequire> requires){
  return new AutoValue_Leaf(value,ImmutableSet.copyOf(requires));
}

Fixed version (ground truth):
static Leaf create(JsExpr value,boolean isCheap,Iterable<GoogRequire> requires){
  return new AutoValue_Leaf(value,ImmutableSet.copyOf(requires),isCheap);
}
Program: 29386
Project: 29386
Buggy source:
/** 
 * Returns a code chunk representing the entire access chain. Null-safe accesses in the chain generate code to make sure the chain is non-null before performing the access.
 */
CodeChunk.WithValue result(CodeChunk.Generator codeGenerator){
  ImmutableList<CodeChunk.WithValue> intermediateValues=buildIntermediateValues();
  Preconditions.checkState(intermediateValues.size() == chain.size() + 1);
  CodeChunk.WithValue cur=intermediateValues.get(intermediateValues.size() - 1);
  for (int i=intermediateValues.size() - 2; i >= 0; --i) {
    CodeChunk.WithValue chunk=intermediateValues.get(i);
    boolean nullSafe=chain.get(i).nullSafe;
    if (nullSafe) {
      cur=ifExpression(chunk.doubleEqualsNull(),LITERAL_NULL).else_(cur).build(codeGenerator);
    }
  }
  if (unpackFunction == null) {
    return cur;
  }
 else   if (!isRepeated) {
    return unpackFunction.call(cur);
  }
 else {
    return GOOG_ARRAY_MAP.call(cur,unpackFunction);
  }
}

Fixed version (ground truth):
/** 
 * Returns a code chunk representing the entire access chain. Null-safe accesses in the chain generate code to make sure the chain is non-null before performing the access.
 */
CodeChunk.WithValue result(CodeChunk.Generator codeGenerator){
  CodeChunk.WithValue accessChain=buildAccessChain(base,codeGenerator,chain.iterator());
  if (unpackFunction == null) {
    return accessChain;
  }
 else   if (!isRepeated) {
    return unpackFunction.call(accessChain);
  }
 else {
    return GOOG_ARRAY_MAP.call(accessChain,unpackFunction);
  }
}
Program: 29387
Project: 29387
Buggy source:
@Test public void testNullSafeChain(){
  NullSafeAccumulator accum=new NullSafeAccumulator(CodeChunk.id("String_Node_Str"));
  assertThat(accum).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),true)).generates("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testNullSafeChain(){
  NullSafeAccumulator accum=new NullSafeAccumulator(CodeChunk.id("String_Node_Str"));
  assertThat(accum).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),true)).generates("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),true)).generates("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"+ "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"+ "String_Node_Str");
}
Program: 29388
Project: 29388
Buggy source:
@Test public void testMixedChains(){
  NullSafeAccumulator accum=new NullSafeAccumulator(CodeChunk.id("String_Node_Str"));
  assertThat(accum).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),false)).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),false)).generates("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testMixedChains(){
  NullSafeAccumulator accum=new NullSafeAccumulator(CodeChunk.id("String_Node_Str"));
  assertThat(accum).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),false)).generates("String_Node_Str");
  assertThat(accum.dotAccess(FieldAccess.id("String_Node_Str"),true)).generates("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  assertThat(accum.bracketAccess(CodeChunk.id("String_Node_Str"),false)).generates("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 29391
Project: 29391
Buggy source:
@Override protected void visitSoyFileSetNode(SoyFileSetNode node){
  if (!bidiGlobalDir.isStaticValue()) {
    return;
  }
  nodeIdGen=node.getNodeIdGenerator();
  madeReplacement=false;
  visitChildren(node);
  if (madeReplacement) {
    new CombineConsecutiveRawTextNodesVisitor().exec(node);
  }
}

Fixed version (ground truth):
@Override protected void visitSoyFileSetNode(SoyFileSetNode node){
  if (!bidiGlobalDir.isStaticValue()) {
    return;
  }
  nodeIdGen=node.getNodeIdGenerator();
  madeReplacement=false;
  visitChildren(node);
  if (madeReplacement) {
    new CombineConsecutiveRawTextNodesPass().run(node);
  }
}
Program: 29393
Project: 29393
Buggy source:
/** 
 * This method should be called at the end of a sequence of basic whitespace tokens. This is how we implement the line joining algorithm.
 * @param next The next basic text token image, or null if the next token isn't a basic token.
 */
private void maybeCollapseWhitespace(@Nullable String next){
  if (basicStartOfWhitespace != -1) {
    if (basicHasNewline) {
      if (basicStart == basicStartOfWhitespace || next == null) {
        buffer.delete(basicStartOfWhitespace,buffer.length());
        offsets.delete(basicStartOfWhitespace);
        if (next == null && endColumnAtStartOfWhitespace != -1) {
          offsets.setEndLocation(endLineAtStartOfWhitespace,endColumnAtStartOfWhitespace);
        }
      }
 else {
        if (next.charAt(0) == '<' || buffer.charAt(basicStartOfWhitespace - 1) == '>') {
          buffer.delete(basicStartOfWhitespace,buffer.length());
          offsets.delete(basicStartOfWhitespace);
        }
 else {
          buffer.replace(basicStartOfWhitespace,buffer.length(),"String_Node_Str");
          offsets.delete(basicStartOfWhitespace);
        }
      }
      discontinuityReason=Reason.WHITESPACE;
      basicHasNewline=false;
    }
    basicStartOfWhitespace=-1;
  }
}

Fixed version (ground truth):
/** 
 * This method should be called at the end of a sequence of basic whitespace tokens. This is how we implement the line joining algorithm.
 * @param next The next basic text token image, or null if the next token isn't a basic token.
 */
private void maybeCollapseWhitespace(@Nullable String next){
  if (basicStartOfWhitespace != -1) {
    if (basicHasNewline) {
      offsets.delete(basicStartOfWhitespace);
      if (basicStart == basicStartOfWhitespace || next == null) {
        buffer.setLength(basicStartOfWhitespace);
        if (next == null && endColumnAtStartOfWhitespace != -1) {
          offsets.setEndLocation(endLineAtStartOfWhitespace,endColumnAtStartOfWhitespace);
        }
      }
 else {
        if (next.charAt(0) == '<' || buffer.charAt(basicStartOfWhitespace - 1) == '>') {
          buffer.setLength(basicStartOfWhitespace);
        }
 else {
          buffer.setLength(basicStartOfWhitespace);
          buffer.append(' ');
        }
      }
      discontinuityReason=Reason.WHITESPACE;
      basicHasNewline=false;
    }
    basicStartOfWhitespace=-1;
  }
}
Program: 29394
Project: 29394
Buggy source:
/** 
 * Builds a lookup map that can be used for finding all callers of a particular template. All entries in the map (both keys and values) are HTML templates with strict auto escape mode.
 */
private Multimap<TemplateNode,TemplateNode> buildStrictHtmlCallers(TemplateRegistry registry){
  Multimap<TemplateNode,TemplateNode> strictHtmlCallers=LinkedHashMultimap.create();
  for (  TemplateNode template : registry.getAllTemplates()) {
    for (    CallNode callNode : SoyTreeUtils.getAllNodesOfType(template,CallNode.class)) {
      if (callNode instanceof CallBasicNode) {
        TemplateNode callee=registry.getBasicTemplate(((CallBasicNode)callNode).getCalleeName());
        if (isStrictAndKindHtml(callee)) {
          strictHtmlCallers.put(callee,template);
        }
      }
 else       if (callNode instanceof CallDelegateNode) {
        ImmutableList<TemplateDelegateNode> potentialCallees=registry.getDelTemplateSelector().delTemplateNameToValues().get(((CallDelegateNode)callNode).getDelCalleeName());
        for (        TemplateDelegateNode callee : potentialCallees) {
          if (isStrictAndKindHtml(callee)) {
            strictHtmlCallers.put(callee,template);
          }
        }
      }
    }
  }
  return strictHtmlCallers;
}

Fixed version (ground truth):
/** 
 * Builds a lookup map that can be used for finding all callers of a particular template. All entries in the map (both keys and values) are HTML templates with strict auto escape mode.
 */
private Multimap<TemplateNode,TemplateNode> buildStrictHtmlCallers(TemplateRegistry registry){
  Multimap<TemplateNode,TemplateNode> strictHtmlCallers=LinkedHashMultimap.create();
  for (  TemplateNode template : registry.getAllTemplates()) {
    if (!isStrictAndKindHtml(template)) {
      continue;
    }
    for (    CallNode callNode : SoyTreeUtils.getAllNodesOfType(template,CallNode.class)) {
      if (callNode instanceof CallBasicNode) {
        TemplateNode callee=registry.getBasicTemplate(((CallBasicNode)callNode).getCalleeName());
        if (isStrictAndKindHtml(callee)) {
          strictHtmlCallers.put(callee,template);
        }
      }
 else       if (callNode instanceof CallDelegateNode) {
        ImmutableList<TemplateDelegateNode> potentialCallees=registry.getDelTemplateSelector().delTemplateNameToValues().get(((CallDelegateNode)callNode).getDelCalleeName());
        for (        TemplateDelegateNode callee : potentialCallees) {
          if (isStrictAndKindHtml(callee)) {
            strictHtmlCallers.put(callee,template);
          }
        }
      }
    }
  }
  return strictHtmlCallers;
}
Program: 29395
Project: 29395
Buggy source:
@Override public Optional<Class<?>> load(Type key) throws Exception {
switch (key.getSort()) {
case Type.ARRAY:
    Optional<Class<?>> elementType=objectTypeToClassCache.getUnchecked(key.getElementType());
  if (elementType.isPresent()) {
    return Optional.<Class<?>>of(Array.newInstance(elementType.get(),0).getClass());
  }
return Optional.absent();
case Type.VOID:
return Optional.<Class<?>>of(void.class);
case Type.BOOLEAN:
return Optional.<Class<?>>of(boolean.class);
case Type.BYTE:
return Optional.<Class<?>>of(byte.class);
case Type.CHAR:
return Optional.<Class<?>>of(char.class);
case Type.DOUBLE:
return Optional.<Class<?>>of(double.class);
case Type.INT:
return Optional.<Class<?>>of(int.class);
case Type.SHORT:
return Optional.<Class<?>>of(short.class);
case Type.LONG:
return Optional.<Class<?>>of(long.class);
case Type.FLOAT:
return Optional.<Class<?>>of(float.class);
case Type.OBJECT:
try {
return Optional.<Class<?>>of(Class.forName(key.getClassName(),false,BytecodeUtils.class.getClassLoader()));
}
 catch (ClassNotFoundException e) {
return Optional.absent();
}
default :
throw new IllegalArgumentException("String_Node_Str" + key);
}
}

Fixed version (ground truth):
@Override public Optional<Class<?>> load(Type key) throws Exception {
switch (key.getSort()) {
case Type.ARRAY:
    Optional<Class<?>> elementType=objectTypeToClassCache.getUnchecked(key.getElementType());
  if (elementType.isPresent()) {
    return Optional.<Class<?>>of(Array.newInstance(elementType.get(),0).getClass());
  }
return Optional.absent();
case Type.VOID:
return Optional.<Class<?>>of(void.class);
case Type.BOOLEAN:
return Optional.<Class<?>>of(boolean.class);
case Type.BYTE:
return Optional.<Class<?>>of(byte.class);
case Type.CHAR:
return Optional.<Class<?>>of(char.class);
case Type.DOUBLE:
return Optional.<Class<?>>of(double.class);
case Type.INT:
return Optional.<Class<?>>of(int.class);
case Type.SHORT:
return Optional.<Class<?>>of(short.class);
case Type.LONG:
return Optional.<Class<?>>of(long.class);
case Type.FLOAT:
return Optional.<Class<?>>of(float.class);
case Type.OBJECT:
try {
String className=key.getClassName();
if (className.startsWith(Names.CLASS_PREFIX)) {
return Optional.absent();
}
return Optional.<Class<?>>of(Class.forName(className,false,BytecodeUtils.class.getClassLoader()));
}
 catch (ClassNotFoundException e) {
return Optional.absent();
}
default :
throw new IllegalArgumentException("String_Node_Str" + key);
}
}
Program: 29396
Project: 29396
Buggy source:
@Override protected final Optional<Expression> visitExprNode(ExprNode node){
  if (allowsBoxing()) {
    Optional<SoyExpression> compileWithNoDetaches=exprCompiler.compileWithNoDetaches(node);
    if (compileWithNoDetaches.isPresent()) {
      return Optional.<Expression>of(compileWithNoDetaches.get().box());
    }
  }
  return Optional.absent();
}

Fixed version (ground truth):
@Override protected final Optional<Expression> visitExprNode(ExprNode node){
  if (allowsBoxing()) {
    Optional<SoyExpression> compileWithNoDetaches=exprCompiler.compileWithNoDetaches(node);
    if (compileWithNoDetaches.isPresent()) {
      return Optional.of(compileWithNoDetaches.get().boxAsSoyValueProvider());
    }
  }
  return Optional.absent();
}
Program: 29397
Project: 29397
Buggy source:
/** 
 * Returns an expression that accesses this static field. 
 */
Expression accessor(){
  checkState(isStatic());
  Features features=Features.of(Feature.CHEAP);
  if (!isNullable()) {
    features=features.plus(Feature.NON_NULLABLE);
  }
  return new Expression(type(),features){
    @Override void doGen(    CodeBuilder mv){
      mv.getStatic(owner().type(),FieldRef.this.name(),resultType());
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Returns an expression that accesses this static field. 
 */
Expression accessor(){
  checkState(isStatic());
  Features features=Features.of(Feature.CHEAP);
  if (!isNullable()) {
    features=features.plus(Feature.NON_NULLABLE);
  }
  return new Expression(type(),features){
    @Override void doGen(    CodeBuilder mv){
      accessStaticUnchecked(mv);
    }
  }
;
}
Program: 29398
Project: 29398
Buggy source:
private SoyExpression invokeSoyFunction(FunctionNode node,List<SoyExpression> args){
  Expression soyJavaFunctionExpr=MethodRef.RENDER_CONTEXT_GET_FUNCTION.invoke(parameterLookup.getRenderContext(),constant(node.getFunctionName()));
  Expression list=SoyExpression.asBoxedList(args);
  return SoyExpression.forSoyValue(UnknownType.getInstance(),MethodRef.RUNTIME_CALL_SOY_FUNCTION.invoke(soyJavaFunctionExpr,list));
}

Fixed version (ground truth):
private SoyExpression invokeSoyFunction(FunctionNode node,List<SoyExpression> args){
  Expression soyJavaFunctionExpr=MethodRef.RENDER_CONTEXT_GET_FUNCTION.invoke(parameterLookup.getRenderContext(),constant(node.getFunctionName()));
  Expression list=SoyExpression.asBoxedList(args);
  return SoyExpression.forSoyValue(node.getType(),MethodRef.RUNTIME_CALL_SOY_FUNCTION.invoke(soyJavaFunctionExpr,list).checkedCast(SoyRuntimeType.getBoxedType(node.getType()).runtimeType()));
}
Program: 29399
Project: 29399
Buggy source:
@Override protected void visitHtmlAttributeValueNode(HtmlAttributeValueNode node){
  visitChildren(node);
  Quotes quotes=node.getQuotes();
  if (quotes == Quotes.NONE) {
    replacements.addAll(node.getChildren());
  }
 else {
    replacements.add(createPrefix(quotes.getQuotationCharacter(),node));
    replacements.addAll(node.getChildren());
    replacements.add(createSuffix(quotes.getQuotationCharacter(),node));
  }
}

Fixed version (ground truth):
@Override protected void visitHtmlAttributeValueNode(HtmlAttributeValueNode node){
  visitChildren(node);
  Quotes quotes=node.getQuotes();
  if (quotes == Quotes.NONE) {
    replacements.addAll(node.getChildren());
    needsSpaceSelfClosingTag=true;
  }
 else {
    replacements.add(createPrefix(quotes.getQuotationCharacter(),node));
    replacements.addAll(node.getChildren());
    replacements.add(createSuffix(quotes.getQuotationCharacter(),node));
    needsSpaceSelfClosingTag=false;
  }
}
Program: 29400
Project: 29400
Buggy source:
@Override protected void visitLetContentNode(LetContentNode node){
  boolean prev=needsSpaceForAttribute;
  needsSpaceForAttribute=false;
  visitChildren(node);
  needsSpaceForAttribute=prev;
}

Fixed version (ground truth):
@Override protected void visitLetContentNode(LetContentNode node){
  visitRenderUnitNode(node);
}
Program: 29401
Project: 29401
Buggy source:
@Override protected void visitCallParamContentNode(CallParamContentNode node){
  boolean oldInTag=needsSpaceForAttribute;
  needsSpaceForAttribute=false;
  visitChildren(node);
  needsSpaceForAttribute=oldInTag;
}

Fixed version (ground truth):
@Override protected void visitCallParamContentNode(CallParamContentNode node){
  visitRenderUnitNode(node);
}
Program: 29402
Project: 29402
Buggy source:
private void visitControlFlowBranches(List<? extends ParentSoyNode<?>> branches){
  boolean start=needsSpaceForAttribute;
  boolean end=needsSpaceForAttribute;
  for (  ParentSoyNode<?> branch : branches) {
    visitChildren(branch);
    end|=needsSpaceForAttribute;
    needsSpaceForAttribute=start;
  }
  needsSpaceForAttribute=end;
}

Fixed version (ground truth):
private void visitControlFlowBranches(List<? extends ParentSoyNode<?>> branches){
  boolean startNeedsSpaceForAttribute=needsSpaceForAttribute;
  boolean endNeedsSpaceForAttribute=needsSpaceForAttribute;
  boolean startNeedsSpaceForSelfClosingTag=needsSpaceSelfClosingTag;
  boolean endNeedsSpaceForSelfClosingTag=needsSpaceSelfClosingTag;
  for (  ParentSoyNode<?> branch : branches) {
    visitChildren(branch);
    endNeedsSpaceForAttribute|=needsSpaceForAttribute;
    needsSpaceForAttribute=startNeedsSpaceForAttribute;
    endNeedsSpaceForSelfClosingTag|=needsSpaceSelfClosingTag;
    needsSpaceSelfClosingTag=startNeedsSpaceForSelfClosingTag;
  }
  needsSpaceForAttribute=endNeedsSpaceForAttribute;
  needsSpaceSelfClosingTag=endNeedsSpaceForSelfClosingTag;
}
Program: 29403
Project: 29403
Buggy source:
@Override protected void visitHtmlOpenTagNode(HtmlOpenTagNode node){
  needsSpaceForAttribute=true;
  visitChildren(node);
  needsSpaceForAttribute=false;
  replacements.add(createPrefix("String_Node_Str",node));
  replacements.addAll(node.getChildren());
  replacements.add(createSuffix(node.isSelfClosing() ? "String_Node_Str" : "String_Node_Str",node));
}

Fixed version (ground truth):
@Override protected void visitHtmlOpenTagNode(HtmlOpenTagNode node){
  visitHtmlTagNode(node);
}
Program: 29404
Project: 29404
Buggy source:
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  needsSpaceForAttribute=true;
  visitChildren(node);
  needsSpaceForAttribute=false;
  replacements.add(createPrefix("String_Node_Str",node));
  replacements.addAll(node.getChildren());
  replacements.add(createSuffix("String_Node_Str",node));
}

Fixed version (ground truth):
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  visitHtmlTagNode(node);
}
Program: 29405
Project: 29405
Buggy source:
@Test public void testNoOpRewrites() throws Exception {
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testNoOpRewrites() throws Exception {
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
  assertNoOp("String_Node_Str");
}
Program: 29406
Project: 29406
Buggy source:
@Override protected void visitHtmlAttributeValueNode(HtmlAttributeValueNode node){
  context=context.transitionToState(HtmlContext.HTML_BEFORE_ATTRIBUTE_VALUE);
  Context.AttributeEndDelimiter delim;
switch (node.getQuotes()) {
case DOUBLE:
    delim=Context.AttributeEndDelimiter.DOUBLE_QUOTE;
  break;
case NONE:
delim=Context.AttributeEndDelimiter.SPACE_OR_TAG_END;
break;
case SINGLE:
delim=Context.AttributeEndDelimiter.SINGLE_QUOTE;
break;
default :
throw new AssertionError();
}
context=context.transitionToAttrValue(delim);
visitChildren(node);
}

Fixed version (ground truth):
@Override protected void visitHtmlAttributeValueNode(HtmlAttributeValueNode node){
  context=context.transitionToState(HtmlContext.HTML_BEFORE_ATTRIBUTE_VALUE);
  Context.AttributeEndDelimiter delim;
switch (node.getQuotes()) {
case DOUBLE:
    delim=Context.AttributeEndDelimiter.DOUBLE_QUOTE;
  break;
case NONE:
delim=Context.AttributeEndDelimiter.SPACE_OR_TAG_END;
break;
case SINGLE:
delim=Context.AttributeEndDelimiter.SINGLE_QUOTE;
break;
default :
throw new AssertionError();
}
context=context.transitionToAttrValue(delim);
visitChildren(node);
context=context.transitionToTagBody();
}
Program: 29407
Project: 29407
Buggy source:
private void assertContextualRewriting(String expectedOutput,String... inputs) throws SoyAutoescapeException {
  String source=rewrite(inputs).toSourceString();
  source=source.replace(nonce(),"String_Node_Str");
  assertThat(source.trim()).isEqualTo(expectedOutput);
}

Fixed version (ground truth):
private void assertContextualRewriting(String expectedOutput,String... inputs){
  String source=rewrite(inputs).toSourceString();
  source=source.replace(nonce(),"String_Node_Str");
  assertThat(source.trim()).isEqualTo(expectedOutput);
}
Program: 29408
Project: 29408
Buggy source:
/** 
 * Handles step 6 by converting a list of InjectedSoyGenerators into an equivalent list where there is only one per text node and offset, and where the list is sorted by text node ID and offset.
 */
private static ImmutableListMultimap<RawTextNode,InjectedSoyGenerator> sortAndGroup(List<InjectedSoyGenerator> ungrouped){
  ListMultimap<RawTextNode,InjectedSoyGenerator> byNode=MultimapBuilder.hashKeys().arrayListValues().build();
  for (  InjectedSoyGenerator generator : ungrouped) {
    byNode.put(generator.rawTextNode,generator);
  }
  ImmutableListMultimap.Builder<RawTextNode,InjectedSoyGenerator> groupedAndSorted=ImmutableListMultimap.builder();
  for (  RawTextNode node : byNode.keySet()) {
    List<InjectedSoyGenerator> group=BY_OFFSET.sortedCopy(byNode.get(node));
    for (int i=0, end; i < group.size(); i++) {
      InjectedSoyGenerator firstGroupMember=group.get(i);
      end=i + 1;
      while (end < group.size() && group.get(end).offset == firstGroupMember.offset) {
        ++end;
      }
      InjectedSoyGenerator groupGenerator=end == i + 1 ? firstGroupMember : new GroupOfInjectedSoyGenerator(group.subList(i,end));
      groupedAndSorted.put(node,groupGenerator);
    }
  }
  return groupedAndSorted.build();
}

Fixed version (ground truth):
/** 
 * Handles step 6 by converting a list of InjectedSoyGenerators into an equivalent list where there is only one per text node and offset, and where the list is sorted by text node ID and offset.
 */
private static ImmutableListMultimap<RawTextNode,InjectedSoyGenerator> sortAndGroup(List<InjectedSoyGenerator> ungrouped){
  ListMultimap<RawTextNode,InjectedSoyGenerator> byNode=MultimapBuilder.hashKeys().arrayListValues().build();
  for (  InjectedSoyGenerator generator : ungrouped) {
    byNode.put(generator.rawTextNode,generator);
  }
  ImmutableListMultimap.Builder<RawTextNode,InjectedSoyGenerator> groupedAndSorted=ImmutableListMultimap.builder();
  for (  RawTextNode node : byNode.keySet()) {
    List<InjectedSoyGenerator> group=BY_OFFSET.sortedCopy(byNode.get(node));
    for (int i=0; i < group.size(); ) {
      InjectedSoyGenerator firstGroupMember=group.get(i);
      int start=i;
      ++i;
      while (i < group.size() && group.get(i).offset == firstGroupMember.offset) {
        ++i;
      }
      InjectedSoyGenerator groupGenerator=i == start + 1 ? firstGroupMember : new GroupOfInjectedSoyGenerator(group.subList(start,i));
      groupedAndSorted.put(node,groupGenerator);
    }
  }
  return groupedAndSorted.build();
}
Program: 29409
Project: 29409
Buggy source:
/** 
 * Handles steps 3-5 by creating a NonceAttrGenerator for each location at the ^ in   {@code <scriptfoo=bar^>} immediately after the run of attributes in a script tag.
 */
private static void findNonceAttrLocations(Iterable<? extends SlicedRawTextNode> slicedRawTextNodes,ImmutableList.Builder<InjectedSoyGenerator> out){
  for (  SlicedRawTextNode.RawTextSlice slice : SlicedRawTextNode.find(slicedRawTextNodes,null,IN_SCRIPT_OR_STYLE_TAG_PREDICATE,IN_SCRIPT_OR_STYLE_BODY_PREDICATE)) {
    String rawText=slice.getRawText();
    int rawTextLen=rawText.length();
    if (rawText.charAt(rawTextLen - 1) != '>') {
      throw new IllegalStateException("String_Node_Str" + rawText);
    }
    int insertionPoint=rawTextLen - 1;
    if (insertionPoint - 1 >= 0 && rawText.charAt(insertionPoint - 1) == '/') {
      --insertionPoint;
    }
    out.add(new NonceAttrGenerator(slice.slicedRawTextNode.getRawTextNode(),slice.getStartOffset() + insertionPoint));
  }
}

Fixed version (ground truth):
/** 
 * Handles steps 3-5 by creating a NonceAttrGenerator for each location at the ^ in   {@code <scriptfoo=bar^>} immediately after the run of attributes in a script tag.
 */
private static void findNonceAttrLocations(Iterable<? extends SlicedRawTextNode> slicedRawTextNodes,ImmutableList.Builder<InjectedSoyGenerator> out){
  List<RawTextSlice> transitions=SlicedRawTextNode.find(slicedRawTextNodes,null,IN_SCRIPT_OR_STYLE_TAG_PREDICATE,IN_SCRIPT_OR_STYLE_BODY_PREDICATE);
  for (  SlicedRawTextNode.RawTextSlice slice : transitions) {
    String rawText=slice.getRawText();
    int rawTextLen=rawText.length();
    if (rawText.charAt(rawTextLen - 1) != '>') {
      throw new IllegalStateException("String_Node_Str" + rawText);
    }
    int insertionPoint=rawTextLen - 1;
    if (insertionPoint - 1 >= 0 && rawText.charAt(insertionPoint - 1) == '/') {
      --insertionPoint;
    }
    out.add(new NonceAttrGenerator(slice.getRawTextNode(),slice.getStartOffset() + insertionPoint));
  }
}
Program: 29410
Project: 29410
Buggy source:
/** 
 * The start offset (inclusive) into the text node's text. 
 */
public int getStartOffset(){
  return startOffset;
}

Fixed version (ground truth):
/** 
 * The start offset (inclusive) into the text node's text. 
 */
abstract int getStartOffset();
Program: 29411
Project: 29411
Buggy source:
/** 
 * The raw text of the slice. 
 */
public String getRawText(){
  return slicedRawTextNode.rawTextNode.getRawText().substring(startOffset,endOffset);
}

Fixed version (ground truth):
/** 
 * The raw text of the slice. 
 */
public String getRawText(){
  return getRawTextNode().getRawText().substring(getStartOffset(),getEndOffset());
}
Program: 29413
Project: 29413
Buggy source:
/** 
 * The length of the slice in   {@code char}s. 
 */
public int getLength(){
  return endOffset - startOffset;
}

Fixed version (ground truth):
/** 
 * The length of the slice in   {@code char}s. 
 */
public int getLength(){
  return getEndOffset() - getStartOffset();
}
Program: 29414
Project: 29414
Buggy source:
/** 
 * For debugging. 
 */
@Override public String toString(){
  String rawText=getRawText();
  int id=slicedRawTextNode.rawTextNode.getId();
  return "String_Node_Str" + rawText.replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str"+ id;
}

Fixed version (ground truth):
/** 
 * For debugging. 
 */
@Override public String toString(){
  String rawText=getRawText();
  int id=getRawTextNode().getId();
  return "String_Node_Str" + rawText.replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str"+ id;
}
Program: 29415
Project: 29415
Buggy source:
/** 
 * Called by the builder to add slices as their context becomes known.
 * @param startOffset an offset (inclusive) into the rawTextNode's string content.
 * @param endOffset an offset (exclusive) into the rawTextNode's string content.
 * @param context the context for the slice.
 */
void addSlice(int startOffset,int endOffset,Context context){
  int lastSliceIndex=slices.size() - 1;
  if (lastSliceIndex >= 0) {
    RawTextSlice last=slices.get(lastSliceIndex);
    if (last.endOffset == startOffset && context.equals(last.context)) {
      slices.remove(lastSliceIndex);
      startOffset=last.startOffset;
    }
  }
  slices.add(new RawTextSlice(context,this,startOffset,endOffset));
}

Fixed version (ground truth):
/** 
 * Called by the builder to add slices as their context becomes known.
 * @param startOffset an offset (inclusive) into the rawTextNode's string content.
 * @param endOffset an offset (exclusive) into the rawTextNode's string content.
 * @param context the context for the slice.
 */
void addSlice(int startOffset,int endOffset,Context context){
  int lastSliceIndex=slices.size() - 1;
  if (lastSliceIndex >= 0) {
    RawTextSlice last=slices.get(lastSliceIndex);
    if (last.getEndOffset() == startOffset && context.equals(last.getContext())) {
      slices.remove(lastSliceIndex);
      startOffset=last.getStartOffset();
    }
  }
  slices.add(RawTextSlice.create(context,rawTextNode,startOffset,endOffset));
}
Program: 29416
Project: 29416
Buggy source:
/** 
 * Scans until the next whitespace, > or />, validates that the matched text is an html identifier and returns it.
 */
@Nullable RawTextNode consumeHtmlIdentifier(){
  boolean foundDelimiter=advanceWhileMatches(TAG_IDENTIFIER_MATCHER);
  RawTextNode node=consumeAsRawText();
  if (node != null) {
    if (foundDelimiter && INVALID_IDENTIFIER_CHAR_MATCHER.matches((char)currentChar())) {
      errorReporter.report(currentLocation(),INVALID_IDENTIFIER,(char)currentChar());
      advance();
      consume();
    }
  }
 else {
    errorReporter.report(currentLocation(),GENERIC_UNEXPECTED_CHAR,"String_Node_Str");
    advance();
    consume();
  }
  return node;
}

Fixed version (ground truth):
/** 
 * Scans until the next whitespace, > or />, validates that the matched text is an html identifier and returns it. <p>Requires that we are not at the end of input
 */
@Nullable RawTextNode consumeHtmlIdentifier(SoyErrorKind errorForMissingIdentifier){
  boolean foundDelimiter=advanceWhileMatches(TAG_DELIMITER_MATCHER);
  RawTextNode node=consumeAsRawText();
  if (node != null) {
    int indexIn=INVALID_IDENTIFIER_CHAR_MATCHER.indexIn(node.getRawText());
    if (indexIn != -1) {
      errorReporter.report(node.substringLocation(indexIn,indexIn + 1),INVALID_IDENTIFIER,node.getRawText().charAt(indexIn));
    }
  }
 else   if (foundDelimiter) {
    errorReporter.report(currentLocation(),errorForMissingIdentifier);
    advance();
    consume();
  }
 else {
    throw new AssertionError("String_Node_Str");
  }
  return node;
}
Program: 29417
Project: 29417
Buggy source:
/** 
 * Handle the state where we are right before an attribute. <p>This state is kind of confusing, it just means we are in the middle of a tag and are definitely after some whitespace.
 */
void handleBeforeAttributeName(){
  if (tryCreateTagEnd()) {
    return;
  }
  if (consumeWhitespace()) {
    return;
  }
  RawTextNode identifier=consumeHtmlIdentifier();
  if (identifier == null) {
    context.resetAttribute();
    return;
  }
  context.startAttribute(identifier);
}

Fixed version (ground truth):
/** 
 * Handle the state where we are right before an attribute. <p>This state is kind of confusing, it just means we are in the middle of a tag and are definitely after some whitespace.
 */
void handleBeforeAttributeName(){
  if (tryCreateTagEnd()) {
    return;
  }
  if (consumeWhitespace()) {
    return;
  }
  RawTextNode identifier=consumeHtmlIdentifier(EXPECTED_ATTRIBUTE_NAME);
  if (identifier == null) {
    context.resetAttribute();
    return;
  }
  context.startAttribute(identifier);
}
Program: 29418
Project: 29418
Buggy source:
/** 
 * Handle parsing an html tag name. <p>Look for an html identifier and transition to AFTER_ATTRIBUTE_OR_TAG_NAME.
 */
void handleHtmlTagName(){
  if (consumeWhitespace()) {
    errorReporter.report(context.tagStartLocation(),UNEXPECTED_WS_AFTER_LT);
    context.reset();
    context.setState(State.PCDATA,currentPointOrEnd());
    return;
  }
  RawTextNode node=consumeHtmlIdentifier();
  if (node == null) {
    errorReporter.report(currentLocation(),GENERIC_UNEXPECTED_CHAR,"String_Node_Str");
    context.setTagName(new TagName(new RawTextNode(nodeIdGen.genId(),"String_Node_Str",currentLocation())));
  }
 else {
    context.setTagName(new TagName(node));
  }
}

Fixed version (ground truth):
/** 
 * Handle parsing an html tag name. <p>Look for an html identifier and transition to AFTER_ATTRIBUTE_OR_TAG_NAME.
 */
void handleHtmlTagName(){
  if (consumeWhitespace()) {
    errorReporter.report(context.tagStartLocation(),UNEXPECTED_WS_AFTER_LT);
    context.reset();
    context.setState(State.PCDATA,currentPointOrEnd());
    return;
  }
  RawTextNode node=consumeHtmlIdentifier(EXPECTED_TAG_NAME);
  if (node == null) {
    context.setTagName(new TagName(new RawTextNode(nodeIdGen.genId(),"String_Node_Str",currentLocation())));
  }
 else {
    context.setTagName(new TagName(node));
  }
}
Program: 29419
Project: 29419
Buggy source:
@Override protected void visitMsgFallbackGroupNode(MsgFallbackGroupNode node){
  processPrintableNode(node);
}

Fixed version (ground truth):
@Override protected void visitMsgFallbackGroupNode(MsgFallbackGroupNode node){
  processPrintableNode(node);
  State oldState=context.setState(State.NONE,node.getSourceLocation().getBeginPoint());
  visitChildren(node);
  context.setState(oldState,node.getSourceLocation().getEndPoint());
}
Program: 29420
Project: 29420
Buggy source:
/** 
 * Checks if all branches contain the given   {@TagName} at the head of their open stacks. 
 */
boolean hasCommonPrefix(TagName tag){
  if (!hasDefaultCond()) {
    return false;
  }
  for (  ConditionalBranch branch : branches) {
    if (branch.deque().isEmpty()) {
      return false;
    }
    HtmlTagEntry entry=branch.deque().peek();
    while (entry != null && entry.hasTagName() && !entry.getTagName().equals(tag) && entry.isDefinitelyOptional()) {
      branch.deque().poll();
      entry=branch.deque().peek();
    }
    if (entry.hasTagName()) {
      if (!entry.getTagName().equals(tag)) {
        return false;
      }
    }
 else {
      if (!entry.getBranches().hasCommonPrefix(tag)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks if all branches contain the given   {@TagName} at the head of their open stacks. 
 */
boolean hasCommonPrefix(TagName tag){
  if (!hasDefaultCond()) {
    return false;
  }
  for (  ConditionalBranch branch : branches) {
    if (branch.deque().isEmpty()) {
      return false;
    }
    HtmlTagEntry entry=branch.deque().peek();
    while (entry.hasTagName() && !entry.getTagName().equals(tag) && entry.isDefinitelyOptional()) {
      branch.deque().poll();
      entry=branch.deque().peek();
      if (entry == null) {
        return false;
      }
    }
    if (entry.hasTagName()) {
      if (!entry.getTagName().equals(tag)) {
        return false;
      }
    }
 else {
      if (!entry.getBranches().hasCommonPrefix(tag)) {
        return false;
      }
    }
  }
  return true;
}
Program: 29422
Project: 29422
Buggy source:
/** 
 * Consume a portion of text and compute the next context. Output is stored in member variables.
 * @param text Non empty.
 */
private void processNextToken(String text,Context context) throws SoyAutoescapeException {
  int earliestStart=Integer.MAX_VALUE;
  int earliestEnd=-1;
  Transition earliestTransition=null;
  Matcher earliestMatcher=null;
  for (  Transition transition : TRANSITIONS.get(context.state)) {
    Matcher matcher=transition.pattern.matcher(text);
    try {
      if (matcher.find()) {
        int start=matcher.start();
        if (start < earliestStart) {
          int end=matcher.end();
          if (transition.isApplicableTo(context,matcher)) {
            earliestStart=start;
            earliestEnd=end;
            earliestTransition=transition;
            earliestMatcher=matcher;
          }
        }
      }
    }
 catch (    StackOverflowError soe) {
      throw new RuntimeException("String_Node_Str" + transition.pattern,soe);
    }
  }
  if (earliestTransition != null) {
    this.next=earliestTransition.computeNextContext(context,earliestMatcher);
    this.numCharsConsumed=earliestEnd;
  }
 else {
    throw SoyAutoescapeException.createWithoutMetaInfo("String_Node_Str" + text + "String_Node_Str"+ context);
  }
  if (numCharsConsumed == 0 && this.next.state == context.state) {
    throw new IllegalStateException("String_Node_Str" + text + "String_Node_Str"+ context);
  }
}

Fixed version (ground truth):
/** 
 * Consume a portion of text and compute the next context. Output is stored in member variables.
 * @param text Non empty.
 */
private void processNextToken(String text,Context context) throws SoyAutoescapeException {
  int earliestStart=Integer.MAX_VALUE;
  int earliestEnd=-1;
  Transition earliestTransition=null;
  Matcher earliestMatcher=null;
  for (  Transition transition : TRANSITIONS.get(context.state)) {
    Matcher matcher=transition.pattern.matcher(text);
    try {
      while (matcher.find() && matcher.start() < earliestStart) {
        int start=matcher.start();
        int end=matcher.end();
        if (transition.isApplicableTo(context,matcher)) {
          earliestStart=start;
          earliestEnd=end;
          earliestTransition=transition;
          earliestMatcher=matcher;
          break;
        }
      }
    }
 catch (    StackOverflowError soe) {
      throw new RuntimeException("String_Node_Str" + transition.pattern,soe);
    }
  }
  if (earliestTransition != null) {
    this.next=earliestTransition.computeNextContext(context,earliestMatcher);
    this.numCharsConsumed=earliestEnd;
  }
 else {
    throw SoyAutoescapeException.createWithoutMetaInfo("String_Node_Str" + text + "String_Node_Str"+ context);
  }
  if (numCharsConsumed == 0 && this.next.state == context.state) {
    throw new IllegalStateException("String_Node_Str" + text + "String_Node_Str"+ context);
  }
}
Program: 29423
Project: 29423
Buggy source:
@Test public void testFakeScripts(){
  assertInjected(join("String_Node_Str","String_Node_Str","String_Node_Str" + NONCE + "String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),join("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):
@Test public void testFakeScripts(){
  assertInjected(join("String_Node_Str","String_Node_Str","String_Node_Str" + NONCE + "String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + NONCE + "String_Node_Str","String_Node_Str","String_Node_Str"),join("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: 29424
Project: 29424
Buggy source:
@Test public void testFakeScripts() throws Exception {
  assertInjected(join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),join("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):
@Test public void testFakeScripts() throws Exception {
  assertInjected(join("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"),join("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
}