Skip to content

[ffigen] Config update part 4: include visitor - #3530

Open
liamappelbe wants to merge 50 commits into
mainfrom
ffigen_config_update_4
Open

[ffigen] Config update part 4: include visitor#3530
liamappelbe wants to merge 50 commits into
mainfrom
ffigen_config_update_4

Conversation

@liamappelbe

@liamappelbe liamappelbe commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Migrate all .include and .includeMember config elements to .isIncluded AST fields. For the most part this is straightforward: add an isIncluded field to the internal AST nodes, expose it in the public AST, and replace the config callbacks in ApplyConfigFiltersVisitation with this field.

It becomes a little fiddly because we have to pick a single stage in the processing pipeline to run all the user's visitors. After a lot of playing around I eventually found a setup that preserves the status quo behaviour of the YAML configs (see parser.dart). In hindsight it's a pretty obvious place to put it: after CopyMethodsFromSuperTypesVisitation etc, so that the renaming/filtering sees the full AST, and just before ApplyConfigFiltersVisitation which consumes .isIncluded.

Fixed a minor bug where FindTransitiveDepsVisitation.transitives didn't included all the members of the initial search set. This wasn't a problem for the internal visitors, because they follow all of the links of the internal AST. But the user visitors only follow a few direct member links (eg interface -> method -> param), so allBindings really does need to contain all the bindings, if it's going to be the set that the user visitors iterate over.

Also, deleted a bunch of subconfigs that are now empty, and migrated all the existing configs in the monorepo.

I think it would make sense to refactor how Constants work, so that I don't have to expose them in the config AST, but I'll do that in a follow up to keep this PR simple.

@github-actions

Copy link
Copy Markdown

Package publishing

If you have publishing permissions, you can use the links below to publish the changes after merging this PR.

Package Version Status Publish tag (post-merge)
package:code_assets 1.3.0-wip WIP (no publish necessary)
package:data_assets 0.20.0 already published at pub.dev
package:ffi 2.2.0 already published at pub.dev
package:hooks 2.2.0-wip WIP (no publish necessary)
package:hooks_runner 1.6.2-wip WIP (no publish necessary)
package:jni_flutter 1.0.2 already published at pub.dev
package:jni_util 1.0.0 already published at pub.dev
package:native_toolchain_c 0.19.4-wip WIP (no publish necessary)
package:record_use 1.1.0 ready to publish record_use-v1.1.0
package:swift2objc 0.3.0-wip WIP (no publish necessary)
package:swiftgen 0.1.3 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
code_assets Non-Breaking 1.2.1 2.0.0-wip 2.0.0-wip ✔️
hooks_runner Non-Breaking 1.6.1 1.6.2-wip 1.6.2-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

@liamappelbe liamappelbe changed the title WIP [ffigen] Config update part 4: include visitor [ffigen] Config update part 4: include visitor Aug 14, 2026
@liamappelbe
liamappelbe marked this pull request as ready for review August 14, 2026 02:38
enums: const Enums(silenceWarning: true),
visitors: [
Visitor(
visitFunc: (node) => node.isIncluded = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: since it's a visitor already, would make make sense to drop "visit" and have func: and struct: to make it more concise?

/// Contains typealias for function type if [exposeFunctionTypedefs] is true.
Typealias? _exposedFunctionTypealias;

bool isIncluded = false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add a description to the PR which things are by default included and excluded?

E.g. toplevel things are by default excluded? Transitive things are by default opaque? And members by default included?

visitors: [
Visitor(
visitFunc: (node) =>
node.isIncluded = shouldIncludeNode('functionDecl', node),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: this would possibly more readable if shouldIncludeNode was called stableRandomInclude or something. Then it's immediately clear.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants