Skip to content
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

Need a way to associate CodeGenerator to top-level functions and properties from compiled classes. #1704

Closed
kuanyingchou opened this issue Jan 30, 2024 · 1 comment
Assignees
Labels
P1 major features or blocking bugs
Milestone

Comments

@kuanyingchou
Copy link
Contributor

We can use Dependencies or CodeGenerator.associateWithClasses() to associate CodeGenerator to enclosing files or classes for most elements, but we can't find any for top-level functions and properties from compiled classes. Both KSDeclaration.parentDeclaration and KSNode.containingFile return null. We may need a way to associate these top-level elements.

copybara-service bot pushed a commit to androidx/androidx that referenced this issue Jan 31, 2024
XElement.originatingElementForPoet() fails when the underlying ksDeclaration is not a class. This CL fixes that by making this function cover all subtypes of XElement except top-level functions and properties.

We can't yet support top-level functions and properties from compiled classes in KSP due to google/ksp#1704.

Test: OriginatingElementsTest.kt
Bug: 322539430
Change-Id: I36fee2a4ece66bd542b6da8062c5d942c9e77552
@ting-yuan ting-yuan self-assigned this Jan 31, 2024
@ting-yuan ting-yuan added the P1 major features or blocking bugs label Jan 31, 2024
@ting-yuan ting-yuan added this to the Dagger milestone Feb 1, 2024
@ting-yuan
Copy link
Collaborator

ting-yuan commented Feb 2, 2024

Introduced CodeGenerator.associateWithFunctions() and CodeGenerator.associateWithProperties() in #1707.

N.B. because how top level functions and properties are implemented in libraries is backend / platform specific, there is no simple way to invalidate them individually or in a finer granular. This implementation treats the outputs that are associated by these 2 APIs as aggregating. Further optimizations will be done in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 major features or blocking bugs
Projects
None yet
Development

No branches or pull requests

2 participants