StringTokenImpl.fromSubstring constructor

StringTokenImpl.fromSubstring(
  1. TokenType type,
  2. String data,
  3. int start,
  4. int end,
  5. int charOffset, {
  6. bool canonicalize = false,
  7. CommentToken? precedingComments,
})

Creates a lazy string token. If canonicalize is true, the string is canonicalized before the token is created.

Implementation

StringTokenImpl.fromSubstring(
    TokenType type, String data, int start, int end, int charOffset,
    {bool canonicalize = false, CommentToken? precedingComments})
    : super(type, charOffset, precedingComments) {
  int length = end - start;
  if (length <= LAZY_THRESHOLD) {
    valueOrLazySubstring =
        canonicalizedSubString(data, start, end, canonicalize);
  } else {
    valueOrLazySubstring =
        new _LazySubstring(data, start, length, canonicalize);
  }
}