Menu

Using tree-sitter for entity-level code diffing and dependency graphs
📰
0

Using tree-sitter for entity-level code diffing and dependency graphs

Reddit r/compsci·u/Wise_Reflection_8340·about 1 month ago
#lV2GtZE0
#entity#function#type#tree#sitter#article
Reading 0:00
15s threshold

Using tree-sitter for entity-level code diffing and dependency graphs I've been working on a tool that uses tree-sitter grammars to extract structural entities (functions, classes, methods) from source code, then builds a cross-file dependency graph by resolving references between them. The core problem: traditional diff tools compare lines, but the meaningful unit of change in code is an entity. When you rename a function, move a method, or reformat a file, line-level diff produces noise. Entity-level diff tells you "this function was modified, this one was added, this one moved." The interesting technical bits: \- Each language gets a config that maps AST node types to entity types (e.g. function\_definition in Python, function\_item in Rust, method\_declaration in Java). Currently supports 25+ languages through tree-sitter. \- Scope resolution walks the AST to resolve which entity references which other entity, handling class scopes, impl blocks, function parameters, and assignment-based type tracking.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More