parseOrNull method

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

Native Parser::parse result semantics for an unbound parser.

The established non-null parse convenience remains available to code that constructs the parser with a language. This method returns null for the upstream no-language failure case instead of throwing.

Implementation

TreeSitterTree? parseOrNull(
  String source, {
  TreeSitterTree? oldTree,
  Iterable<TreeSitterInputEdit> edits = const [],
  bool annotateLocals = true,
}) {
  _checkNotDisposed();
  if (_grammar == null) return null;
  return parse(
    source,
    oldTree: oldTree,
    edits: edits,
    annotateLocals: annotateLocals,
  );
}