code: protected String addMatchingBrace( int offset ) throws BadLocationException {
          StringBuffer whiteSpace = new StringBuffer();
          int line = rootElement.getElementIndex(offset);
          int i = rootElement.getElement(line).getStartOffset();
          while( true ) {
              String temp = doc.getText(i, 1);
              if (temp.equals(" ") || temp.equals("\t")) {
                  whiteSpace.append(temp);
                  i++;
              } else
                  break;
          }
          return "{\n" + whiteSpace.toString() + whiteSpace.toString() + "\n" + whiteSpace.toString() + "}";
      }
docs: /*
  Overide bracket matching for other languages