@Override public int getErrorsCount(final CharSequence seq, Language fileLanguage, final Project project) { final Lexer lexer = new JavaLexer(LanguageLevel.HIGHEST); lexer.start(seq); if(lexer.getTokenType() != JavaTokenType.LBRACE) { return IErrorCounterReparseableElementType.FATAL_ERROR; } lexer.advance(); int balance = 1; while(true) { IElementType type = lexer.getTokenType(); if(type == null) { break; } if(balance == 0) { return IErrorCounterReparseableElementType.FATAL_ERROR; } if(type == JavaTokenType.LBRACE) { balance++; } else if(type == JavaTokenType.RBRACE) { balance--; } lexer.advance(); } return balance; }