Repository navigation
feat: add C support via a language plugin - #35
Merged
Merged
Conversation
Declarator names, parameters, comment blocks above a node and #include resolution read the same way in C and C++, so they live in one module the C plugin uses now and a C++ plugin can reuse later.
Reads .c and .h with tree-sitter-c. Only definitions are Functions. Calls resolve by name in C's own visibility order (same file, quoted #include chain and the implementing .c file, then the one non-static definition), and two or more candidates mean no wire rather than a guess.
The hints still listed only Python and Rust, so TypeScript and JavaScript were missing before C joined them.
Headers with prototypes and doc comments, a static helper, and a function-pointer parameter that must not draw a wire.
The call collector walked each body with a stack and popped children last-first, so a function's calls came out in reverse source order. The canvas stacks callee cards in that order, which put them upside down and made every wire from a caller cross the others. Push children reversed so the walk visits them in source order, as the Rust plugin's recursion does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #33
What
Adds C as a Language plugin (
.c,.h), built on the shared bookkeeping from #31.backend/languages/cfamily.py: tree-sitter helpers meant to be reused by the C++ plugin (declarators, parameters, comment blocks,#includeresolution).backend/languages/c.py: the plugin. Only definitions are Functions; a header prototype never is, but its comment documents a definition that has none.#includechain (and the.cimplementing an included header, non-static only), then the one non-static definition in the picked root. Two or more candidates at the step that finds any mean no wire. A call through a parameter or local variable is treated as indirect and never linked.centry inlanguages.ts,prism-chighlighting, and the empty-state hints now name every supported language (TypeScript and JavaScript were missing).sample_c_project/, plus the README table row, Backend bullet and the verification line inCLAUDE.md.Decisions worth a look
-Ipaths. Not in the issue; documented in the plugin docstring..cfor a header prefers the header's own directory before other directories with the same stem.unannotatedReturn: nullfor C, so a missing return type never renders asNone.Verification
python -m backend.analyzeronsample_project,sample_rust_project,sample_typescript_projectandsample_rust_nested_projectgives identical function, edge and file counts before and after (16/17, 8/6, 21/18, 2/1).sample_c_project: 11 functions, 9 edges, no parse errors.npm run buildandnpm run lintpass infrontend/;GET /api/healthreturnsok.npm run buildon its own.Include/directory (283 macro-heavy headers) analyzes in about 2s, with the 247 files tree-sitter can't fully parse flagged and the functions it recovered kept.Not verified
#a8b9cc, not checked in a browser.