Expand description
Declaration units and comment-blind digests of one source file.
An assertion flow rests on specific code, not on the bytes of a file, and a test executes specific declarations, not a file. This module names what a file declares – functions, methods, classes, in a tree – and digests each declaration with comments blanked and nested declarations replaced by a placeholder, so an edit is attributed to the declaration it lands in and to nothing else. A test’s recorded execution is expressed in the same units.
Comments are erased, each with the formatting that was its own: the line it
occupied, or the spaces that set it off from code. Blank lines and trailing
whitespace go too, outside string literals, where no language reads them.
Whitespace that belongs to code is kept exactly: indentation is syntax in
Python, and a line break decides a statement in JavaScript, Go, Ruby and
Kotlin. A comment the language or a tool reads – //go:embed, a Ruby
magic comment, a Rust doctest – is kept as well; erasing it would hide a
change that runs.
Nothing here is a dependency analysis. The tree says where an edit landed; whether that edit matters to a test is decided by what the test executed.
Structs§
- Code
- What a parser could say about one file.
- Diff
- Indices into the old view for what changed or went, into the new for what arrived.
- Unit
- One declaration, positioned the way anchors are: one-based lines and one-based UTF-8 byte columns, end exclusive.