// tags before we allow folding
if (commentText.length() > 6
&& commentText.substring(0, 3).equals("{{!")
&& commentText.substring(commentText.length() - 2, commentText.length()).equals("}}")) {
TextRange range = new TextRange(commentNode.getTextRange().getStartOffset() + 3, commentNode.getTextRange().getEndOffset() - 2);
descriptors.add(new FoldingDescriptor(commentNode, range));
}
}
if (psi instanceof HbBlockWrapper) {
PsiElement endOpenBlockStache = getOpenBlockCloseStacheElement(psi.getFirstChild());
PsiElement endCloseBlockStache = getCloseBlockCloseStacheElement(psi.getLastChild());
// if we've got a well formed block with the open and close elems we need, define a region to fold
if (endOpenBlockStache != null && endCloseBlockStache != null) {
int endOfFirstOpenStacheLine
= document.getLineEndOffset(document.getLineNumber(psi.getTextRange().getStartOffset()));
// we set the start of the text we'll fold to be just before the close braces of the open stache,
// or, if the open stache spans multiple lines, to the end of the first line
int foldingRangeStartOffset = Math.min(endOpenBlockStache.getTextRange().getStartOffset(), endOfFirstOpenStacheLine);
// we set the end of the text we'll fold to be just before the final close braces in this block
int foldingRangeEndOffset = endCloseBlockStache.getTextRange().getStartOffset();
TextRange range = new TextRange(foldingRangeStartOffset, foldingRangeEndOffset);
descriptors.add(new FoldingDescriptor(psi, range));
}
}
PsiElement child = psi.getFirstChild();
while (child != null) {