// PSimpleIndenter has such a method but it's not exposed in the base class.
 private boolean isBlockBegin(CharSequence lineToTheLeft) {
   if (lineToTheLeft.length() == 0) {
     return false;
   }
   char lastChar = lineToTheLeft.charAt(lineToTheLeft.length() - 1);
   if (PBracketUtilities.isOpenBracket(lastChar) == false) {
     return false;
   }
   char closeBracket = PBracketUtilities.getPartnerForBracket(lastChar);
   if (textArea.getIndenter().isElectric(closeBracket) == false) {
     return false;
   }
   return true;
 }
 private static String getUnmatchedBrackets(final String initialText) {
   String text = initialText.replaceAll("\\\\.", "_"); // Remove escaped characters.
   text = text.replaceAll("'.'", "_"); // Remove character literals.
   text = text.replaceAll("\"([^\\n]*?)\"", "_"); // Remove string literals.
   text = text.replaceAll("/\\*(?s).*?\\*/", "_"); // Remove C comments.
   text = text.replaceAll("//[^\\n]*", "_"); // Remove C++ comments.
   StringBuilder unmatchedBrackets = new StringBuilder();
   for (int i = 0; i < text.length(); ++i) {
     char ch = text.charAt(i);
     if (PBracketUtilities.isOpenBracket(ch) && ch != '<') {
       unmatchedBrackets.append(ch);
     } else if (PBracketUtilities.isCloseBracket(ch) && ch != '>') {
       char openBracket = PBracketUtilities.getPartnerForBracket(ch);
       int lastCharIndex = unmatchedBrackets.length() - 1;
       if (lastCharIndex >= 0 && unmatchedBrackets.charAt(lastCharIndex) == openBracket) {
         unmatchedBrackets.deleteCharAt(lastCharIndex);
       } else {
         unmatchedBrackets.append(ch);
       }
     }
   }
   return unmatchedBrackets.toString();
 }