[jnigen] Expose editable documentation on the visitor API #3496 - #3602
[jnigen] Expose editable documentation on the visitor API #3496#3602AzazelSensei wants to merge 2 commits into
Conversation
Visitors can replace, insert, or clear documentation on classes, methods, fields, and parameters. Custom docs that omit @deprecated still pick up the original tag for Dart @deprecated. Fixes dart-lang#3496
| if (GenerationStage.renamer <= until) { | ||
| cloned.finalName = finalName; | ||
| } | ||
| cloned.userDefinedName = userDefinedName; |
There was a problem hiding this comment.
Match the logic in Method.clone: only clone the userDefined* things if GenerationStage.userVisitor <= until
| import 'resolver.dart'; | ||
| import 'visitor.dart'; | ||
|
|
||
| JavaDocComment? _docsFor(JavaDocComment? original, String? userDefined) { |
There was a problem hiding this comment.
It might be cleaner to store the user defined javadoc inside the JavaDocComment, rather than constructing all these temp JavaDocComment objects. Probably also makes sense to rename the field to JavaDocComment.userDefinedComment and rename JavaDocComment.comment to originalComment.
That would also let you simplify this pattern: _classDecl.userDefinedJavadoc ?? _classDecl.javadoc?.comment ?? ''. You could add a getter named comment that does userDefinedJavadoc ?? originalComment. Then that original pattern would become _classDecl.javadoc?.comment ?? ''`.
|
Analysis error is preventing the tests from running. Make sure to |
Keep originalComment and userDefinedComment on the same node so the generator does not build throwaway copies. Param.clone now copies userDefined fields only when the clone includes the user visitor stage. Fixes analyze prefer_const_constructors in the visitor docs test.
|
Pushed a follow-up. Visitor docs now live on JavaDocComment as originalComment/userDefinedComment, Param.clone only copies userDefined fields when that stage is included, and the test uses a const Annotation so analyze is clean. |
Description
The visitor API could rename or exclude members but not touch Javadoc. I exposed a
documentationstring on classes, methods, fields, and parameters so a visitor can replace, insert, or drop comments. If the new text has no@deprecatedtag, the original one is still used for Dart@Deprecated.Related Issues
Fixes #3496
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).