nus-yam/ex-repair huggingface dataset:
Program: 29425
Project: 29425
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();
    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 != 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;
}
Program: 29427
Project: 29427
Buggy source:
/** 
 * Tries to find common prefix and report errors accordingly. 
 */
private static boolean tryMatchCommonPrefix(HtmlTagEntry openTag,HtmlTagEntry closeTag,ErrorReporter errorReporter){
  Preconditions.checkArgument(openTag.hasTagName() != closeTag.hasTagName());
  boolean matchCommonPrefix=false;
  if (openTag.hasTagName()) {
    TagName openTagName=openTag.getTagName();
    if (closeTag.getBranches().hasCommonPrefix(openTagName)) {
      closeTag.getBranches().popAllBranches();
      matchCommonPrefix=true;
      if (!closeTag.getBranches().isEmpty()) {
        matchCommonPrefix=false;
        errorReporter.report(closeTag.getSourceLocation(),UNEXPECTED_CLOSE_TAG_WITH_EXPECTATION,openTagName.getStaticTagNameAsLowerCase().get());
      }
    }
 else {
      errorReporter.report(openTagName.getTagLocation(),OPEN_TAG_NOT_CLOSED);
    }
  }
 else {
    TagName closeTagName=closeTag.getTagName();
    if (openTag.getBranches().hasCommonPrefix(closeTagName)) {
      openTag.getBranches().popAllBranches();
      matchCommonPrefix=true;
      if (!openTag.getBranches().isEmpty()) {
        matchCommonPrefix=false;
        errorReporter.report(openTag.getSourceLocation(),OPEN_TAG_NOT_CLOSED);
      }
    }
 else {
      errorReporter.report(closeTagName.getTagLocation(),UNEXPECTED_CLOSE_TAG);
    }
  }
  return matchCommonPrefix;
}

Fixed version (ground truth):
/** 
 * Tries to find common prefix and report errors accordingly. 
 */
private static boolean tryMatchCommonPrefix(HtmlTagEntry openTag,HtmlTagEntry closeTag,ErrorReporter errorReporter){
  Preconditions.checkArgument(openTag.hasTagName() != closeTag.hasTagName());
  return openTag.hasTagName() ? tryMatchCommonPrefix(openTag.getTagName(),closeTag,errorReporter) : tryMatchCommonPrefix(openTag,closeTag.getTagName(),errorReporter);
}
Program: 29428
Project: 29428
Buggy source:
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  TagName closeTag=node.getTagName();
  if (isDefinitelyVoid(node)) {
    errorReporter.report(node.getSourceLocation(),INVALID_CLOSE_TAG,closeTag.getStaticTagName().getRawText());
    return;
  }
  if (closeTag.isForeignContent()) {
    foreignContentEndLocation=node.getSourceLocation();
    inForeignContent=false;
  }
  HtmlTagEntry openTag=openTagStack.peekFirst();
  while (openTag != null && openTag.hasTagName() && !openTag.getTagName().equals(closeTag) && openTag.isDefinitelyOptional()) {
    openTagStack.pollFirst();
    openTag=openTagStack.peekFirst();
  }
  if (openTag != null && openTag.hasTagName()) {
    if (HtmlTagEntry.matchOrError(openTag.getTagName(),closeTag,errorReporter)) {
      openTagStack.pollFirst();
    }
  }
 else {
    closeTagQueue.addLast(new HtmlTagEntry(closeTag));
  }
}

Fixed version (ground truth):
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  TagName closeTag=node.getTagName();
  if (isDefinitelyVoid(node)) {
    errorReporter.report(node.getSourceLocation(),INVALID_CLOSE_TAG,closeTag.getStaticTagName().getRawText());
    return;
  }
  if (closeTag.isForeignContent()) {
    foreignContentEndLocation=node.getSourceLocation();
    inForeignContent=false;
  }
  if (!HtmlTagEntry.tryMatchCloseTag(openTagStack,closeTag,errorReporter)) {
    closeTagQueue.addLast(new HtmlTagEntry(closeTag));
  }
}
Program: 29429
Project: 29429
Buggy source:
/** 
 * Remove a common   {@code TagName} from all branches. Note that we assume that each branchcontains the  {@code TagName}. You will need to explicitly call   {@code hasCommonPrefix} beforecalling this method.
 */
