@Override
  public void documentChanged(@NotNull DocumentEvent e) {
    synchronized (this) {
      final Document document = e.getDocument();
      Lexer l = getLexer();
      // if the document been changed before "from __future__ import unicode_literals"
      // we should update the whole document
      if (l instanceof LayeredLexer) {
        Lexer delegate = ((LayeredLexer)l).getDelegate();
        int offset = e.getOffset();
        int lineNumber = document.getLineNumber(offset);
        TextRange tr = new TextRange(document.getLineStartOffset(lineNumber), document.getLineEndOffset(lineNumber));
        document.putUserData(KEY, !document.getText(tr).contains(PyNames.UNICODE_LITERALS));
        Boolean hasUnicodeImport = document.getUserData(KEY);
        if (delegate instanceof PythonHighlightingLexer &&
            (((PythonHighlightingLexer)delegate).getImportOffset() > e.getOffset()
             || hasUnicodeImport != hadUnicodeImport)) {
          ((PythonHighlightingLexer)delegate).clearState(e.getDocument().getTextLength());
          setText(document.getCharsSequence());
        }
        else super.documentChanged(e);
      }
      else super.documentChanged(e);
    }
  }
@Override
  public void documentChanged(@NotNull DocumentEvent e)