feat: allow creating custom qualifier annotations #176
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.
Following #108, I was wondering if it was possible to improve class-based qualifiers even more by being able to make our own qualifier annotations like so:
These dependencies would be injected that way:
They would also be injected into constructors using the same annotation.
I think the syntax looks better that way but not everyone may think the same. Regardless, I feel like it wouldn't be a bad idea to give the developer the ability to choose between whatever option they prefer to declare a qualifier.
I don't have a lot of experience with KSP but I've managed to implement the feature (it works with either
@Named
or@Qualifier
). I have no idea of the impact on compilation speed, but I'd expect that there is at least some impact because in order to find the qualifier for a definition, we need to resolve each of its annotations until we find one whose declaration is annotated with@Named
or@Qualifier
.This could be extended to Scopes as well, I don't personally use them a lot, but I could try to implement the same feature for Scopes.