Skip to main content

Module fingerprint

Module fingerprint 

Expand description

Structural AST fingerprinting for clone detection.

Walks a tree-sitter parse tree in pre-order, emitting (kind_name, child_count) pairs while skipping identifier, literal, and comment nodes. The resulting byte sequence is SHA-256-hashed to yield a 256-bit Fingerprint::digest that:

  • is identical for Type 1 (exact) clones
  • is identical for Type 2 (renamed/parameterized) clones — names and literals are normalized away
  • diverges for structurally different code

Structs§

Fingerprint
One function-or-file’s structural fingerprint.

Functions§

fingerprint_source
Compute a structural fingerprint over the full source of code for language lang. Returns Err if tree-sitter fails to load the language (should never happen for the pinned grammars) or to parse (returns an empty-tree fingerprint, not an error, since tree-sitter is permissive).