[Demonstration 1]

[Buggy Method]
private FileObject getRoot(FileObject file) {
    Project project = FileOwnerQuery.getOwner(file);
    Sources sources = ProjectUtils.getSources(project);
    for (SourceGroup sourceGroup : sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        FileObject root = sourceGroup.getRootFolder();
        if (FileUtil.isParentOf(root, file) || root.equals(file)) {
            return root;
        }
    }
    return null;
}

[Buggy Hunk]
return null;

[Patch]
return ClassPath.getClassPath(file, ClassPath.SOURCE).findOwnerRoot(file);

[Demonstration 2]

[Buggy Method]
@Nonnull
private static ArrayList<Substitution> identifySubstitutions(@Nonnull String[] operands, @Nonnull SourceLocation body) {
    // There are a few patterns that will get substituted in macros.
    //
    // The following patterns are matched anywhere in the macro body:
    // - \{xyz}   if xyz is an integer, gets substituted to the nth operand (\0 is the attribute); otherwise, if xyz matches the
    //            name of an operand, gets substituted with the corresponding operand in a macro invocation
    // - \*       gets substituted with the last label on the macro invocation line
    //
    // The following patterns are matched outside of string literals only:
    // - xyz      if xyz is an identifier that matches the name of an operand, gets substituted with the corresponding operand
    //            in a macro invocation
    // - \xyz     if xyz is an integer, gets substituted to the nth operand (\0 is the attribute)
    final ArrayList<Substitution> substitutions = new ArrayList<>();
    final RangedCharSequenceReader reader = new RangedCharSequenceReader(new DocumentReader(body.getFile().getText()), body.getTextPosition(), body.getTextPosition() + body.getSourceNode().getLength());
    int inString = -1;
    while (!reader.atEnd()) {
        final int startPosition = reader.getCurrentPosition();
        int codePoint = reader.getCurrentCodePoint();
        if (codePoint == '\\') {
            reader.advance();
            codePoint = reader.getCurrentCodePoint();
            if (codePoint == '{') {
                // Read until we find a '}'.
                do {
                    reader.advance();
                    codePoint = reader.getCurrentCodePoint();
                } while (codePoint != -1 && codePoint != '}');
                if (codePoint == '}') {
                    reader.advance();
                    final int endPosition = reader.getCurrentPosition();
                    // Read the name starting after "\{" and ending before "}".
                    // Trim it because operands are always trimmed.
                    reader.setCurrentPosition(startPosition + 2);
                    final String name = reader.readSubstring(endPosition - startPosition - 3).trim();
                    final Integer i = tryParseInt(name);
                    if (i != null) {
                        // NOTE: i - 1 is ATTRIBUTE when i == 0
                        substitutions.add(new Substitution(startPosition, endPosition - startPosition, i - 1));
                    } else {
                        // Check if the text between the braces matches the name of an operand.
                        findNamedSubstitution(operands, name, startPosition, endPosition, substitutions);
                    }
                }
                continue;
            }
            if (codePoint == '*') {
                reader.advance();
                substitutions.add(new Substitution(startPosition, reader.getCurrentPosition() - startPosition, Substitution.LABEL));
                continue;
            }
            if (inString == -1) {
                if (Syntax.isDigit(codePoint)) {
                    // Read until we find a non-digit.
                    do {
                        reader.advance();
                    } while (Syntax.isDigit(reader.getCurrentCodePoint()));
                    final int endPosition = reader.getCurrentPosition();
                    reader.setCurrentPosition(startPosition + 1);
                    final String name = reader.readSubstring(endPosition - startPosition - 1).trim();
                    final Integer i = tryParseInt(name);
                    if (i != null) {
                        // NOTE: i - 1 is ATTRIBUTE when i == 0
                        substitutions.add(new Substitution(startPosition, endPosition - startPosition, i - 1));
                    }
                    continue;
                }
            } else {
                // Skip the next code point. This allows single and double quotes, in particular, to be escaped.
                reader.advance();
            }
        } else {
            if (inString == -1) {
                if (codePoint == '\'' || codePoint == '"') {
                    inString = codePoint;
                } else if (M68KParser.SYNTAX.isValidIdentifierCodePoint(codePoint)) {
                    boolean startsWithDigit = Syntax.isDigit(codePoint);
                    // Read an identifier.
                    do {
                        reader.advance();
                    } while (M68KParser.SYNTAX.isValidIdentifierCodePoint(reader.getCurrentCodePoint()));
                    if (!startsWithDigit) {
                        final int endPosition = reader.getCurrentPosition();
                        reader.setCurrentPosition(startPosition);
                        final String identifier = reader.readSubstring(endPosition - startPosition);
                        // Check if the identifier matches the name of an operand.
                        findNamedSubstitution(operands, identifier, startPosition, endPosition, substitutions);
                    }
                    continue;
                }
            } else if (inString == codePoint) {
                inString = -1;
            }
        }
        reader.advance();
    }
    return substitutions;
}

[Buggy Hunk]
} else if (M68KParser.SYNTAX.isValidIdentifierCodePoint(codePoint)) {

[Patch]
} else if (M68KParser.SYNTAX.isValidIdentifierInitialCodePoint(codePoint)) {

[Demonstration 3]

[Buggy Method]
@Override
public void onClick(View v) {
    stop();
    int i = v.getId();
    if (i == R.id.ok) {
        recordListener.onComplete(file.getPath());
    } else if (i == R.id.delete) {
        FileUtil.deleteDirWihtFile(FileUtil.getCacheRootFile(v.getContext()));
        recordListener.onCancel();
    }
}

[Buggy Hunk]
FileUtil.deleteDirWihtFile(FileUtil.getCacheRootFile(v.getContext()));

[Patch]
new File(FileUtil.getCacheRootFile(v.getContext()), mp3Name).delete();