Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial support Lombok for java 8 (mostly done) #4855

Merged
merged 29 commits into from
Jan 10, 2025
Merged

Partial support Lombok for java 8 (mostly done) #4855

merged 29 commits into from
Jan 10, 2025

Conversation

jevanlingen
Copy link
Contributor

@jevanlingen jevanlingen commented Jan 7, 2025

What's changed?

  • Java 8 parser can parse Lombok code as well.
  • Other improvements
    • Lombok parser code optimised for all java parsers
    • Improved Lombok tests
    • Renamed all JavacAnnotationHandler without an action to <LombokAnnotation>NoOpHandler (half of the JavacAnnotationHandler classes that had this behavior were already named that way)

What's does not work yet?

  • @AllArgsConstructorHandler, @NoArgsConstructorHandler and @NoArgsConstructorHandler with the onConstructor_ param.
  • @Jacksonized

Further research should be done in a follow up ticket. The rest of this code is good as it is and is mergeable. Especially since the onX feature is still very much in the experimental status and @Jacksonized is not used that often.

What's your motivation?

Any additional context

I tried to bring the Java 8 and Java 17 code as close to each other as possible. That's why I added the parseInputsToCompilerAst method and removed the custom Todo class (just like the java 11, 17 and 21 parser).

Furthermore I squeezed the lombok code in all parsers as much as possible. By having just one isLombokGenerated method which works for whatever com.sun.source.tree.Tree as input, the code is easier to follow.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

github-actions[bot]

This comment was marked as resolved.

@timtebeek timtebeek added the enhancement New feature or request label Jan 8, 2025
@jevanlingen jevanlingen changed the title Support Lombok for java 8 Partial support Lombok for java 8 (mostly done) Jan 9, 2025
@jevanlingen jevanlingen marked this pull request as ready for review January 9, 2025 16:21
# Conflicts:
#	rewrite-java-17/src/main/java/org/openrewrite/java/isolated/ReloadableJava17ParserVisitor.java
#	rewrite-java-21/src/main/java/org/openrewrite/java/isolated/ReloadableJava21ParserVisitor.java
#	rewrite-java-8/src/main/java/org/openrewrite/java/ReloadableJava8ParserVisitor.java
@timtebeek timtebeek requested a review from sambsnyd January 9, 2025 17:49
@timtebeek timtebeek merged commit 50d160e into main Jan 10, 2025
2 checks passed
@timtebeek timtebeek deleted the lombok-java-8 branch January 10, 2025 09:07
sambsnyd pushed a commit that referenced this pull request Jan 15, 2025
* Support Lombok for java 8

* Support Lombok for java 8

* Support Lombok for java 8

* Add rewrite-java-lombok to classpath

* Improve message

* Remove `TimedTodo` to be more like the other java parsers

* cleanup

* Add JavaCompiler `delegate` fix

* Support Lomboks `var` and `val` for Java 8

* Cleanup

* Cleanup

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup

* Improve `onConstructor` and `onConstructorNoArgs` args

* Fix missing `onConstructor_` check

* Cleanup

* Apply suggestions from code review

Co-authored-by: Knut Wannheden <[email protected]>

* Improve tests

* Merge branch 'main' into lombok-java-8

* Rename JavacAnnotationHandler with no action to XNoOpHandler

* Rename JavacAnnotationHandler with no action to XNoOpHandler

* Improve lomboks `ExampleException` test

---------

Co-authored-by: Knut Wannheden <[email protected]>
sambsnyd pushed a commit that referenced this pull request Jan 15, 2025
* Support Lombok for java 8

* Support Lombok for java 8

* Support Lombok for java 8

* Add rewrite-java-lombok to classpath

* Improve message

* Remove `TimedTodo` to be more like the other java parsers

* cleanup

* Add JavaCompiler `delegate` fix

* Support Lomboks `var` and `val` for Java 8

* Cleanup

* Cleanup

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup of `isLombokGenerated` methods

* Cleanup

* Improve `onConstructor` and `onConstructorNoArgs` args

* Fix missing `onConstructor_` check

* Cleanup

* Apply suggestions from code review

Co-authored-by: Knut Wannheden <[email protected]>

* Improve tests

* Merge branch 'main' into lombok-java-8

* Rename JavacAnnotationHandler with no action to XNoOpHandler

* Rename JavacAnnotationHandler with no action to XNoOpHandler

* Improve lomboks `ExampleException` test

---------

Co-authored-by: Knut Wannheden <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parser-java
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants