-
Notifications
You must be signed in to change notification settings - Fork 302
Cannot get the fully qualified name of an annotation not on the classpath #783
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
Comments
Therefore, if it cannot be resolved, there is no way to determine its FQN precisely. |
@ting-yuan I understand there may be cases where the FQN is not available, but in the case I was describing, it is. In that case calling |
This is an interesting use case. Unfortunately KSP doesn't support it for now; We'll need to add something like |
Unfortunately no. I’m not in control of the class path where my processors
are applied, which is likely the case in the vast majority of scenarios
…On Mon, Jan 31, 2022 at 5:43 AM laszio ***@***.***> wrote:
This is an interesting use case. Unfortunately KSP doesn't support it for
now; We'll need to add something like resolveQualifiedName. Could you
work it around by supplying the definition in the classpath?
—
Reply to this email directly, view it on GitHub
<#783 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMCVLONVROKCYLLPHVTM2DUYZRVVANCNFSM5KVFHZGA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@ting-yuan Do you have a recommendation on how I would add a test for this? |
You could build a library May I know how you're going to solve this? If you're thinking of introducing a new API, would you mind to discuss with @neetopia before investing in implementation? |
This is turning out to be pretty necessary, especially if you're in a loop with other processors, where you need to rely on those types. The information should be available to build these symbols - if the FQCN isn't available in the text of the class passed into an annotation parameter, there's an import statement in the file that should have its qualifier, so that should be discoverable by something analyzing its source. Indeed, if it came in from a class file, it would have FQCN because all the imports are normalized-away during compilation. In my own case, I have GRPC service sources being generated, and my annotation references them. Those sources are part of the compilation job, but even if they weren't, the type I'm evaluating during processing should have all the breadcrumbs. Heck, I'm considering literally processing the file to look for the import statement as a stop-gap. |
Currently
KSAnnotation
only supportsshortName
. In the case where an annotation is not on the classpath, we should still be able to determine the fully qualified name of the annotation.Calling
annotation.annotationType.resolve()
returns an error type in this case so it cannot be retrieved from the declarationThe text was updated successfully, but these errors were encountered: