Skip to main content

Module parse

Module parse 

Source
Expand description

Tree-sitter parsing and source-span collection.

Structs§

SpanRecord
Represents SpanRecord.

Enums§

TsGrammar
Represents TsGrammar.

Functions§

collect_spans
Parses C# source and returns its namespace, type, and member declaration spans.
is_ts_js
Whether rel is a TS/JS file – ts_grammar_for(rel).is_some().
node_text
Text of node out of a utf16_bytes buffer – the UTF-16 counterpart of Node::utf8_text, and the only way to read source text in this crate.
parse_ts_js
One parse of source under grammar. Parser::parse returns None only on cancellation/malformed-input-size edge cases, never on ordinary syntax errors (those surface as ERROR nodes inside a still-present tree).
run_parse
Parses the C# file at path and prints its syntax tree.
run_spans
Collects declaration spans from the C# file at path and prints them as JSON.
spans_json
Serializes span records as a JSON array.
ts_grammar_for
Maps a file extension to its grammar. Based on the last . in rel, not path-aware: a dotted directory segment on a file with no extension of its own would misfire (a known, accepted edge case).
utf16_bytes
The same units as a little-endian byte buffer, which is what node byte offsets index into and therefore what every text() helper slices.
utf16_index
UTF-16 code-unit index for a byte offset (or column) reported by a tree parsed out of a utf16_bytes buffer.
utf16_units
Encodes source text as UTF-16 code units.