SourceFile.decoded constructor

SourceFile.decoded(Iterable<int> decodedChars, { dynamic url })

Creates a new source file from a list of decoded code units.

url may be either a String, a Uri, or null.

Currently, if decodedChars contains characters larger than 0xFFFF, they'll be treated as single characters rather than being split into surrogate pairs. This behavior is deprecated. For forwards-compatibility, callers should only pass in characters less than or equal to 0xFFFF.

Implementation

SourceFile.decoded(Iterable<int> decodedChars, {url})
    : url = url is String ? Uri.parse(url) : url,
      _decodedChars = new Uint32List.fromList(decodedChars.toList()) {
  for (var i = 0; i < _decodedChars.length; i++) {
    var c = _decodedChars[i];
    if (c == _CR) {
      // Return not followed by newline is treated as a newline
      var j = i + 1;
      if (j >= _decodedChars.length || _decodedChars[j] != _LF) c = _LF;
    }
    if (c == _LF) _lineStarts.add(i + 1);
  }
}