[Demonstration 1]

[Buggy Method]
@Override
public void writeReference(String text, Object reference, boolean isLocal) {
    this.render((canvas) -> {
        if (reference instanceof PackageReference) {
            this.write(text);
        } else if (reference instanceof TypeReference) {
            TypeReference ref = (TypeReference) reference;
            if (text.equals("@")) {
                // Procyon has a bug where the '@' in front of attributes
                //  is written as an identifier. We manually handle this.
                this.write(text);
                return;
            }
            HtmlAttributes attribs = class_(CSS.JAVA_REF_TYPE);
            attribs.add("ref_type", "type");
            attribs.add("type", ref.getFullName());
            canvas.span(attribs).content(text);
        } else if (reference instanceof MethodReference) {
            MethodReference ref = (MethodReference) reference;
            HtmlAttributes attribs = class_(CSS.JAVA_REF_METHOD);
            attribs.add("ref_type", "method");
            attribs.add("type", ref.getDeclaringType().getFullName());
            attribs.add("method_name", ref.getName());
            attribs.add("method_type", ref.getReturnType().getFullName());
            attribs.add("method_sig", ref.getSignature());
            canvas.span(attribs).content(text);
        } else if (reference instanceof FieldReference) {
            FieldReference ref = (FieldReference) reference;
            HtmlAttributes attribs = class_(CSS.JAVA_REF_FIELD);
            attribs.add("ref_type", "field");
            attribs.add("type", ref.getDeclaringType().getFullName());
            attribs.add("field_name", ref.getName());
            attribs.add("field_type", ref.getFieldType().getFullName());
            canvas.span(attribs).content(text);
        } else if (reference instanceof ParameterReference) {
            //				ParameterReference ref = ( ParameterReference ) reference;
            canvas.span(class_(CSS.JAVA_REF_PARAMETER)).content(text);
        } else if (reference instanceof VariableReference) {
            VariableReference ref = (VariableReference) reference;
            if (this.seenVariables.add(ref)) {
                // Procyon has a bug where both references and definitions
                //  for variables are passed to this method. We manually
                //  redirect definitions to the correct place.
                this.writeDefinition(text, ref, isLocal);
                return;
            }
            canvas.span(class_(CSS.JAVA_REF_VARIABLE)).content(text);
        } else {
            throw new IllegalArgumentException("Can not write reference type: " + reference.getClass());
        }
    });
}

[Buggy Hunk]
attribs.add( "type", ref.getFullName( ) );

[Patch]
attribs.add( "type", ref.getInternalName( ).replace( '/', '.' ) );

[Demonstration 2]

[Buggy Method]
private void createTheme(@NotNull Project project, Module module) {
    String[] commands = { "echo", "0", "|", "php", "bin/plugin", "devtools", "new-theme", "--name", themeData.getName(), "--description", themeData.getDescription(), "--developer", themeData.getDeveloper(), "--email", themeData.getEmail() };
    GravProjectSettings settings = GravProjectSettings.getInstance(project);
    ModuleRootManager root = ModuleRootManager.getInstance(module);
    VirtualFile srcFile = null;
    for (VirtualFile file : root.getSourceRoots()) {
        if (file.isDirectory() && file.getName().contentEquals("src")) {
            srcFile = file;
            break;
        }
    }
    if (srcFile == null) {
        if (settings.withSrcDirectory) {
            NotificationHelper.showBaloon("No source root found in module '" + module.getName() + "'", MessageType.ERROR, project);
            return;
        } else {
            srcFile = FileCreateUtil.getParentDirectory(module.getModuleFile(), module.getName());
        }
    }
    VirtualFile finalSrcFile = srcFile;
    ProcessUtils processUtils = new ProcessUtils(commands, new File(finalSrcFile.getPath()));
    Task.Backgroundable t = new Task.Backgroundable(project, "Create New Grav Theme in Module '" + module.getName() + "'") {

        @Override
        public boolean shouldStartInBackground() {
            return true;
        }

        @Override
        public void onSuccess() {
            super.onSuccess();
            String output = processUtils.getOutputAsString();
            if (processUtils.getErrorOutput() != null) {
                NotificationHelper.showBaloon(processUtils.getErrorOutput(), MessageType.ERROR, project);
            } else {
                NotificationHelper.showBaloon("Theme '" + themeData.getName() + "' was created", MessageType.INFO, project);
            }
        }

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            processUtils.execute();
        }
    };
    ProgressManager.getInstance().run(t);
}

[Buggy Hunk]
if (settings.withSrcDirectory) {

[Patch]
if (settings != null && settings.withSrcDirectory) {

[Demonstration 3]

[Buggy Method]
@Test
public void testTestOverFlow() {
    Processor processor = new Processor();
    processor.testOverflow(1);
    Assert.assertFalse(processor.overflow);
    processor.testOverflow(1000);
    Assert.assertTrue(processor.overflow);
    processor.testOverflow(128);
    Assert.assertTrue(processor.overflow);
    processor.testOverflow(127);
    Assert.assertFalse(processor.overflow);
    processor.testOverflow(-128);
    Assert.assertFalse(processor.overflow);
    processor.testOverflow(-129);
    Assert.assertTrue(processor.overflow);
    processor.testOverflow((long) 129);
    Assert.assertTrue(processor.overflow);
}

[Buggy Hunk]
processor.testOverflow((long) 129);

[Patch]
processor.testOverflow(129L);