void popAllBranches(){
  for (  ConditionalBranch branch : branches) {
    HtmlTagEntry entry=branch.deque().peek();
    if (entry.hasTagName()) {
      branch.deque().pop();
    }
 else {
      entry.getBranches().popAllBranches();
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove a common   {@code TagName} from all branches. Note that we assume that each branchcontains the  {@code TagName}. You will need to explicitly call   {@code hasCommonPrefix} beforecalling this method.
 */
void popAllBranches(){
  for (  ConditionalBranch branch : branches) {
    HtmlTagEntry entry=branch.deque().peek();
    if (entry.hasTagName()) {
      branch.deque().pop();
    }
 else {
      entry.getBranches().popAllBranches();
    }
  }
  removeEmptyDeque();
}
Program: 29431
Project: 29431
Buggy source:
/** 
 * A method that should be called after we visit a control flow node (  {@code IfNode} or {@code SwitchNode}). <p>Compared to   {@code matchOrError} methods, this method does not report an error when one ofthe deques is empty. However, if both deques are not empty but the top do not match, we should report an error.
 */
public static void tryMatchOrError(ArrayDeque<HtmlTagEntry> openStack,ArrayDeque<HtmlTagEntry> closeQueue,ErrorReporter errorReporter){
  while (!openStack.isEmpty() && !closeQueue.isEmpty()) {
    if (!matchOrError(openStack.pollFirst(),closeQueue.pollFirst(),errorReporter)) {
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 * A method that should be called after we visit a control flow node (  {@code IfNode} or {@code SwitchNode}). <p>Compared to   {@code matchOrError} methods, this method does not report an error when one ofthe deques is empty. However, if both deques are not empty but the top do not match, we should report an error. <p>Another difference is that we don't try to remove all optional tags from the openStack, if the closeQueue is empty. It is possible that some of the optional tags are ended in another control block, and we cannot remove them too eagerly.
 */
public static boolean tryMatchOrError(ArrayDeque<HtmlTagEntry> openStack,ArrayDeque<HtmlTagEntry> closeQueue,ErrorReporter errorReporter){
  while (!openStack.isEmpty() && !closeQueue.isEmpty()) {
    if (!closeQueue.peekFirst().isDefinitelyOptional() && openStack.peekFirst().isDefinitelyOptional()) {
      openStack.pollFirst();
      continue;
    }
    if (!matchOrError(openStack.pollFirst(),closeQueue.pollFirst(),errorReporter)) {
      return false;
    }
  }
  return true;
}
Program: 29433
Project: 29433
Buggy source:
/** 
 * A method that should be called after we visit a control flow node (  {@code IfNode} or {@code SwitchNode}). <p>Compared to   {@code matchOrError} methods, this method does not report an error when one ofthe deques is empty. However, if both deques are not empty but the top do not match, we should report an error. <p>Another difference is that we don't try to remove all optional tags from the openStack, if the closeQueue is empty. It is possible that some of the optional tags are ended in another control block, and we cannot remove them too eagerly.
 */
public static boolean tryMatchOrError(ArrayDeque<HtmlTagEntry> openStack,ArrayDeque<HtmlTagEntry> closeQueue,ErrorReporter errorReporter){
  while (!openStack.isEmpty() && !closeQueue.isEmpty()) {
    if (!closeQueue.peekFirst().isDefinitelyOptional() && openStack.peekFirst().isDefinitelyOptional()) {
      openStack.pollFirst();
      continue;
    }
    if (!matchOrError(openStack.pollFirst(),closeQueue.pollFirst(),errorReporter)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * A method that should be called after we visit a control flow node (  {@code IfNode} or {@code SwitchNode}). <p>Compared to   {@code matchOrError} methods, this method does not report an error when one ofthe deques is empty. However, if both deques are not empty but the top do not match, we should report an error. <p>Another difference is that we don't try to remove all optional tags from the openStack, if the closeQueue is empty. It is possible that some of the optional tags are ended in another control block, and we cannot remove them too eagerly.
 */
public static boolean tryMatchOrError(ArrayDeque<HtmlTagEntry> openStack,ArrayDeque<HtmlTagEntry> closeQueue,ErrorReporter errorReporter){
  while (!openStack.isEmpty() && !closeQueue.isEmpty()) {
    HtmlTagEntry openTag=openStack.peekFirst();
    HtmlTagEntry closeTag=closeQueue.peekFirst();
    if (closeTag.isDefinitelyOptional()) {
      if (closeTag.getTagName().equals(openTag.getTagName())) {
        openStack.pollFirst();
        closeQueue.pollFirst();
        continue;
      }
      if (!openTag.hasTagName()) {
        return tryMatchCommonPrefix(openTag,closeTag,errorReporter);
      }
    }
    if (closeTag.hasTagName()) {
      while (!openStack.isEmpty()) {
        openTag=openStack.peekFirst();
        if (openTag.isDefinitelyOptional()) {
          openStack.pollFirst();
          continue;
        }
 else         if (!openTag.hasTagName()) {
          openTag.getBranches().popOptionalTags();
          if (openTag.getBranches().isEmpty()) {
            openStack.pollFirst();
            continue;
          }
        }
        break;
      }
    }
    if (matchOrError(openTag,closeTag,errorReporter)) {
      openStack.pollFirst();
      closeQueue.pollFirst();
    }
 else {
      return false;
    }
  }
  return true;
}
Program: 29435
Project: 29435
Buggy source:
@Override protected void visitTemplateNode(TemplateNode node){
  Checkpoint checkpoint=errorReporter.checkpoint();
  visitChildren(node);
  if (errorReporter.errorsSince(checkpoint)) {
    return;
  }
  matchTagsInDeques();
}

Fixed version (ground truth):
@Override protected void visitTemplateNode(TemplateNode node){
  Checkpoint checkpoint=errorReporter.checkpoint();
  visitChildren(node);
  if (errorReporter.errorsSince(checkpoint)) {
    return;
  }
  HtmlTagEntry.matchOrError(openTagStack,closeTagQueue,errorReporter);
}
Program: 29436
Project: 29436
Buggy source:
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  TagName closeTag=node.getTagName();
  if (isDefinitelyVoid(node)) {
    errorReporter.report(node.getSourceLocation(),INVALID_CLOSE_TAG,closeTag.getStaticTagName().getRawText());
    return;
  }
  if (closeTag.isForeignContent()) {
    foreignContentEndLocation=node.getSourceLocation();
    inForeignContent=false;
  }
  if (!closeTag.isDefinitelyOptional()) {
    popOptionalTags(false);
  }
  if (!openTagStack.isEmpty() && openTagStack.peekFirst().hasTagName()) {
    TagName openTag=openTagStack.peekFirst().getTagName();
    if (HtmlTagEntry.matchOrError(openTag,closeTag,errorReporter)) {
      openTagStack.pollFirst();
    }
  }
 else {
    closeTagQueue.addLast(new HtmlTagEntry(closeTag));
  }
}

Fixed version (ground truth):
@Override protected void visitHtmlCloseTagNode(HtmlCloseTagNode node){
  TagName closeTag=node.getTagName();
  if (isDefinitelyVoid(node)) {
    errorReporter.report(node.getSourceLocation(),INVALID_CLOSE_TAG,closeTag.getStaticTagName().getRawText());
    return;
  }
  if (closeTag.isForeignContent()) {
    foreignContentEndLocation=node.getSourceLocation();
    inForeignContent=false;
  }
  HtmlTagEntry openTag=openTagStack.peekFirst();
  while (openTag != null && openTag.hasTagName() && !openTag.getTagName().equals(closeTag) && openTag.isDefinitelyOptional()) {
    openTagStack.pollFirst();
    openTag=openTagStack.peekFirst();
  }
  if (openTag != null && openTag.hasTagName()) {
    if (HtmlTagEntry.matchOrError(openTag.getTagName(),closeTag,errorReporter)) {
      openTagStack.pollFirst();
    }
  }
 else {
    closeTagQueue.addLast(new HtmlTagEntry(closeTag));
  }
}
Program: 29437
Project: 29437
Buggy source:
/** 
 * Called to handle whitespace that was completely removed from a raw text node. 
 */
void handleJoinedWhitespace(SourceLocation.Point point,boolean atEndOfBlock){
switch (context.getState()) {
case UNQUOTED_ATTRIBUTE_VALUE:
    context.createUnquotedAttributeValue(point);
case AFTER_TAG_NAME_OR_ATTRIBUTE:
  context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
case AFTER_ATTRIBUTE_NAME:
if (atEndOfBlock) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
}
case BEFORE_ATTRIBUTE_VALUE:
case BEFORE_ATTRIBUTE_NAME:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
case HTML_COMMENT:
case CDATA:
case NONE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
return;
}
throw new AssertionError();
}

Fixed version (ground truth):
/** 
 * Called to handle whitespace that was completely removed from a raw text node. 
 */
void handleJoinedWhitespace(SourceLocation.Point point){
switch (context.getState()) {
case UNQUOTED_ATTRIBUTE_VALUE:
    context.createUnquotedAttributeValue(point);
case AFTER_TAG_NAME_OR_ATTRIBUTE:
  context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
case AFTER_ATTRIBUTE_NAME:
int currentChar=currentChar();
if (currentChar == -1 || (!CharMatcher.whitespace().matches((char)currentChar) && '=' != (char)currentChar)) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
}
case BEFORE_ATTRIBUTE_VALUE:
case BEFORE_ATTRIBUTE_NAME:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
case HTML_COMMENT:
case CDATA:
case NONE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
return;
}
throw new AssertionError();
}
Program: 29439
Project: 29439
Buggy source:
/** 
 * Scans until the next whitespace, > or />, validates that the matched text is an html identifier and returns it.
 */
@Nullable RawTextNode consumeHtmlIdentifier(){
  advanceWhileMatches(TAG_RAW_TEXT_MATCHER);
  RawTextNode node=consumeAsRawText();
  if (node != null) {
    int invalidChar=indexOfInvalidNameCharacter(node.getRawText());
    if (invalidChar != -1) {
      errorReporter.report(node.substringLocation(invalidChar,invalidChar + 1),INVALID_IDENTIFIER,node.getRawText().charAt(invalidChar));
    }
  }
 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.
 */
@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;
}
Program: 29441
Project: 29441
Buggy source:
void maybeFinishPendingAttribute(SourceLocation.Point currentPoint){
  if (hasUnquotedAttributeValueParts()) {
    createUnquotedAttributeValue(currentPoint);
  }
 else   if (hasQuotedAttributeValueParts()) {
    errorReporter.report(currentPoint.asLocation(filePath),FOUND_END_OF_ATTRIBUTE_STARTED_IN_ANOTHER_BLOCK);
    throw new AbortParsingBlockError();
  }
  if (attributeName != null) {
    createAttributeNode();
  }
}

Fixed version (ground truth):
void maybeFinishPendingAttribute(SourceLocation.Point currentPoint){
  if (hasUnquotedAttributeValueParts()) {
    createUnquotedAttributeValue(currentPoint);
  }
 else   if (hasQuotedAttributeValueParts()) {
    errorReporter.report(currentPoint.asLocation(filePath),FOUND_END_OF_ATTRIBUTE_STARTED_IN_ANOTHER_BLOCK);
    throw new AbortParsingBlockError();
  }
  if (attributeName != null) {
    SourceLocation location=attributeName.getSourceLocation();
    HtmlAttributeNode attribute;
    if (attributeValue != null) {
      attribute=new HtmlAttributeNode(nodeIdGen.genId(),location,checkNotNull(equalsSignLocation));
      location=location.extend(attributeValue.getSourceLocation());
      edits.addChild(attribute,attributeName);
      edits.addChild(attribute,attributeValue);
    }
 else {
      attribute=new HtmlAttributeNode(nodeIdGen.genId(),location,null);
      edits.addChild(attribute,attributeName);
    }
    attributeName=null;
    equalsSignLocation=null;
    attributeValue=null;
    directTagChildren.add(attribute);
    edits.remove(attribute);
  }
}
Program: 29442
Project: 29442
Buggy source:
/** 
 * Called to handle whitespace that was completely removed from a raw text node. 
 */
void handleJoinedWhitespace(SourceLocation.Point point,boolean atEndOfBlock){
switch (context.getState()) {
case UNQUOTED_ATTRIBUTE_VALUE:
    context.createUnquotedAttributeValue(point);
  return;
case AFTER_TAG_NAME_OR_ATTRIBUTE:
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
case AFTER_ATTRIBUTE_NAME:
if (atEndOfBlock) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
}
case BEFORE_ATTRIBUTE_VALUE:
case BEFORE_ATTRIBUTE_NAME:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
case HTML_COMMENT:
case CDATA:
case NONE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
return;
}
throw new AssertionError();
}

Fixed version (ground truth):
/** 
 * Called to handle whitespace that was completely removed from a raw text node. 
 */
void handleJoinedWhitespace(SourceLocation.Point point,boolean atEndOfBlock){
switch (context.getState()) {
case UNQUOTED_ATTRIBUTE_VALUE:
    context.createUnquotedAttributeValue(point);
case AFTER_TAG_NAME_OR_ATTRIBUTE:
  context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
case AFTER_ATTRIBUTE_NAME:
if (atEndOfBlock) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
}
case BEFORE_ATTRIBUTE_VALUE:
case BEFORE_ATTRIBUTE_NAME:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
case HTML_COMMENT:
case CDATA:
case NONE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
return;
}
throw new AssertionError();
}
Program: 29443
Project: 29443
Buggy source:
/** 
 * Applies the given print directive to   {@code expr} and returns the result.
 * @param generator The CodeChunk generator to use.
 * @param expr The expression to apply the print directive to.
 * @param directive The print directive to apply.
 * @param args Print directive args, if any.
 */
public static CodeChunk.WithValue applyDirective(CodeChunk.Generator generator,CodeChunk.WithValue expr,SoyJsSrcPrintDirective directive,List<CodeChunk.WithValue> args){
  List<JsExpr> argExprs=Lists.transform(args,TO_JS_EXPR);
  JsExpr applied=directive.applyForJsSrc(expr.singleExprOrName(),argExprs);
  RequiresCollector.IntoImmutableSet collector=new RequiresCollector.IntoImmutableSet();
  expr.collectRequires(collector);
  boolean isSingleExpr=expr.isRepresentableAsSingleExpression();
  for (  CodeChunk.WithValue arg : args) {
    arg.collectRequires(collector);
    if (!arg.isRepresentableAsSingleExpression()) {
      isSingleExpr=false;
      break;
    }
  }
  if (directive instanceof SoyLibraryAssistedJsSrcPrintDirective) {
    for (    String name : ((SoyLibraryAssistedJsSrcPrintDirective)directive).getRequiredJsLibNames()) {
      collector.add(GoogRequire.create(name));
    }
  }
  return isSingleExpr ? fromExpr(applied,collector.get()) : generator.newChunk().statement(expr).statements(args).assign(fromExpr(applied,collector.get())).buildAsValue();
}

Fixed version (ground truth):
/** 
 * Applies the given print directive to   {@code expr} and returns the result.
 * @param generator The CodeChunk generator to use.
 * @param expr The expression to apply the print directive to.
 * @param directive The print directive to apply.
 * @param args Print directive args, if any.
 */
public static CodeChunk.WithValue applyDirective(CodeChunk.Generator generator,CodeChunk.WithValue expr,SoyJsSrcPrintDirective directive,List<CodeChunk.WithValue> args){
  List<JsExpr> argExprs=Lists.transform(args,TO_JS_EXPR);
  JsExpr applied=directive.applyForJsSrc(expr.singleExprOrName(),argExprs);
  RequiresCollector.IntoImmutableSet collector=new RequiresCollector.IntoImmutableSet();
  expr.collectRequires(collector);
  boolean isSingleExpr=expr.isRepresentableAsSingleExpression();
  for (  CodeChunk.WithValue arg : args) {
    arg.collectRequires(collector);
    if (!arg.isRepresentableAsSingleExpression()) {
      isSingleExpr=false;
    }
  }
  if (directive instanceof SoyLibraryAssistedJsSrcPrintDirective) {
    for (    String name : ((SoyLibraryAssistedJsSrcPrintDirective)directive).getRequiredJsLibNames()) {
      collector.add(GoogRequire.create(name));
    }
  }
  return isSingleExpr ? fromExpr(applied,collector.get()) : generator.newChunk().statement(expr).statements(args).assign(fromExpr(applied,collector.get())).buildAsValue();
}
Program: 29445
Project: 29445
Buggy source:
/** 
 * Eats all whitespace from the input prefix. Returns   {@code true} if we matched any whitespacecharacters.
 */
boolean consumeWhitespace(){
  int startIndex=currentRawTextIndex;
  advanceWhileMatches(CharMatcher.whitespace());
  consume();
  return currentRawTextIndex != startIndex;
}

Fixed version (ground truth):
/** 
 * Eats all whitespace from the input prefix. Returns   {@code true} if we matched any whitespacecharacters.
 */
boolean consumeWhitespace(){
  int startIndex=currentRawTextIndex;
  advanceWhileMatches(CharMatcher.whitespace());
  consume();
  edits.remove(currentRawTextNode);
  return currentRawTextIndex != startIndex;
}
Program: 29446
Project: 29446
Buggy source:
@VisibleForTesting public HtmlRewritePass(ImmutableList<String> experimentalFeatures,ErrorReporter errorReporter){
  this.enabled=experimentalFeatures.contains("String_Node_Str");
  this.errorReporter=errorReporter;
}

Fixed version (ground truth):
public HtmlRewritePass(ImmutableList<String> experimentalFeatures,ErrorReporter errorReporter){
  this.enabled=experimentalFeatures.contains("String_Node_Str");
  this.errorReporter=errorReporter;
}
Program: 29447
Project: 29447
Buggy source:
/** 
 * Apply all edits. 
 */
void apply(){
  for (  StandaloneNode nodeToRemove : toRemove) {
    BlockNode parent=nodeToRemove.getParent();
    List<StandaloneNode> children=replacements.get(nodeToRemove);
    if (!children.isEmpty()) {
      parent.addChildren(parent.getChildIndex(nodeToRemove),children);
    }
    parent.removeChild(nodeToRemove);
  }
  for (  Map.Entry<BlockNode,List<StandaloneNode>> entry : asMap(newChildren).entrySet()) {
    entry.getKey().addChildren(entry.getValue());
  }
  clear();
}

Fixed version (ground truth):
/** 
 * Apply all edits. 
 */
void apply(){
  for (  StandaloneNode nodeToRemove : toRemove) {
    BlockNode parent=nodeToRemove.getParent();
    int index=parent.getChildIndex(nodeToRemove);
    parent.removeChild(index);
    List<StandaloneNode> children=replacements.get(nodeToRemove);
    if (!children.isEmpty()) {
      parent.addChildren(index,children);
    }
  }
  for (  Map.Entry<BlockNode,List<StandaloneNode>> entry : asMap(newChildren).entrySet()) {
    entry.getKey().addChildren(entry.getValue());
  }
  clear();
}
Program: 29448
Project: 29448
Buggy source:
@Test public void testConditionalQuotedAttributeValues(){
  TemplateNode node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  assertThatASTString(node).isEqualTo("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");
  node=runPass("String_Node_Str" + "String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str" + "String_Node_Str");
  assertThatASTString(node).isEqualTo("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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
@Test public void testConditionalQuotedAttributeValues(){
  TemplateNode node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  assertThatASTString(node).isEqualTo("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");
  node=runPass("String_Node_Str" + "String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str" + "String_Node_Str");
  assertThatASTString(node).isEqualTo("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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 29449
Project: 29449
Buggy source:
/** 
 * Handle immediately after an attribute name. <p>Look for an '=' sign to signal the presence of an attribute value
 */
void handleAfterAttributeName(){
  boolean ws=consumeWhitespace();
  int current=currentChar();
  if (current == '=') {
    SourceLocation.Point equalsSignPoint=currentPoint();
    advance();
    consume();
    consumeWhitespace();
    context.setEqualsSignLocation(equalsSignPoint,currentPointOrEnd());
  }
 else {
    context.createAttributeNode();
    if (ws) {
      context.setState(State.BEFORE_ATTRIBUTE_NAME,currentPointOrEnd());
    }
  }
}

Fixed version (ground truth):
/** 
 * Handle immediately after an attribute name. <p>Look for an '=' sign to signal the presence of an attribute value
 */
void handleAfterAttributeName(){
  boolean ws=consumeWhitespace();
  int current=currentChar();
  if (current == '=') {
    SourceLocation.Point equalsSignPoint=currentPoint();
    advance();
    consume();
    consumeWhitespace();
    context.setEqualsSignLocation(equalsSignPoint,currentPointOrEnd());
  }
 else {
    context.setState(ws ? State.BEFORE_ATTRIBUTE_NAME : State.AFTER_TAG_NAME_OR_ATTRIBUTE,currentPointOrEnd());
  }
}
Program: 29450
Project: 29450
Buggy source:
/** 
 * Handle immediately before an attribute value. <p>Look for a quote character to signal the beginning of a quoted attribute value or switch to UNQUOTED_ATTRIBUTE_VALUE to handle that.
 */
void handleBeforeAttributeValue(){
  int c=currentChar();
  if (c == '\'' || c == '"') {
    SourceLocation.Point quotePoint=currentPoint();
    context.startQuotedAttributeValue(currentRawTextNode,quotePoint,c == '"' ? State.DOUBLE_QUOTED_ATTRIBUTE_VALUE : State.SINGLE_QUOTED_ATTRIBUTE_VALUE);
    advance();
    consume();
  }
 else {
    context.setState(State.UNQUOTED_ATTRIBUTE_VALUE,currentPoint());
  }
}

Fixed version (ground truth):
/** 
 * Handle immediately before an attribute value. <p>Look for a quote character to signal the beginning of a quoted attribute value or switch to UNQUOTED_ATTRIBUTE_VALUE to handle that.
 */
void handleBeforeAttributeValue(){
  boolean ws=consumeWhitespace();
  if (ws) {
    return;
  }
  int c=currentChar();
  if (c == '\'' || c == '"') {
    SourceLocation.Point quotePoint=currentPoint();
    context.startQuotedAttributeValue(currentRawTextNode,quotePoint,c == '"' ? State.DOUBLE_QUOTED_ATTRIBUTE_VALUE : State.SINGLE_QUOTED_ATTRIBUTE_VALUE);
    advance();
    consume();
  }
 else {
    context.setState(State.UNQUOTED_ATTRIBUTE_VALUE,currentPoint());
  }
}
Program: 29451
Project: 29451
Buggy source:
/** 
 * Called to handle whitespace that was completely removed from a raw text node. 
 */
void handleJoinedWhitespace(SourceLocation.Point point){
switch (context.getState()) {
case UNQUOTED_ATTRIBUTE_VALUE:
    context.createUnquotedAttributeValue(point);
  return;
case AFTER_TAG_NAME_OR_ATTRIBUTE:
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
case BEFORE_ATTRIBUTE_VALUE:
case BEFORE_ATTRIBUTE_NAME:
case AFTER_ATTRIBUTE_NAME:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
case HTML_COMMENT:
case CDATA:
case NONE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
return;
}
throw new AssertionError();
}

Fixed version (ground truth):
/** 
 * Called to handle whitespace that was completely removed from a raw text node. 
 */
void handleJoinedWhitespace(SourceLocation.Point point,boolean atEndOfBlock){
switch (context.getState()) {
case UNQUOTED_ATTRIBUTE_VALUE:
    context.createUnquotedAttributeValue(point);
  return;
case AFTER_TAG_NAME_OR_ATTRIBUTE:
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
case AFTER_ATTRIBUTE_NAME:
if (atEndOfBlock) {
context.setState(State.BEFORE_ATTRIBUTE_NAME,point);
return;
}
case BEFORE_ATTRIBUTE_VALUE:
case BEFORE_ATTRIBUTE_NAME:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
case HTML_COMMENT:
case CDATA:
case NONE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
return;
}
throw new AssertionError();
}
Program: 29452
Project: 29452
Buggy source:
/** 
 * Handle unquoted attribute values. <p>Search for whitespace or the end of the tag as a delimiter.
 */
void handleUnquotedAttributeValue(){
  boolean foundDelimiter=advanceWhileMatches(TAG_RAW_TEXT_MATCHER);
  RawTextNode node=consumeAsRawText();
  if (node != null) {
    int badCharIndex=BAD_UNQUOTED_ATTRIBUTE_CHARACTER_MATCHER.indexIn(node.getRawText());
    if (badCharIndex != -1) {
      errorReporter.report(node.substringLocation(badCharIndex,badCharIndex + 1),ILLEGAL_HTML_ATTRIBUTE_CHARACTER);
    }
    context.addAttributeValuePart(node);
  }
  if (foundDelimiter) {
    context.createUnquotedAttributeValue(currentPoint());
  }
}

Fixed version (ground truth):
/** 
 * Handle unquoted attribute values. <p>Search for whitespace or the end of the tag as a delimiter.
 */
void handleUnquotedAttributeValue(){
  boolean foundDelimiter=advanceWhileMatches(UNQUOTED_ATTRIBUTE_VALUE_MATCHER);
  RawTextNode node=consumeAsRawText();
  if (node != null) {
    context.addAttributeValuePart(node);
  }
  if (foundDelimiter) {
    context.createUnquotedAttributeValue(currentPoint());
    char c=(char)currentChar();
    if (!UNQUOTED_ATTRIBUTE_VALUE_DELIMITER.matches(c)) {
      errorReporter.report(currentLocation(),ILLEGAL_HTML_ATTRIBUTE_CHARACTER);
      advance();
      consume();
    }
  }
}
Program: 29453
Project: 29453
Buggy source:
/** 
 * Handle   {@link State#XML_DECLARATION}. <p>This is for things like   {@code <!DOCTYPE HTML PUBLIC"http://www.w3.org/TR/html4/strict.dtd">}. . We are looking for the end or a quoted 'attribute'.
 */
void handleXmlDeclaration(){
  boolean foundDelimiter=advanceWhileMatches(XML_DECLARATION_NON_DELIMITERS);
  if (foundDelimiter) {
    int c=currentChar();
    advance();
    if (c == '"') {
      context.setState(State.DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE,currentPoint());
    }
 else     if (c == '\'') {
      context.setState(State.SINGLE_QUOTED_XML_ATTRIBUTE_VALUE,currentPoint());
    }
 else     if (c == '>') {
      context.setState(State.PCDATA,currentPoint());
    }
 else {
      throw new AssertionError("String_Node_Str" + c);
    }
  }
}

Fixed version (ground truth):
/** 
 * Handle   {@link State#XML_DECLARATION}. <p>This is for things like   {@code <!DOCTYPE HTML PUBLIC"http://www.w3.org/TR/html4/strict.dtd">}. . We are looking for the end or a quoted 'attribute'.
 */
void handleXmlDeclaration(){
  boolean foundDelimiter=advanceWhileMatches(XML_DECLARATION_NON_DELIMITERS);
  if (foundDelimiter) {
    int c=currentChar();
    SourceLocation.Point currentPoint=currentPoint();
    advance();
    if (c == '"') {
      context.setState(State.DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE,currentPoint);
    }
 else     if (c == '\'') {
      context.setState(State.SINGLE_QUOTED_XML_ATTRIBUTE_VALUE,currentPoint);
    }
 else     if (c == '>') {
      context.setState(State.PCDATA,currentPoint);
    }
 else {
      throw new AssertionError("String_Node_Str" + c);
    }
  }
}
Program: 29455
Project: 29455
Buggy source:
@Test public void testAttributes(){
  TemplateNode node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  String structure="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertThatASTString(node).isEqualTo(structure);
  node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  assertThatASTString(node).isEqualTo(structure);
  node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  assertThatASTString(node).isEqualTo(structure);
}

Fixed version (ground truth):
@Test public void testAttributes(){
  TemplateNode node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  String structure="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertThatASTString(node).isEqualTo(structure);
  node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  assertThatASTString(node).isEqualTo(structure);
  node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  assertThatASTString(node).isEqualTo(structure);
  node=runPass("String_Node_Str");
  assertThatSourceString(node).isEqualTo("String_Node_Str");
  HtmlOpenTagNode openTag=(HtmlOpenTagNode)node.getChild(1);
  assertThat(openTag.isSelfClosing()).isFalse();
  HtmlAttributeValueNode attributeValue=(HtmlAttributeValueNode)((HtmlAttributeNode)openTag.getChild(0)).getChild(1);
  assertThat(attributeValue.getQuotes()).isEqualTo(HtmlAttributeValueNode.Quotes.NONE);
  assertThat(((RawTextNode)attributeValue.getChild(0)).getRawText()).isEqualTo("String_Node_Str");
}
Program: 29457
Project: 29457
Buggy source:
/** 
 * Returns true if this switch has a   {@code default} case. 
 */
public boolean hasDefaultCase(){
  return getChild(numChildren() - 1) instanceof SwitchDefaultNode;
}

Fixed version (ground truth):
/** 
 * Returns true if this switch has a   {@code default} case. 
 */
public boolean hasDefaultCase(){
  return numChildren() > 0 && getChild(numChildren() - 1) instanceof SwitchDefaultNode;
}
Program: 29458
Project: 29458
Buggy source:
void setAttributeValue(StandaloneNode node){
  checkNotNull(node);
  checkState(attributeValue == null);
  edits.remove(node);
  attributeValue=node;
  setState(State.AFTER_TAG_NAME_OR_ATTRIBUTE,node.getSourceLocation().getEndPoint());
}

Fixed version (ground truth):
void setAttributeValue(StandaloneNode node){
  checkNotNull(node);
  checkState(attributeValue == null,"String_Node_Str",node.getSourceLocation());
  edits.remove(node);
  attributeValue=node;
  setState(State.AFTER_TAG_NAME_OR_ATTRIBUTE,node.getSourceLocation().getEndPoint());
}
Program: 29459
Project: 29459
Buggy source:
/** 
 * Resets parsing state, this is useful for error recovery. 
 */
void reset(){
  tagStartPoint=null;
  tagStartNode=null;
  tagName=null;
  directTagChildren.clear();
  resetAttribute();
  resetAttributeValue();
}

Fixed version (ground truth):
/** 
 * Resets all parsing state, this is useful for error recovery. 
 */
void reset(){
  tagStartPoint=null;
  tagStartNode=null;
  tagName=null;
  directTagChildren.clear();
  resetAttribute();
}
Program: 29460
Project: 29460
Buggy source:
void setEqualsSignLocation(SourceLocation.Point equalsSignPoint,SourceLocation.Point stateTransitionPoint){
  checkNotNull(equalsSignPoint);
  checkState(attributeName != null);
  checkState(equalsSignLocation == null);
  equalsSignLocation=equalsSignPoint;
  setState(State.BEFORE_ATTRIBUTE_VALUE,stateTransitionPoint);
}

Fixed version (ground truth):
void setEqualsSignLocation(SourceLocation.Point equalsSignPoint,SourceLocation.Point stateTransitionPoint){
  checkNotNull(equalsSignPoint);
  if (attributeName == null) {
    errorReporter.report(stateTransitionPoint.asLocation(filePath),FOUND_EQ_WITH_ATTRIBUTE_IN_ANOTHER_BLOCK);
    throw new AbortParsingBlockError();
  }
  checkState(equalsSignLocation == null);
  equalsSignLocation=equalsSignPoint;
  setState(State.BEFORE_ATTRIBUTE_VALUE,stateTransitionPoint);
}
Program: 29461
Project: 29461
Buggy source:
/** 
 * Visits a block and returns the finalState. 
 */
State visitBlock(State startState,BlockNode node,String blockName,Checkpoint checkpoint){
  visitChildren(node);
  context.finishBlock();
  State finalState=context.getState();
  SourceLocation.Point finalStateTransitionPoint=context.getStateTransitionPoint();
  if (finalState.isInvalidForEndOfBlock()) {
    errorReporter.report(node.getSourceLocation(),BLOCK_ENDS_IN_INVALID_STATE,blockName,finalState);
    finalState=startState;
  }
  if (!errorReporter.errorsSince(checkpoint)) {
    State reconciled=startState.reconcile(finalState);
    if (reconciled == null) {
      String suggestion=reconciliationFailureHint(startState,finalState);
      errorReporter.report(finalStateTransitionPoint.asLocation(filePath),BLOCK_CHANGES_CONTEXT,blockName,startState,finalState,suggestion != null ? "String_Node_Str" + suggestion : "String_Node_Str");
    }
 else {
      finalState=reconciled;
      reparentNodes(node,context,finalState);
    }
  }
 else {
    finalState=startState;
  }
  context.setState(finalState,node.getSourceLocation().getEndPoint());
  return finalState;
}

Fixed version (ground truth):
/** 
 * Visits a block and returns the finalState. 
 */
State visitBlock(State startState,BlockNode node,String blockName,Checkpoint checkpoint){
  try {
    visitChildren(node);
  }
 catch (  AbortParsingBlockError abortProcessingError) {
switch (startState) {
case AFTER_ATTRIBUTE_NAME:
case AFTER_TAG_NAME_OR_ATTRIBUTE:
case BEFORE_ATTRIBUTE_NAME:
case BEFORE_ATTRIBUTE_VALUE:
case SINGLE_QUOTED_ATTRIBUTE_VALUE:
case DOUBLE_QUOTED_ATTRIBUTE_VALUE:
case UNQUOTED_ATTRIBUTE_VALUE:
case HTML_TAG_NAME:
      context.resetAttribute();
    context.setState(State.BEFORE_ATTRIBUTE_NAME,node.getSourceLocation().getEndPoint());
  break;
case CDATA:
case DOUBLE_QUOTED_XML_ATTRIBUTE_VALUE:
case HTML_COMMENT:
case NONE:
case PCDATA:
case RCDATA_SCRIPT:
case RCDATA_STYLE:
case RCDATA_TEXTAREA:
case RCDATA_TITLE:
case SINGLE_QUOTED_XML_ATTRIBUTE_VALUE:
case XML_DECLARATION:
context.reset();
context.setState(startState,node.getSourceLocation().getEndPoint());
break;
}
}
context.finishBlock();
State finalState=context.getState();
SourceLocation.Point finalStateTransitionPoint=context.getStateTransitionPoint();
if (finalState.isInvalidForEndOfBlock()) {
errorReporter.report(node.getSourceLocation(),BLOCK_ENDS_IN_INVALID_STATE,blockName,finalState);
finalState=startState;
}
if (!errorReporter.errorsSince(checkpoint)) {
State reconciled=startState.reconcile(finalState);
if (reconciled == null) {
String suggestion=reconciliationFailureHint(startState,finalState);
errorReporter.report(finalStateTransitionPoint.asLocation(filePath),BLOCK_CHANGES_CONTEXT,blockName,startState,finalState,suggestion != null ? "String_Node_Str" + suggestion : "String_Node_Str");
}
 else {
finalState=reconciled;
reparentNodes(node,context,finalState);
}
}
 else {
finalState=startState;
}
context.setState(finalState,node.getSourceLocation().getEndPoint());
return finalState;
}
Program: 29462
Project: 29462
Buggy source:
/** 
 * Attempts to finish the current tag, returns true if it did. 
 */
boolean tryCreateTagEnd(){
  int c=currentChar();
  if (c == '>') {
    if (context.hasTagStart()) {
      SourceLocation.Point point=currentPoint();
      context.setState(context.createTag(currentRawTextNode,false,point),point);
    }
 else {
      context.reset();
      errorReporter.report(currentLocation(),FOUND_END_TAG_STARTED_IN_ANOTHER_BLOCK);
    }
    advance();
    consume();
    return true;
  }
 else   if (matchPrefix("String_Node_Str",false)) {
    advance();
    if (context.hasTagStart()) {
      SourceLocation.Point point=currentPoint();
      context.setState(context.createTag(currentRawTextNode,true,point),point);
    }
 else {
      context.reset();
      errorReporter.report(currentLocation(),FOUND_END_TAG_STARTED_IN_ANOTHER_BLOCK);
    }
    advance();
    consume();
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Attempts to finish the current tag, returns true if it did. 
 */
boolean tryCreateTagEnd(){
  int c=currentChar();
  if (c == '>') {
    if (context.hasTagStart()) {
      SourceLocation.Point point=currentPoint();
      context.setState(context.createTag(currentRawTextNode,false,point),point);
    }
 else {
      errorReporter.report(currentLocation(),FOUND_END_TAG_STARTED_IN_ANOTHER_BLOCK);
      throw new AbortParsingBlockError();
    }
    advance();
    consume();
    return true;
  }
 else   if (matchPrefix("String_Node_Str",false)) {
    advance();
    if (context.hasTagStart()) {
      SourceLocation.Point point=currentPoint();
      context.setState(context.createTag(currentRawTextNode,true,point),point);
    }
 else {
      errorReporter.report(currentLocation(),FOUND_END_TAG_STARTED_IN_ANOTHER_BLOCK);
      throw new AbortParsingBlockError();
    }
    advance();
    consume();
    return true;
  }
  return false;
}
Program: 29464
Project: 29464
Buggy source:
/** 
 * Records the start of an html tag
 * @param tagStartNode The node where it started
 * @param isCloseTag is is a close tag
 * @param point the source location of the {@code <} character.
 */
void startTag(RawTextNode tagStartNode,boolean isCloseTag,SourceLocation.Point point){
  checkState(this.tagStartPoint == null);
  checkState(this.tagStartNode == null);
  checkState(this.directTagChildren.isEmpty());
  if (startingState != State.PCDATA) {
    errorReporter.report(point.asLocation(filePath),BLOCK_TRANSITION_DISALLOWED,blockName,startingState,"String_Node_Str");
    reset();
  }
  this.tagStartPoint=checkNotNull(point);
  this.tagStartNode=checkNotNull(tagStartNode);
  this.isCloseTag=isCloseTag;
}

Fixed version (ground truth):
/** 
 * Records the start of an html tag
 * @param tagStartNode The node where it started
 * @param isCloseTag is is a close tag
 * @param point the source location of the {@code <} character.
 */
void startTag(RawTextNode tagStartNode,boolean isCloseTag,SourceLocation.Point point){
  checkState(this.tagStartPoint == null);
  checkState(this.tagStartNode == null);
  checkState(this.directTagChildren.isEmpty());
  if (startingState != State.PCDATA) {
    errorReporter.report(point.asLocation(filePath),BLOCK_TRANSITION_DISALLOWED,blockName,startingState,"String_Node_Str");
    throw new AbortParsingBlockError();
  }
  this.tagStartPoint=checkNotNull(point);
  this.tagStartNode=checkNotNull(tagStartNode);
  this.isCloseTag=isCloseTag;
}
Program: 29465
Project: 29465
Buggy source:
void maybeFinishPendingAttribute(SourceLocation.Point currentPoint){
  if (hasUnquotedAttributeValueParts()) {
    createUnquotedAttributeValue(currentPoint);
  }
 else   if (hasQuotedAttributeValueParts()) {
    errorReporter.report(currentPoint.asLocation(filePath),FOUND_END_OF_ATTRIBUTE_STARTED_IN_ANOTHER_BLOCK);
    resetAttribute();
  }
  if (attributeName != null) {
    createAttributeNode();
  }
}

Fixed version (ground truth):
void maybeFinishPendingAttribute(SourceLocation.Point currentPoint){
  if (hasUnquotedAttributeValueParts()) {
    createUnquotedAttributeValue(currentPoint);
  }
 else   if (hasQuotedAttributeValueParts()) {
    errorReporter.report(currentPoint.asLocation(filePath),FOUND_END_OF_ATTRIBUTE_STARTED_IN_ANOTHER_BLOCK);
    throw new AbortParsingBlockError();
  }
  if (attributeName != null) {
    createAttributeNode();
  }
}
Program: 29466
Project: 29466
Buggy source:
/** 
 * Handle a quoted attribute value. <p>These are easy we just look for the end quote.
 */
void handleQuotedAttributeValue(boolean doubleQuoted){
  boolean hasQuote=advanceWhileMatches(doubleQuoted ? NOT_DOUBLE_QUOTE : NOT_SINGLE_QUOTE);
  RawTextNode data=consumeAsRawText();
  if (data != null) {
    context.addAttributeValuePart(data);
  }
  if (hasQuote) {
    if (context.hasQuotedAttributeValueParts()) {
      context.createQuotedAttributeValue(currentRawTextNode,doubleQuoted,currentPoint());
    }
 else {
      errorReporter.report(currentLocation(),FOUND_END_OF_ATTRIBUTE_STARTED_IN_ANOTHER_BLOCK);
      context.resetAttribute();
      context.setState(State.BEFORE_ATTRIBUTE_NAME,currentPoint());
    }
    advance();
    consume();
  }
}

Fixed version (ground truth):
/** 
 * Handle a quoted attribute value. <p>These are easy we just look for the end quote.
 */
void handleQuotedAttributeValue(boolean doubleQuoted){
  boolean hasQuote=advanceWhileMatches(doubleQuoted ? NOT_DOUBLE_QUOTE : NOT_SINGLE_QUOTE);
  RawTextNode data=consumeAsRawText();
  if (data != null) {
    context.addAttributeValuePart(data);
  }
  if (hasQuote) {
    if (context.hasQuotedAttributeValueParts()) {
      context.createQuotedAttributeValue(currentRawTextNode,doubleQuoted,currentPoint());
    }
 else {
      errorReporter.report(currentLocation(),FOUND_END_OF_ATTRIBUTE_STARTED_IN_ANOTHER_BLOCK);
      throw new AbortParsingBlockError();
    }
    advance();
    consume();
  }
}
Program: 29467
Project: 29467
Buggy source:
void startAttribute(StandaloneNode attrName){
  maybeFinishPendingAttribute(attrName.getSourceLocation().getBeginPoint());
  checkNotNull(attrName);
  checkState(attributeName == null);
  if (startingState == State.BEFORE_ATTRIBUTE_VALUE) {
    errorReporter.report(attrName.getSourceLocation(),BLOCK_TRANSITION_DISALLOWED,blockName,startingState,"String_Node_Str");
    resetAttribute();
  }
  edits.remove(attrName);
  attributeName=attrName;
  setState(State.AFTER_ATTRIBUTE_NAME,attrName.getSourceLocation().getEndPoint());
}

Fixed version (ground truth):
void startAttribute(StandaloneNode attrName){
  maybeFinishPendingAttribute(attrName.getSourceLocation().getBeginPoint());
  checkNotNull(attrName);
  checkState(attributeName == null);
  if (startingState == State.BEFORE_ATTRIBUTE_VALUE) {
    errorReporter.report(attrName.getSourceLocation(),BLOCK_TRANSITION_DISALLOWED,blockName,startingState,"String_Node_Str");
    throw new AbortParsingBlockError();
  }
  edits.remove(attrName);
  attributeName=attrName;
  setState(State.AFTER_ATTRIBUTE_NAME,attrName.getSourceLocation().getEndPoint());
}