private static boolean isInsertSpaceAtCaret(@NotNull Editor editor, char charTyped, @NotNull Project project) {
    if (!isSpaceAroundAssignment(editor, project)) {
      return false;
    }

    int caretOffset = editor.getCaretModel().getOffset();
    CharSequence text = editor.getDocument().getImmutableCharSequence();

    HighlighterIterator lexerIterator = createLexerIterator(editor, caretOffset);
    if (lexerIterator == null || lexerIterator.getTokenType() == JavaTokenType.STRING_LITERAL) {
      return false;
    }

    boolean insertBeforeEq = charTyped == '=' && isInsertSpaceBeforeEq(caretOffset, text);
    boolean insertAfterEq = caretOffset > 0 && caretOffset - 1 < text.length() && text.charAt(caretOffset - 1) == '='
                            && isAssignmentOperator(lexerIterator) && isInsertSpaceAfterEq(charTyped);

    return (insertBeforeEq || insertAfterEq);
  }
private static boolean isInsertSpaceAtCaret(@NotNull Editor editor, char charTyped, @NotNull Project project)