int offset = editor.getCaretModel().getOffset();
HighlighterIterator iterator = ((EditorEx) editor).getHighlighter().createIterator(offset);
boolean atEndOfDocument = offset == editor.getDocument().getTextLength();
if (!atEndOfDocument) iterator.retreat();
if (iterator.atEnd()) return;
BraceMatcher braceMatcher = BraceMatchingUtil.getBraceMatcher(fileType, iterator);
if (iterator.atEnd()) return;
IElementType braceTokenType = iterator.getTokenType();
CharSequence fileText = editor.getDocument().getCharsSequence();
if (!braceMatcher.isLBraceToken(iterator, fileText, fileType)) return;