highlightRanges method

List<StyledRange> highlightRanges(
  1. String code, {
  2. required String language,
  3. required SyntaxTheme theme,
})

Styled ranges over the whole of code, as UTF-16 offsets into it: the shape renderers that style one string at a time want. To re-highlight as the code changes, keep a TokenizedDocument instead.

Implementation

List<StyledRange> highlightRanges(
  String code, {
  required String language,
  required SyntaxTheme theme,
}) => (TokenizedDocument(grammar(language))..update(code)).ranges(theme);