if (psiElement == null || !psiElement.isValid()) return;
if (!FileModificationService.getInstance().prepareFileForWrite(psiElement.getContainingFile())) return;
if (psiElement instanceof PsiWhiteSpace) psiElement = PsiTreeUtil.prevLeaf(psiElement);
HbBlockMustache blockMustache = (HbBlockMustache)PsiTreeUtil.findFirstParent(psiElement, true, new Condition<PsiElement>() {
@Override
public boolean value(PsiElement psiElement) {
return psiElement instanceof HbBlockMustache;
}
});
if (blockMustache == null) {
return;
}
HbBlockMustache targetBlockMustache = blockMustache;
// ensure we update the open or close mustache for this block appropriately
if (myUpdateOpenMustache != (targetBlockMustache instanceof HbOpenBlockMustache)) {
targetBlockMustache = blockMustache.getPairedElement();
}