parseUtf8Bytes method

TreeSitterTree parseUtf8Bytes(
  1. Uint8List bytes, {
  2. TreeSitterTree? oldTree,
  3. Iterable<TreeSitterInputEdit> edits = const [],
  4. bool annotateLocals = true,
})

Parses exact UTF-8 bytes without normalizing malformed input through a Dart String. Every public byte range remains relative to bytes.

Implementation

TreeSitterTree parseUtf8Bytes(
  Uint8List bytes, {
  TreeSitterTree? oldTree,
  Iterable<TreeSitterInputEdit> edits = const [],
  bool annotateLocals = true,
}) {
  try {
    final result = _parseSource(
      utf8.decode(bytes, allowMalformed: true),
      Uint8List.fromList(bytes),
      oldTree: oldTree,
      edits: edits,
      annotateLocals: annotateLocals,
    );
    _hasOutstandingParse = false;
    return result;
  } on GeneratedTreeSitterParseHalted {
    _hasOutstandingParse = true;
    throw const TreeSitterParseHaltedException();
  }
}