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

Add new migration case of WebMvcConfigurer #616

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SiBorea
Copy link

@SiBorea SiBorea commented Nov 5, 2024

What's changed?

The origin recipe only handle classes that extend WebMvcConfigurer. In some cases, people return new WebMvcConfigurer() directly as a bean.

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

@timtebeek timtebeek added the enhancement New feature or request label Nov 5, 2024
Comment on lines +89 to +94
} else if (newClass.getClazz() instanceof J.ParameterizedType) {
J.ParameterizedType parameterizedType = (J.ParameterizedType) newClass.getClazz();
newClass = newClass.withClazz(parameterizedType
.withType(WEB_MVC_CONFIGURER_TYPE)
.withClazz(TypeTree.build(WEB_MVC_CONFIGURER).withType(WEB_MVC_CONFIGURER_TYPE))
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither WebMvcConfigurerAdapter nor WebMvcConfigurer takes in an generic type right? Would we even need the handling here then?

Suggested change
} else if (newClass.getClazz() instanceof J.ParameterizedType) {
J.ParameterizedType parameterizedType = (J.ParameterizedType) newClass.getClazz();
newClass = newClass.withClazz(parameterizedType
.withType(WEB_MVC_CONFIGURER_TYPE)
.withClazz(TypeTree.build(WEB_MVC_CONFIGURER).withType(WEB_MVC_CONFIGURER_TYPE))
);

Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see these additional cases covered! Thanks a lot for the continued work on improvements here.

A quick question and two code suggestions before we merge, but otherwise this looks perfect already.

Comment on lines +111 to +116
} else if (md.getReturnTypeExpression() instanceof J.ParameterizedType) {
J.ParameterizedType parameterizedType = (J.ParameterizedType) md.getReturnTypeExpression();
md = md.withReturnTypeExpression(parameterizedType
.withType(WEB_MVC_CONFIGURER_TYPE)
.withClazz(TypeTree.build(WEB_MVC_CONFIGURER).withType(WEB_MVC_CONFIGURER_TYPE))
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (md.getReturnTypeExpression() instanceof J.ParameterizedType) {
J.ParameterizedType parameterizedType = (J.ParameterizedType) md.getReturnTypeExpression();
md = md.withReturnTypeExpression(parameterizedType
.withType(WEB_MVC_CONFIGURER_TYPE)
.withClazz(TypeTree.build(WEB_MVC_CONFIGURER).withType(WEB_MVC_CONFIGURER_TYPE))
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

2 participants