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

Feature request: expose an API in Resolver to retrieve the module name for handling mangling of internal members #1621

Closed
ZacSweers opened this issue Nov 25, 2023 · 3 comments · Fixed by #1847

Comments

@ZacSweers
Copy link
Contributor

internal members will have mangled names when seen from Java. In an existing non-KSP compiler plugin (Anvil) we use this logic to compute the mangled suffix that these functions would have like so

private fun ModuleDescriptor.mangledNameSuffix(): String {
  // We replace - with _ to maintain interoperability with Dagger's expected generated identifiers
  val name = name.asString().replace('-', '_')
  return if (name.startsWith('<') && name.endsWith('>')) {
    name.substring(1, name.length - 1)
  } else {
    name
  }
}

Could KSP expose an API to access ModuleDescriptor.name? This would allow ensuring generation of jvm-compatible sources when migrating to KSP in our case.

@ZacSweers
Copy link
Contributor Author

I could send a PR for this too if you're open to it

@ting-yuan
Copy link
Collaborator

Thanks, the API sounds good and patches are welcome.

btw, in case I'm on vacation, please ping @neetopia for review after Dec. 10.

ZacSweers added a commit to ZacSweers/ksp that referenced this issue Dec 5, 2023
@ZacSweers
Copy link
Contributor Author

Done #1649

ZacSweers added a commit to ZacSweers/ksp that referenced this issue Apr 17, 2024
ZacSweers added a commit to ZacSweers/ksp that referenced this issue Apr 17, 2024
ting-yuan pushed a commit that referenced this issue Apr 18, 2024
github-actions bot pushed a commit that referenced this issue Apr 18, 2024
Resolves #1621

(cherry picked from commit c262051)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants