elihart02/22/2021, 5:07 PM
? As far as I can tell there isn’t a
representation of a package (potentially because package-info.java is not used in kotlin?) I have a javac processor that looks up annotations on package elements and am wondering how KSP handles that. Similarly, does KSP provide any way to resolve the package by name? In javac we can do
to get a package, which then provides access to all elements in that package (including elements from other modules). We have used this to enable a single module to aggregate the generated files of other modules, by putting them all in the same package. I’m trying to figure out how to translate this to KSP
Jiaxiang02/22/2021, 8:29 PM
elihart02/22/2021, 9:54 PM
Jiaxiang02/23/2021, 1:39 AM
elihart02/23/2021, 2:26 AM
completely skips any annotated packages (I suppose kotlin just doesn’t even compile those?) That’s fine, I can work around that at least, but I think the documentation could be a little clearer that the package annotation target in java is not supported (it says the package element doesn’t exist, but kind of implies KSFile is the closest alternative)
Jiaxiang02/23/2021, 2:55 AM
to iterate through all files and find the files with desired package name.
elihart02/23/2021, 3:32 AM
Jiaxiang02/25/2021, 11:59 PM
elihart02/26/2021, 4:19 AM
Jiaxiang02/26/2021, 10:55 PM
elihart02/26/2021, 11:37 PM
Jiaxiang02/26/2021, 11:42 PM
to get the symbols from binaries, this can be hard to implement and also expensive. I am trying to explore alternate options before I can make a commitment on whether KSP will provide such API for getting symbols from a package, since a package symbol is most likely for Java rather than for Kotlin.
elihart02/27/2021, 6:11 PM
since a package symbol is most likely for Java rather than for KotlinI don’t think a package symbol is important, and it is fine that KSP doesn’t have it. But it is useful for both Java and Kotlin to look up either all symbols with the same package name, or process annotations in another binary. If KSP took a package name and returned a list of symbols within that package that would work great too, without any need for a package symbol
gabrielfv02/27/2021, 11:02 PM
annotation just to tell the processor “Hey, this is the module we should generate the aggregating code!“. Granted I don’t see no other way to do this in a nice API other than rely on flags that could be triggered from a custom gradle plugin and that’s not exactly better either.
elihart03/25/2021, 6:48 PM
Jiaxiang03/25/2021, 7:03 PM
, or support it in another module, potentially Room’s abstraction layer. Yes please file an issue on Github.