if (fileToPatch.findChild(getBeforeFileName()) != null) {
throw new ApplyPatchException("File " + getBeforeFileName() + " already exists");
}
VirtualFile newFile = fileToPatch.createChildData(this, getBeforeFileName());
final Document document = FileDocumentManager.getInstance().getDocument(newFile);
<BUG>document.setText(myHunks.get(0).getText());
</BUG>
FileDocumentManager.getInstance().saveDocument(document);
}
else if (isDeletedFile()) {

if (fileToPatch.findChild(getBeforeFileName()) != null) {
throw new ApplyPatchException("File " + getBeforeFileName() + " already exists");
}
VirtualFile newFile = fileToPatch.createChildData(this, getBeforeFileName());
final Document document = FileDocumentManager.getInstance().getDocument(newFile);
document.setText(getNewFileText());
FileDocumentManager.getInstance().saveDocument(document);
}
else if (isDeletedFile()) {
