private AccessibleTextSequence getWordOrLexeme(int offset, @MagicConstant(intValues = {BEFORE, HERE, AFTER}) int direction) {
      boolean isCamel = editor.getSettings().isCamelWords();
      var caretStopPolicy = resolveCaretStopPolicy(direction);
      offset = moveWordOffset(offset, direction, caretStopPolicy, isCamel);
      var wordStop = caretStopPolicy.getWordStop();
      int wordStart = getWordAtOffsetStart(offset, wordStop, isCamel);
      int wordEnd = getWordAtOffsetEnd(offset, wordStop, isCamel);
      if (wordStart == -1 || wordEnd == -1 || wordStart > wordEnd) {
        return null;
      }
      return new AccessibleTextSequence(wordStart, wordEnd,
                                        editor.getDocument().getCharsSequence().subSequence(wordStart, wordEnd).toString());
    }
private AccessibleTextSequence getWordOrLexeme(int offset, @MagicConstant(intValues = {BEFORE, HERE, AFTER}) int direction)