Skip to content

Conversation

@sergehuber
Copy link

Hello, first of all thanks a lot for your great tool, it has been tremendously useful for my project, where we also need to generate Typescript definition files from Java code to use with GraalJS.

Our needs were a bit different, we wanted to be able to generate a minimal API, to avoid exposing too many classes and methods to the Javascript engine. So I modified the project to add options that would make it easier to control how the generation works. I have also fixed a small bug where in the blacklist if you added a string such as "javax.servlet.HttpServlet" it would also blacklist "javax.servlet.HttpServletRequest", "javax.http.HttpServletRequestWrapper" and any other classes that contained the blacklist string. I changed to use regular expressions as I have done with all the new options I have added.

I have updated the README to document all the new options.

I hope you will find these improvements useful.

Regards,
Serge...

* --emitReadOnly : if set, deactivates constructors and setter in the generated types
* --excludeMethods : a list of regular expressions that will be used to exclude methods by name
Added some build and launch scripts to download all the resources needed for the npm-modules-engine configuration
Upgraded Gradle
Updated gitignore file with more files to ignore
…hod names (including the fully qualified class name) to filter methods.

Added new options :
--groupByDomain : if set, the generated types will be grouped by domain, if not set the output will instead be grouped by module name
* --useGettersAndSetters : if set, Typescript getters and setters will be used to group methods into setters and getters. If not set this mechanism is disabled and no intelligence will be performed to regroup getter and setter methods.
Improved launch script so that it can also patch the resulting output for issues due to the specific Java API that is being generated (for example to replace GraalVM ProxyObject and ProxyArray with real types)
Switched output to use interfaces almost everywhere instead of classes
…hod names (including the fully qualified class name) to filter methods.

Added new options :
--groupByDomain : if set, the generated types will be grouped by domain, if not set the output will instead be grouped by module name
* --useGettersAndSetters : if set, Typescript getters and setters will be used to group methods into setters and getters. If not set this mechanism is disabled and no intelligence will be performed to regroup getter and setter methods.
Improved launch script so that it can also patch the resulting output for issues due to the specific Java API that is being generated (for example to replace GraalVM ProxyObject and ProxyArray with real types)
Switched output to use interfaces almost everywhere instead of classes
- New methodWhitelist parameter that makes it possible to only include methods that were whitelisted. The methods can be listed using regular expressions allowing for example to group all getters using get.*
- New fieldWhitelist parameter that makes it possible to whitelist fields to include in classes, the same way that it is done for methods
- Changed useGettersAndSetters parameter name to gettersAndSettersOff to make it compatible by default with the old behavior.
- Renamed groupByDomain parameter to groupByModule so that the default behavior is the original one by default
- New flattenTypes parameter that, if activated, will copy all the methods from parent classes and interfaces into a type, and remove the hierarchy. This can be useful if you want to limit the number of types and don't care loosing the hierarchy of classes/interfaces
- New forceParentJavadocs parameter that will force the copy of parent javadoc into subclasses including the ones that only have an @inheritdoc annotation
- New rootTypes parameter that takes a list of root classes/interfaces. This list of classes/interfaces will be used to optimize the amount of generated types, since all the types that are not accessible from the roots will be automatically excluded from the generated types. This is very efficient at minimizing the amount of types and methods exposed
- New debugMatching parameter. If activated, it will print out logs about the matching process for the whitelist and blacklisting mechanism, making it easier to understand why a method is being filtered or not.
- Blacklist parameters has been changed (!) to use patterns as there was an issue when some classes started with the same beginning part such as javax.servlet.HttpServlet and javax.servlet.HttpServletRequest
- Added a new whitelist configuration to test and compare between the two systems. If it works well we will probably remove the old one.
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