elihart
02/22/2021, 5:07 PMjavax.lang.model.element.PackageElement
? As far as I can tell there isn’t a KSAnnotated
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 Elements.getPackageElement(CharSequence)
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 KSPJiaxiang
02/22/2021, 8:29 PMelihart
02/22/2021, 9:54 PMJiaxiang
02/23/2021, 1:39 AMelihart
02/23/2021, 2:26 AMresolver.getSymbolsWithAnnotation
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)Jiaxiang
02/23/2021, 2:55 AMgetAllFiles()
to iterate through all files and find the files with desired package name.elihart
02/23/2021, 3:32 AMJiaxiang
02/25/2021, 11:59 PMelihart
02/26/2021, 4:19 AMJiaxiang
02/26/2021, 10:55 PMelihart
02/26/2021, 11:37 PMJiaxiang
02/26/2021, 11:42 PMgetSymbolsAnnotatedWith
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.elihart
02/27/2021, 6:11 PMsince 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
gabrielfv
02/27/2021, 11:02 PM@Root<…>
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.elihart
03/25/2021, 6:48 PMJiaxiang
03/25/2021, 7:03 PMgetJvmName()
, or support it in another module, potentially Room’s abstraction layer. Yes please file an issue on Github.elihart
04/02/2021, 4:23 PM