private void addToken(@NotNull Queue<Token> output, int position) {
    position = Math.min(position, myText.length());
    if (position > myCurrentOffset) {
      boolean newState = myCurrentScope.getParent() == null;
      int wsStart = myCurrentOffset;
      while (myStripWhitespaces && position > myCurrentOffset && Character.isWhitespace(myText.charAt(myCurrentOffset))) {
        myCurrentOffset++;
      }

      if (wsStart < myCurrentOffset) {
        output.offer(new Token(TextMateScope.WHITESPACE, wsStart, myCurrentOffset, newState));
        newState = false;
      }

      int wsEnd = position;
      while (myStripWhitespaces && wsEnd > myCurrentOffset && Character.isWhitespace(myText.charAt(wsEnd - 1))) {
        wsEnd--;
      }

      if (myCurrentOffset < wsEnd) {
        output.offer(new Token(myCurrentScope, myCurrentOffset, wsEnd, newState));
      }

      if (wsEnd < position) {
        output.offer(new Token(TextMateScope.WHITESPACE, wsEnd, position, newState));
      }

      myCurrentOffset = position;
    }
  }
private void addToken(@NotNull Queue<Token> output, int position)