boolean (PsiElement element, int offset) { int balance = 0; while (element != null) { @NonNls final String text = element.getText(); final int endIndex = StringUtil.indexOfIgnoreCase(text, "</code>", offset); final int end = endIndex >= 0 ? endIndex : text.length(); if (text.equals("{")) { balance++; } else if (text.equals("}")) { balance--; if (balance < 0) return false; } if (containsHtmlTag(text, offset, end)) { return false; } if (endIndex >= 0) { return balance == 0; } offset = 0; element = element.getNextSibling(); if (element instanceof PsiInlineDocTag) { return false; } } return false; }