Repository navigation
[ffigen] [jnigen] Util to dump entire parsed API - #3621
amanmaurya92 wants to merge 1 commit into
Conversation
eede01e to
0cef6dc
Compare
0cef6dc to
fcec59a
Compare
fcec59a to
1eb6b7c
Compare
|
@liamappelbe all CI are green now, please merge this, as this is my first pr here 😄. I appreciate your guidance. |
liamappelbe
left a comment
There was a problem hiding this comment.
Almost there. Just a few more details.
| /// Whether this method is a constructor. | ||
| bool get isConstructor => _method.isConstructor; | ||
|
|
||
| /// The method descriptor (e.g. `(Ljava/lang/String;)V`), if available. |
There was a problem hiding this comment.
This change seems unrelated?
If you want to include it, it'll need a changelog entry. I'm also wondering why it's nullable. Under what circumstances would the descriptor not be available? It'll also need a test (for both the non-null and null cases). And at that point it should probably be a separate PR.
| /// | ||
| /// Returns the formatted dump string. | ||
| Future<String> dumpApi({Logger? logger}) async { | ||
| logger ??= createDefaultLogger(); |
There was a problem hiding this comment.
Most of this function duplicates line 67-96 of generate. Can you factor out the logic into a helper? Looks like the helper could just take a Logger? and return userClasses.
| - Allow interface mixin names to be customized using the visitor API. | ||
| - Support customizing the command `java -jar ApiSummarizer.jar` via the | ||
| `summarizer.command` field in config. | ||
| - Add `dumpApi` utility and `ApiDumperVisitor` to dump parsed Java AST. |
There was a problem hiding this comment.
Move this to the changelog entry for 1.0.1-wip, and bump it to 1.1.0-wip. You'll also need to update the jnigen pubspec, and I think there's a const variable somewhere in jnigen that holds the version too.
As of #3627, you at least won't need to update all the bindings files 😅
Description
When configuring FFIgen or JNIgen, users frequently encounter scenarios where expected API elements do not appear in the generated bindings (due to incorrect entry point headers, missing include paths, preprocessor flags, or misconfigured filters). Diagnosing this previously required users to construct custom AST visitor debug scripts from scratch.
This PR introduces a standardized AST dumping utility:
ApiDumperVisitortopackage:ffigento traverse and format all public AST declarations into a clear, greppable format (Node(name, USR/parent)).dumpApi({StringSink? sink, Logger? logger, Uri? libclangDylib})extension method onFfiGeneratorthat parses headers without writing output binding files.ApiDumperVisitoranddumpApi({StringSink? sink, Logger? logger})onJniGeneratorinpackage:jnigento dump Java classes, methods, parameters, and fields.pkgs/ffigenandpkgs/jnigencovering synthetic AST node dumping and end-to-end header parsing.CHANGELOG.mdfor both packages.Related Issues
Fixes #3605
PR Checklist
dart tool/ci.dart --alllocally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevelpubspec.yamlworkspace.CHANGELOG.mdfor the relevant packages. (Not needed for small changes such as doc typos).