https://kotlinlang.org logo
#ksp
Title
# ksp
z

Zac Sweers

03/14/2024, 5:27 AM
Would y'all be open to a PR to expand
Resolver.getDeclarationsFromPackage()
to allow including subpackages too? We have a good use case for this in Anvil
j

Jiaxiang

03/14/2024, 6:16 PM
What do you mean by subpackage?
z

Zac Sweers

03/14/2024, 6:22 PM
Give
com.example
, I want to also fetch
com.example.subpackage
But I only know about the first one at processing-time
This is possible with the underlying module itself, just would like to avoid using a private API to achieve the same result :)
j

Jiaxiang

03/14/2024, 6:32 PM
I see, that looks doable from implementation side, caveat is that this API have the potential of extracting the whole classpath out though.
alternatively, what if we just provide an API to give you a list of subpackages under a pacakge name? So that you can subsequently use the package names to get the declarations using existing API?
z

Zac Sweers

03/14/2024, 7:24 PM
yeah that would work too 👍
👍 1
we want from dependencies too, not just sources. In case it matters
j

Jiaxiang

03/14/2024, 7:25 PM
That should be fine, we already return symbols from dependencies for getting from package.
z

Zac Sweers

03/14/2024, 7:25 PM
awesome. Should I file an issue summarizing this?
or just go straight for the PR?
j

Jiaxiang

03/14/2024, 7:26 PM
Sounds good, please go ahead with an issue to begin with.
👍 1
z

Zac Sweers

03/14/2024, 7:28 PM
do you want me to try a PR?
j

Jiaxiang

03/14/2024, 7:29 PM
That should also work if it fits your bandwidth 🙂
z

Zac Sweers

03/14/2024, 7:29 PM
Will do
thank you color 1
Does the ResolverAAImpl do the inverse of this by coincidence? The code appears to gather all the symbols of parent packages as well as the requested package
j

Jiaxiang

03/14/2024, 7:59 PM
it was intentional, the reason for the code is that you might get multiple package symbols for same package name therefore you need to visit all package symbols and filter by name and union them.
z

Zac Sweers

03/14/2024, 8:00 PM
interesting, and not necessary in KSP1's impl?
j

Jiaxiang

03/14/2024, 8:00 PM
yes, they are different
👍 1
z

Zac Sweers

03/14/2024, 8:00 PM
initial impl here: https://github.com/google/ksp/pull/1796. Working on tests next
👍 1
2 Views