getHiddenTokensToRight method

List<Token>? getHiddenTokensToRight(
  1. int tokenIndex, [
  2. int channel = -1
])

Collect all tokens on specified channel to the right of the current token up until we see a token on DEFAULT_TOKEN_CHANNEL or EOF. If channel is -1, find any non default channel token.

Implementation

List<Token>? getHiddenTokensToRight(int tokenIndex, [int channel = -1]) {
  lazyInit();
  if (tokenIndex < 0 || tokenIndex >= tokens.length) {
    throw RangeError.index(tokenIndex, tokens);
  }

  final nextOnChannel =
      nextTokenOnChannel(tokenIndex + 1, Lexer.DEFAULT_TOKEN_CHANNEL);
  // if none onchannel to right, nextOnChannel=-1 so set to = last token
  final to = nextOnChannel == -1 ? size - 1 : nextOnChannel;
  final from = tokenIndex + 1;

  return filterForChannel(from, to, channel);
}