Skip to content

feat: use parser-backed ino prototype generation - #657

Merged
zackees merged 1 commit into
mainfrom
feat/648-parser-backed-ino-prototypes
Jun 19, 2026
Merged

feat: use parser-backed ino prototype generation#657
zackees merged 1 commit into
mainfrom
feat/648-parser-backed-ino-prototypes

Conversation

@zackees

@zackeeszackees commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace regex-based .ino prototype extraction with tree-sitter C++ parsing.
  • Generate prototypes only from free-function definitions and skip control-flow blocks, lambdas, class methods, macro fragments, namespace-local functions, and scoped Class::method definitions.
  • Strip default argument expressions from generated prototypes so the later function definition remains valid C++.
  • Document that this path uses an embedded parser and does not require clang/libclang at runtime.

Closes#648

Tests

  • soldr cargo fmt
  • soldr cargo test -p fbuild-build source_scanner
  • soldr cargo clippy -p fbuild-build --all-targets -- -D warnings
  • soldr cargo test -p fbuild-build

Notes

During verification, one soldr run reported a lost zccache daemon connection during session start. I ran the standard daemon stop/retry flow and the same test passed afterward.

Summary by CodeRabbit

  • New Features

    • Enhanced .ino prototype extraction with improved handling of templates, references, and complex C++ signatures for better accuracy.
  • Documentation

    • Added reference documentation describing the .ino prototype generation process and supported language constructs.

@coderabbitai

coderabbitaiBot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c140c245-36f6-4143-b81e-af92f51c5710

📥 Commits

Reviewing files that changed from the base of the PR and between db10481 and 3b7b02c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • Cargo.toml
  • crates/fbuild-build/Cargo.toml
  • crates/fbuild-build/src/source_scanner.rs
  • docs/reference/platformio-compatibility.md

📝 Walkthrough

Walkthrough

Replaces regex-based .ino function prototype and forward-declaration extraction in source_scanner.rs with a Tree-sitter C++ parser pipeline. Adds tree-sitter and tree-sitter-cpp as workspace and crate dependencies, updates prototype-extraction tests for complex C++ signatures, and adds reference documentation describing the new approach.

Changes

Tree-sitter .ino Prototype Extraction

Layer / File(s)Summary
Workspace and crate dependency wiring
Cargo.toml, crates/fbuild-build/Cargo.toml, crates/fbuild-build/src/source_scanner.rs
Registers tree-sitter (0.26.9) and tree-sitter-cpp (0.23.4) as workspace dependencies, adds them to the crate's dependency section, and imports tree_sitter::{Node, Parser} in the scanner.
Tree-sitter prototype extraction and forward-declaration detection
crates/fbuild-build/src/source_scanner.rs
Replaces regex-based extract_function_prototypes and find_existing_forward_declarations with a Tree-sitter C++ parser pipeline that traverses function_definition and declaration AST nodes, skips nested namespace/class/struct/union contexts, normalizes signatures, strips default argument values via AST byte ranges, and deduplicates results.
Updated tests and reference documentation
crates/fbuild-build/src/source_scanner.rs, docs/reference/platformio-compatibility.md
Adds test cases for templates, attributes, references, and default-argument stripping; adds cases asserting non-free functions are skipped; removes the prior regex keyword-skip test. Adds a documentation subsection covering the Tree-sitter-based prototype generation approach, its structural constraints, and the absence of a clang/libclang runtime requirement.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hopping through syntax trees with glee,
No more regex for this little bunny!
Tree-sitter parses C++ just right,
Templates and defaults all trimmed tight.
Forward declarations, clean and bright —
The AST keeps prototypes in sight! 🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/648-parser-backed-ino-prototypes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit dfb2907 into mainJun 19, 2026
83 of 91 checks passed
@zackees
zackees deleted the feat/648-parser-backed-ino-prototypes branch June 19, 2026 20:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

feat: replace regex ino prototype generation with clang AST parsing

1 participant

@zackees