Feat: 'Default' @ExtensionMethod extensions - #4010
Open
screret wants to merge 3 commits into
Open
Conversation
Contributor
|
This is definitely going to need tests. The I'd also be interested in what performance impact there could potentially be having something apply by default. |
Collaborator
|
I implemented something similar years ago: Rawi01@516e0c7 If I remember correctly it slows down compilation and @rzwitserloot was not happy about that. |
Contributor
This is what I would suspect. Doing extension functions is probably way more efficient as part of the compile stage rather than as an annotation processing step. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces the
lombok.extensionMethod.defaultExtensionsandlombok.extensionMethod.suppressBaseMethodsconfiguration keys, allowing extension method usage without explicitly applying@ExtensionMethod({MyExtensions.class, MyExtensions2.class, ...})to every class via lombok.config.Using the annotation still requires explicitly defining an extension, but it can be left empty if one (for whatever reason) only wants to change the
suppressBaseMethodsvalue for a class.If
suppressBaseMethodsisn't defined, the configuration value is applied (default: true).Extensions in the
lombok.extensionMethod.suppressBaseMethodsconfiguration are applied in addition to explicitly defined ones. As far as I can tell, defining an extension twice doesn't have any adverse effects.Changes
HandleExtensionMethodan AST adapter.Additional Information
The code is loosely based on
HandleFieldDefaults.I did not fix the Eclipse handler, because I don't know how, and I assume you know better than I do.
Getting the project to compile was surprisingly annoying, though that might just be me not wanting to use Eclipse. IntelliJ wasn't happy with the java 6 requirement and duplicate dependency classes, but I got it working.
Sometimes I had to delete a stub class, recompile, and add the stub back. That made it mysteriously work 10/10 times. It worked, though, so I'm not complaining.