-
Notifications
You must be signed in to change notification settings - Fork 78
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
Autowired field into constructor parameter #200
Conversation
2099447
to
08df793
Compare
@pway99 converted into a Visitor as discussed earlier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @BoykoAlex, just a few minor suggestions.
private String classFqName; | ||
|
||
private String fieldName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider making these final
|
||
@Override | ||
public J visitClassDeclaration(ClassDeclaration classDecl, ExecutionContext p) { | ||
if (classFqName.equals(classDecl.getType().getFullyQualifiedName())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest using TypeUtils here
get() = object : Recipe() { | ||
override fun getDisplayName() : String { return "Convert autowired field" } | ||
override fun getVisitor(): TreeVisitor<*, ExecutionContext> { | ||
return AutowiredFieldIntoConstructorParameterVisitor("demo.A", "a") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be
override val recipe: Recipe
get() = toRecipe{AutowiredFieldIntoConstructorParameterVisitor("demo.A", "a")}
08df793
to
7cd1c4b
Compare
@pway99 I've corrected the PR as suggested. Thanks very much for the review!-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @BoykoAlex !
Hi! Is there any recipe that uses this visitor? |
Takes fq name of the class and field name and converts that field if it is
@Autowired
into constructor parameter if there is a qualifying constructor.Does need some sort of
getApplicableTest()
? Is it ok to be a recipe? Or you'd rather have it as a visitor? Feedback is welcomed.