← Back to Pull requests

[ffigen] [jnigen] Util to dump entire parsed API #3621

Open
amanmaurya92 opened this pull request with 594 lines diff across 15 files
View on GitHub
amanmaurya92 amanmaurya92 commented on Sep 08, 2026 08:39 UTC
Author

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:

  • Adds ApiDumperVisitor to package:ffigen to traverse and format all public AST declarations into a clear, greppable format (Node(name, USR/parent)).

  • Adds dumpApi({StringSink? sink, Logger? logger, Uri? libclangDylib}) extension method on FfiGenerator that parses headers without writing output binding files.

  • Adds matching ApiDumperVisitor and dumpApi({StringSink? sink, Logger? logger}) on JniGenerator in package:jnigen to dump Java classes, methods, parameters, and fields.

  • Adds comprehensive unit tests in both pkgs/ffigen and pkgs/jnigen covering synthetic AST node dumping and end-to-end header parsing.

  • Updates CHANGELOG.md for both packages.
  • Related Issues

    Fixes https://github.com/dart-lang/native/issues/3605

    PR Checklist

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.

  • I've run dart tool/ci.dart --all locally 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 toplevel pubspec.yaml workspace.

  • All existing and new tests are passing. I added new tests to check the change I am making.

  • The PR is actually solving the issue. PRs that don't solve the issue will be closed. Please be respectful of the maintainers' time. If it's not clear what the issue is, feel free to ask questions on the GitHub issue before submitting a PR.

  • I have updated CHANGELOG.md for the relevant packages. (Not needed for small changes such as doc typos).

  • I have updated the pubspec package version if necessary.
  • Diff: 594 lines (+584 / -10) across 15 files Reviewer: liamappelbe Review duration: 63657m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.69) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.69 · 594 lines diff across 15 files
    0.69
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.88 · 5 substantive comment(s)
    0.88
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.382
    Real PR Conversation Timeline
    22 items
    liamappelbe liamappelbe commented on code on Sep 09, 2026 01:39 UTC
    Code Review
    pkgs/ffigen/lib/src/config_provider/api_dumper.dart:1
    @@ -0,0 +1,146 @@
    +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
    +// for details. All rights reserved. Use of this source code is governed by a
    +// BSD-style license that can be found in the LICENSE file.
    +
    +import 'dart:io';
    +
    +import 'public_ast.dart';
    +
    +/// A visitor that dumps all visited AST nodes in a concise, greppable format.
    +///
    +/// Output format examples:
    +/// ```text
    +/// Func(originalName, USR)
    +/// Param(Func(originalName, USR), paramName)
    +/// Struct(originalName, USR)
    +/// Field(Struct(originalName, USR), fieldName)
    +/// ObjCInterface(originalName, USR)
    +/// ObjCMethod(ObjCInterface(originalName, USR), selector)
    +/// ```
    +final class ApiDumperVisitor extends Visitor {
    +  final StringSink _sink;
    +
    +  /// Creates an [ApiDumperVisitor] that writes to [sink] (defaults to
    +  /// [stdout]).
    +  ApiDumperVisitor([StringSink? sink]) : _sink = sink ?? stdout, super.base();
    +
    +  /// Dumps all [nodes] and returns the formatted output string.
    +  static String dump(Iterable<AstNode> nodes) {
    +    final buffer = StringBuffer();
    +    final visitor = ApiDumperVisitor(buffer);
    +    visitor.visitAll(nodes);
    +    return buffer.toString();
    +  }
    +
    +  static String _declString(DeclNode decl) {
    +    if (decl is ObjCCategory) {
    +      final interfaceStr = _declString(decl.interface);
    +      return 'ObjCCategory($interfaceStr, ${decl.originalName}, ${decl.usr})';

    Looking at the outputs in the test, I think it'd be more readable to put the $interfaceStr last. Same with the parents below.

    liamappelbe liamappelbe commented on code on Sep 09, 2026 01:55 UTC
    Code Review
    pkgs/ffigen/lib/src/config_provider/api_dumper.dart:1
    @@ -0,0 +1,146 @@
    +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
    +// for details. All rights reserved. Use of this source code is governed by a
    +// BSD-style license that can be found in the LICENSE file.
    +
    +import 'dart:io';
    +
    +import 'public_ast.dart';
    +
    +/// A visitor that dumps all visited AST nodes in a concise, greppable format.
    +///
    +/// Output format examples:
    +/// ```text
    +/// Func(originalName, USR)
    +/// Param(Func(originalName, USR), paramName)
    +/// Struct(originalName, USR)
    +/// Field(Struct(originalName, USR), fieldName)
    +/// ObjCInterface(originalName, USR)
    +/// ObjCMethod(ObjCInterface(originalName, USR), selector)
    +/// ```
    +final class ApiDumperVisitor extends Visitor {
    +  final StringSink _sink;
    +
    +  /// Creates an [ApiDumperVisitor] that writes to [sink] (defaults to
    +  /// [stdout]).
    +  ApiDumperVisitor([StringSink? sink]) : _sink = sink ?? stdout, super.base();
    +
    +  /// Dumps all [nodes] and returns the formatted output string.
    +  static String dump(Iterable<AstNode> nodes) {
    +    final buffer = StringBuffer();
    +    final visitor = ApiDumperVisitor(buffer);
    +    visitor.visitAll(nodes);
    +    return buffer.toString();
    +  }
    +
    +  static String _declString(DeclNode decl) {
    +    if (decl is ObjCCategory) {

    Looks like this special casing exists here because ObjCMethod.parent can be either a ObjCInterface or ObjCCategory. So it would be better to do that special casing in visitObjCMethod:

    @override
    void visitObjCMethod(ObjCMethod node) {
      _sink.writeln('ObjCMethod(${_objCMethodParent(node.parent)}, ${node.selector})');
    }
    
    static String _objCMethodParent(DeclNode node) => switch(node) {
      ObjCInterface i => _visitObjCInterface(i),
      ObjCCategory c => _visitObjCCategory(c),
    };
    
    @override
    void visitObjCInterface(ObjCInterface node) {
      _sink.writeln(_visitObjCInterface(node));
    }
    
    static String _visitObjCInterface(ObjCInterface node) => _declString(node);
    
    static String _declString(DeclNode decl) =>
      '${decl.runtimeType}(${decl.originalName}, ${decl.usr})';
    

    Same for _namedNodeString.

    liamappelbe liamappelbe commented on code on Sep 09, 2026 01:58 UTC
    Code Review
    pkgs/ffigen/lib/src/config_provider/config.dart:1
    @@ -133,6 +133,20 @@ final class FfiGenerator {
           this,
         ).generate(logger: logger, libclangDylib: libclangDylib);
       }
    +
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.

    I think the API should do one or the other: return the string or print to the sink. We don't need both.

    liamappelbe liamappelbe commented on code on Sep 09, 2026 02:00 UTC
    Code Review
    pkgs/ffigen/lib/src/ffigen.dart:1
    @@ -8,13 +8,48 @@ import 'package:cli_util/cli_logging.dart' show Ansi;
     import 'package:logging/logging.dart';
     
     import 'config_provider.dart' show FfiGenerator;
    +import 'config_provider/api_dumper.dart';
     import 'context.dart';
     import 'header_parser.dart' show parse;
     import 'logger.dart';
     
     final _ansi = Ansi(Ansi.terminalSupportsAnsi);
     
     extension FfiGenGenerator on FfiGenerator {
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.
    +  Future<String> dumpApi({
    +    StringSink? sink,
    +    Logger? logger,
    +    Uri? libclangDylib,
    +  }) async {
    +    logger ??= createDefaultLogger();
    +    final buffer = StringBuffer();
    +    final dumper = ApiDumperVisitor(buffer);
    +
    +    final dumperConfig = FfiGenerator(
    +      input: input,
    +      cpp: cpp,
    +      objectiveC: objectiveC,
    +      output: output,
    +      visitors: [...visitors, dumper],

    Why run the user visitors here?

    liamappelbe liamappelbe commented on code on Sep 09, 2026 02:10 UTC
    Code Review
    pkgs/ffigen/CHANGELOG.md:1
    @@ -38,6 +38,7 @@
       ObjC category methods returning `instancetype` are filtered.
     - Minor Objective-C code generator and function type signature fixes.
     - Bump `package:code_assets` dependency to `^2.0.0`.
    +- Add `dumpApi` utility and `ApiDumperVisitor` to dump entire parsed AST.

    v22 is already out. You'll need to bump the version to 22.1.0-wip, here and in the pubspec.

    liamappelbe liamappelbe commented on code on Sep 09, 2026 02:11 UTC
    Code Review
    pkgs/jnigen/lib/src/elements/api_dumper.dart:1
    @@ -0,0 +1,66 @@
    +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
    +// for details. All rights reserved. Use of this source code is governed by a
    +// BSD-style license that can be found in the LICENSE file.
    +
    +import 'dart:io';
    +
    +import 'j_elements.dart';
    +
    +/// A visitor that dumps all visited Java AST nodes in a concise, greppable
    +/// format.
    +///
    +/// Output format examples:
    +/// ```text
    +/// ClassDecl(java.lang.Object)
    +/// Method(ClassDecl(java.lang.Object), toString)
    +/// Param(Method(ClassDecl(java.lang.Object), equals), obj)
    +/// Field(ClassDecl(com.example.MyClass), myField)
    +/// ```
    +final class ApiDumperVisitor extends Visitor {
    +  final StringSink _sink;
    +  ClassDecl? _currentClass;
    +  Method? _currentMethod;
    +
    +  /// Creates an [ApiDumperVisitor] that writes to [sink] (defaults to
    +  /// [stdout]).
    +  ApiDumperVisitor([StringSink? sink])
    +      : _sink = sink ?? stdout,
    +        super.base();
    +
    +  /// Dumps all [classes] and returns the formatted output string.
    +  static String dump(Classes classes) {
    +    final buffer = StringBuffer();
    +    final visitor = ApiDumperVisitor(buffer);
    +    classes.accept(visitor);
    +    return buffer.toString();
    +  }
    +
    +  @override
    +  void visitClass(ClassDecl c) {
    +    _currentClass = c;
    +    _sink.writeln('ClassDecl(${c.binaryName})');
    +  }
    +
    +  @override
    +  void visitMethod(Method method) {
    +    _currentMethod = method;
    +    final parentName = _currentClass?.binaryName ?? 'unknown';
    +    _sink.writeln('Method(ClassDecl($parentName), ${method.originalName})');
    +  }
    +
    +  @override
    +  void visitField(Field field) {
    +    final parentName = _currentClass?.binaryName ?? 'unknown';
    +    _sink.writeln('Field(ClassDecl($parentName), ${field.originalName})');
    +  }
    +
    +  @override
    +  void visitParam(Param parameter) {
    +    final parentClass = _currentClass?.binaryName ?? 'unknown';
    +    final parentMethod = _currentMethod?.originalName ?? 'unknown';
    +    _sink.writeln(
    +      'Param(Method(ClassDecl($parentClass), $parentMethod), '

    DRY. Reuse the logic from visitMethod.

    liamappelbe liamappelbe commented on code on Sep 09, 2026 02:12 UTC
    Code Review
    pkgs/jnigen/lib/src/elements/api_dumper.dart:1
    @@ -0,0 +1,66 @@
    +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
    +// for details. All rights reserved. Use of this source code is governed by a
    +// BSD-style license that can be found in the LICENSE file.
    +
    +import 'dart:io';
    +
    +import 'j_elements.dart';
    +
    +/// A visitor that dumps all visited Java AST nodes in a concise, greppable
    +/// format.
    +///
    +/// Output format examples:
    +/// ```text
    +/// ClassDecl(java.lang.Object)
    +/// Method(ClassDecl(java.lang.Object), toString)
    +/// Param(Method(ClassDecl(java.lang.Object), equals), obj)
    +/// Field(ClassDecl(com.example.MyClass), myField)
    +/// ```
    +final class ApiDumperVisitor extends Visitor {
    +  final StringSink _sink;
    +  ClassDecl? _currentClass;
    +  Method? _currentMethod;
    +
    +  /// Creates an [ApiDumperVisitor] that writes to [sink] (defaults to
    +  /// [stdout]).
    +  ApiDumperVisitor([StringSink? sink])
    +      : _sink = sink ?? stdout,
    +        super.base();
    +
    +  /// Dumps all [classes] and returns the formatted output string.
    +  static String dump(Classes classes) {
    +    final buffer = StringBuffer();
    +    final visitor = ApiDumperVisitor(buffer);
    +    classes.accept(visitor);
    +    return buffer.toString();
    +  }
    +
    +  @override
    +  void visitClass(ClassDecl c) {
    +    _currentClass = c;
    +    _sink.writeln('ClassDecl(${c.binaryName})');
    +  }
    +
    +  @override
    +  void visitMethod(Method method) {
    +    _currentMethod = method;
    +    final parentName = _currentClass?.binaryName ?? 'unknown';
    +    _sink.writeln('Method(ClassDecl($parentName), ${method.originalName})');

    DRY. Reuse the logic from visitClass.

    liamappelbe liamappelbe commented on code on Sep 09, 2026 02:12 UTC
    Code Review
    pkgs/jnigen/lib/src/elements/api_dumper.dart:1
    @@ -0,0 +1,66 @@
    +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
    +// for details. All rights reserved. Use of this source code is governed by a
    +// BSD-style license that can be found in the LICENSE file.
    +
    +import 'dart:io';
    +
    +import 'j_elements.dart';
    +
    +/// A visitor that dumps all visited Java AST nodes in a concise, greppable
    +/// format.
    +///
    +/// Output format examples:
    +/// ```text
    +/// ClassDecl(java.lang.Object)
    +/// Method(ClassDecl(java.lang.Object), toString)
    +/// Param(Method(ClassDecl(java.lang.Object), equals), obj)
    +/// Field(ClassDecl(com.example.MyClass), myField)
    +/// ```
    +final class ApiDumperVisitor extends Visitor {
    +  final StringSink _sink;
    +  ClassDecl? _currentClass;
    +  Method? _currentMethod;
    +
    +  /// Creates an [ApiDumperVisitor] that writes to [sink] (defaults to
    +  /// [stdout]).
    +  ApiDumperVisitor([StringSink? sink])
    +      : _sink = sink ?? stdout,
    +        super.base();
    +
    +  /// Dumps all [classes] and returns the formatted output string.
    +  static String dump(Classes classes) {
    +    final buffer = StringBuffer();
    +    final visitor = ApiDumperVisitor(buffer);
    +    classes.accept(visitor);
    +    return buffer.toString();
    +  }
    +
    +  @override
    +  void visitClass(ClassDecl c) {
    +    _currentClass = c;
    +    _sink.writeln('ClassDecl(${c.binaryName})');
    +  }
    +
    +  @override
    +  void visitMethod(Method method) {
    +    _currentMethod = method;
    +    final parentName = _currentClass?.binaryName ?? 'unknown';
    +    _sink.writeln('Method(ClassDecl($parentName), ${method.originalName})');

    As in the FFIgen one, move the method name to the start.

    amanmaurya92 amanmaurya92 commented on code on Sep 09, 2026 05:00 UTC
    Code Review
    pkgs/ffigen/lib/src/config_provider/config.dart:1
    @@ -133,6 +133,20 @@ final class FfiGenerator {
           this,
         ).generate(logger: logger, libclangDylib: libclangDylib);
       }
    +
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.

    The dual behavior was for convenience, but doing one or the other makes complete sense for a cleaner API. so between:
    Future<String> dumpApi(...) and
    Future<void> dumpApi({StringSink? sink})
    Which do you prefer? I was leaning more towards Future<String> dumpApi(...).

    liamappelbe liamappelbe commented on code on Sep 10, 2026 00:25 UTC
    Code Review
    pkgs/ffigen/lib/src/config_provider/config.dart:1
    @@ -133,6 +133,20 @@ final class FfiGenerator {
           this,
         ).generate(logger: logger, libclangDylib: libclangDylib);
       }
    +
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.

    Yeah, I think returning a String makes more sense.

    amanmaurya92 amanmaurya92 commented on code on Sep 10, 2026 03:56 UTC
    Code Review
    pkgs/ffigen/lib/src/config_provider/config.dart:1
    @@ -133,6 +133,20 @@ final class FfiGenerator {
           this,
         ).generate(logger: logger, libclangDylib: libclangDylib);
       }
    +
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.

    I have addressed that now. thanks

    amanmaurya92 amanmaurya92 commented on code on Sep 10, 2026 04:00 UTC
    Code Review
    pkgs/ffigen/lib/src/ffigen.dart:1
    @@ -8,13 +8,48 @@ import 'package:cli_util/cli_logging.dart' show Ansi;
     import 'package:logging/logging.dart';
     
     import 'config_provider.dart' show FfiGenerator;
    +import 'config_provider/api_dumper.dart';
     import 'context.dart';
     import 'header_parser.dart' show parse;
     import 'logger.dart';
     
     final _ansi = Ansi(Ansi.terminalSupportsAnsi);
     
     extension FfiGenGenerator on FfiGenerator {
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.
    +  Future<String> dumpApi({
    +    StringSink? sink,
    +    Logger? logger,
    +    Uri? libclangDylib,
    +  }) async {
    +    logger ??= createDefaultLogger();
    +    final buffer = StringBuffer();
    +    final dumper = ApiDumperVisitor(buffer);
    +
    +    final dumperConfig = FfiGenerator(
    +      input: input,
    +      cpp: cpp,
    +      objectiveC: objectiveC,
    +      output: output,
    +      visitors: [...visitors, dumper],

    My idea was that if a user has configured renaming or filtering visitors, running them before dumper allows dumpApi() to inspect the AST in the exact state when the code generator will see it (consistent with how jnigen runs visitors before dumper in generate_bindings.dart). if you prefer I can remove it or keep visitors: [dumper].

    liamappelbe liamappelbe commented on code on Sep 10, 2026 04:26 UTC
    Code Review
    pkgs/ffigen/lib/src/ffigen.dart:1
    @@ -8,13 +8,48 @@ import 'package:cli_util/cli_logging.dart' show Ansi;
     import 'package:logging/logging.dart';
     
     import 'config_provider.dart' show FfiGenerator;
    +import 'config_provider/api_dumper.dart';
     import 'context.dart';
     import 'header_parser.dart' show parse;
     import 'logger.dart';
     
     final _ansi = Ansi(Ansi.terminalSupportsAnsi);
     
     extension FfiGenGenerator on FfiGenerator {
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.
    +  Future<String> dumpApi({
    +    StringSink? sink,
    +    Logger? logger,
    +    Uri? libclangDylib,
    +  }) async {
    +    logger ??= createDefaultLogger();
    +    final buffer = StringBuffer();
    +    final dumper = ApiDumperVisitor(buffer);
    +
    +    final dumperConfig = FfiGenerator(
    +      input: input,
    +      cpp: cpp,
    +      objectiveC: objectiveC,
    +      output: output,
    +      visitors: [...visitors, dumper],

    I can see the utility in that, but I don't think it will work. At least not the way you have it written currently.

    In FFIgen, later visitors still see nodes that have been filtered out by earlier visitors, so this won't actually show which nodes are filtered. You could fix this by only printing the node if isIncluded, or printing "X " or something at the start of the line if the node isn't included. This is an inconsistency with JNIgen, so maybe we should change the visitor infra to skip nodes that are filtered, but it's tricky because we filter almost all nodes out by default, so the first visitor wouldn't see anything :upside_down_face:.

    As for renames, you're printing the originalName, not the name, so these changes won't be visible either. As it stands now I don't think any of the user visitors can have any visible effect on the dumpApi output.

    In any case, if this is a use case you want to support, you'll need to write tests for it.

    amanmaurya92 amanmaurya92 commented on code on Sep 10, 2026 04:30 UTC
    Code Review
    pkgs/ffigen/lib/src/ffigen.dart:1
    @@ -8,13 +8,48 @@ import 'package:cli_util/cli_logging.dart' show Ansi;
     import 'package:logging/logging.dart';
     
     import 'config_provider.dart' show FfiGenerator;
    +import 'config_provider/api_dumper.dart';
     import 'context.dart';
     import 'header_parser.dart' show parse;
     import 'logger.dart';
     
     final _ansi = Ansi(Ansi.terminalSupportsAnsi);
     
     extension FfiGenGenerator on FfiGenerator {
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.
    +  Future<String> dumpApi({
    +    StringSink? sink,
    +    Logger? logger,
    +    Uri? libclangDylib,
    +  }) async {
    +    logger ??= createDefaultLogger();
    +    final buffer = StringBuffer();
    +    final dumper = ApiDumperVisitor(buffer);
    +
    +    final dumperConfig = FfiGenerator(
    +      input: input,
    +      cpp: cpp,
    +      objectiveC: objectiveC,
    +      output: output,
    +      visitors: [...visitors, dumper],

    Ohh okay, 😅 must have missed that. I will look into it more

    amanmaurya92 amanmaurya92 commented on code on Sep 10, 2026 04:50 UTC
    Code Review
    pkgs/ffigen/lib/src/ffigen.dart:1
    @@ -8,13 +8,48 @@ import 'package:cli_util/cli_logging.dart' show Ansi;
     import 'package:logging/logging.dart';
     
     import 'config_provider.dart' show FfiGenerator;
    +import 'config_provider/api_dumper.dart';
     import 'context.dart';
     import 'header_parser.dart' show parse;
     import 'logger.dart';
     
     final _ansi = Ansi(Ansi.terminalSupportsAnsi);
     
     extension FfiGenGenerator on FfiGenerator {
    +  /// Parses the headers according to this config and dumps all user-visible
    +  /// AST nodes to [sink] (or stdout if not provided).
    +  ///
    +  /// Returns the formatted dump string.
    +  Future<String> dumpApi({
    +    StringSink? sink,
    +    Logger? logger,
    +    Uri? libclangDylib,
    +  }) async {
    +    logger ??= createDefaultLogger();
    +    final buffer = StringBuffer();
    +    final dumper = ApiDumperVisitor(buffer);
    +
    +    final dumperConfig = FfiGenerator(
    +      input: input,
    +      cpp: cpp,
    +      objectiveC: objectiveC,
    +      output: output,
    +      visitors: [...visitors, dumper],

    and you're completely right. I verified the parser pipeline. user visitors don't have any visible effect on the output anyway. I've updated dumpApi to only run dumper in both ffigen and jnigen.

    amanmaurya92 amanmaurya92 commented on Sep 12, 2026 12:49 UTC
    Author

    @liamappelbe all CI are green now, please merge this, as this is my first pr here 😄. I appreciate your guidance.

    liamappelbe liamappelbe commented on code on Sep 14, 2026 01:35 UTC
    Code Review
    pkgs/jnigen/lib/src/elements/j_elements.dart:1
    @@ -153,6 +153,9 @@ class Method implements _Element {
       /// Whether this method is a constructor.
       bool get isConstructor => _method.isConstructor;
     
    +  /// The method descriptor (e.g. `(Ljava/lang/String;)V`), if available.

    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.

    liamappelbe liamappelbe commented on code on Sep 14, 2026 01:38 UTC
    Code Review
    pkgs/jnigen/lib/src/generate_bindings.dart:1
    @@ -26,6 +27,38 @@ void collectOutputStream(Stream<List<int>> stream, StringBuffer buffer) =>
         stream.transform(const Utf8Decoder()).forEach(buffer.write);
     
     extension JniGenGenerator on JniGenerator {
    +  /// Parses the Java input according to this config and dumps all user-visible
    +  /// AST nodes.
    +  ///
    +  /// Returns the formatted dump string.
    +  Future<String> dumpApi({Logger? logger}) async {
    +    logger ??= createDefaultLogger();

    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.

    liamappelbe liamappelbe commented on code on Sep 14, 2026 01:40 UTC
    Code Review
    pkgs/jnigen/CHANGELOG.md:1
    @@ -30,6 +30,7 @@
     - 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.

    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 https://github.com/dart-lang/native/pull/3627, you at least won't need to update all the bindings files 😅

    liamappelbe liamappelbe commented on Sep 14, 2026 01:43 UTC
    Reviewer

    Almost there. Just a few more details.

    amanmaurya92 amanmaurya92 commented on Oct 12, 2026 10:12 UTC
    Author

    @liamappelbe I have addressed every suggestion. please take a look and approve

    Reviewers
    Assignees
    amanmaurya92 amanmaurya92
    Labels
    risk: low confidence: 88.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 68.7% (HIGH) · Higher = larger blast radius
    68.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 88.3% · Lower = rushed or shallow review
    88.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.1% · Safe to merge
    8.1%