getLineTokens method

List<Token> getLineTokens(
  1. int line, [
  2. bool? precise
])

This is similar to getTokenAt, but collects all tokens for a given line into an array. It is much cheaper than repeatedly calling getTokenAt, which re-parses the part of the line before the token for every call.

Implementation

List<Token> getLineTokens(int line, [bool? precise]) {
  var result = precise != null
      ? callArgs('getLineTokens', [line, precise])
      : callArg('getLineTokens', line);
  if (result is List) {
    return List.of(result.map((t) => Token.fromProxy(t)));
  } else {
    return [];
  }
}