Skip to content

fix(definitions): recognize export macros, open typedef bodies, top-level prototypes, and namespace re-exports - #932

Open
dmtrKovalenko wants to merge 2 commits into
codex/blueprint-text-filesfrom
codex/definition-forms
Open

dmtrKovalenko wants to merge 2 commits into
codex/blueprint-text-filesfrom
codex/definition-forms

Conversation

@dmtrKovalenko

@dmtrKovalenko dmtrKovalenko commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

The C grammar now names C++ classes after export macros, keeps the struct tag when a typedef body continues on later lines, and accepts one-line prototypes at the top level or after a modifier. The JavaScript grammar maps as to an Alias rule, so export * as Name from defines Name.


Source line Before After
class BASE_EXPORT CommandLine { Not a definition Defines CommandLine
struct COMPONENT_EXPORT(NETWORK_CPP) Foo { Not a definition Defines Foo
typedef struct AVCodecContext { (body on later lines) Not a definition Defines AVCodecContext
int av_read_frame(AVFormatContext *s, AVPacket *pkt); Not a definition (two-line form was) Defines av_read_frame
virtual void OnChanged(const Event& event); Not a definition Defines OnChanged
export * as SessionRetry from "./retry" Not a definition Defines SessionRetry
ret = av_read_frame(s, pkt);, static DEFINE_MUTEX(lock); Not a definition Not a definition
count * sizeof(T) Defined sizeof Not a definition

The rules stay in the grammar tables and generated checkers:

  • languages.rs maps the JavaScript keyword as to a new Alias action in rules.rs.
  • The C_TYPE branch of declaration_name skips all-caps export macros.
  • c_function accepts ); only at column 0 or after a grammar modifier, and never for an all-caps macro call.

Classifier latency per matched line, best of 7 passes over the same samples:

Corpus Samples Before After
C/C++ (FFmpeg libavcodec, libavformat, libavutil, Chromium base) 6.5M 21.5 ns 21.4 ns
TypeScript (opencode src folders) 1.24M 21.5 ns 21.7 ns
Rust (Nushell, unaffected) 1.0M 15.6 ns 15.7 ns

On the C/C++ corpus the classifier finds 86,050 definitions instead of 76,706. TypeScript gains every export * as re-export.

Note

Indented C++ member declarations without a modifier, such as void MaybeComplete();, stay unclassified, as on main. The out-of-line definition in the .cc file is classified.

Stacked on #931.

Stack merge order: #924, #925, #927, #928, #930, #931, #932, #940, #933, #934.

Summary by CodeRabbit

  • Bug Fixes
    • Improved definition matching for C and C++ export macros, typedefs, and function prototypes.
    • Improved recognition of TypeScript namespace re-exports and Zig @This() declarations.
    • JavaScript alias exports are now recognized more reliably, including aliases declared after modifiers.
    • C and C++ type declarations are less likely to be mistaken for function definitions.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a18489f-9f67-4a94-a9c4-529cd473e6a0
📥 Commits

Reviewing files that changed from the base of the PR and between 2e449b8 and 206f796.

📒 Files selected for processing: 4
  • crates/fff-core/src/definition/languages.rs
  • crates/fff-core/src/definition/mod.rs
  • crates/fff-core/src/definition/parser.rs
  • crates/fff-core/src/definition/rules.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The parser changes add C/C++ export-macro, prototype, and typedef-tag handling. JavaScript rules recognize TypeScript namespace re-export aliases. Tests cover these cases and Zig declarations with fuzzy matching enabled and disabled.

Changes: Definition matching

Layer / File(s) Summary
C/C++ declaration recognition
crates/fff-core/src/definition/parser.rs, crates/fff-core/src/definition/mod.rs
C/C++ parsing handles macro-prefixed type names and distinguishes function prototypes from other semicolon-terminated constructs. Tests cover export macros, prototypes, and excluded forms.
Typedef tag parsing
crates/fff-core/src/definition/parser.rs, crates/fff-core/src/definition/mod.rs
Typedef parsing recognizes struct, union, and enum tags, including attributes and bodies that continue on later lines. Tests cover named and anonymous forms.
Namespace exports and cross-language tests
crates/fff-core/src/definition/languages.rs, crates/fff-core/src/definition/rules.rs, crates/fff-core/src/definition/mod.rs
JavaScript alias rules recognize TypeScript namespace re-export names. Tests cover TypeScript and Zig declarations and check fuzzy and exact matching.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 206f7

This change widens definition recognition for C/C++ and TypeScript. The supplied evidence shows no actionable merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main definition-classifier fixes: export macros, typedef bodies, top-level prototypes, and namespace re-exports.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

…evel prototypes, and namespace re-exports

The C grammar skips all-caps export macros before a type name, keeps the struct tag when a typedef body continues on later lines, and accepts one-line prototypes at the top level or after a modifier. JavaScript maps `as` to an Alias rule, so `export * as Name from` defines Name.
…eywords

Indented one-line declarations count only after virtual or explicit, so locals built with arguments stay out. A parenthesised attribute before a typedef tag is skipped, and asm, volatile, __attribute__, __declspec and alignas are never declared names.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant