filterForChannel method

List<Token>? filterForChannel(
  1. int from,
  2. int to,
  3. int channel
)

Implementation

List<Token>? filterForChannel(int from, int to, int channel) {
  final hidden = <Token>[];
  for (var i = from; i <= to; i++) {
    final t = tokens[i];
    if (channel == -1) {
      if (t.channel != Lexer.DEFAULT_TOKEN_CHANNEL) hidden.add(t);
    } else {
      if (t.channel == channel) hidden.add(t);
    }
  }
  if (hidden.isEmpty) return null;
  return hidden;
}