Comments (6)
KSName is meant to align with qualified names therefore you are seeing this result, but it is also reasonable to provide correct logic to get the qualifier. We will discuss to see what's the path forward for KSName.
The Glide example is not using KotlinPoet in a very practical way, mainly due to there is no KSP support built in KotlinPoet so we took a workaround to address the ClassName, ideally, there should be some extension functions around KSP properties to work with KotlinPoet.
from ksp.
sounds good. I'm one of the maintainers of KotlinPoet, we'd be interested in seeing what a kotlinpoet-ksp artifact could like on our end. Some obvious ones come to mind, like FileSpec.writeTo(CodeGenerator) support and KSName.toClassName(). Open to other suggestions as well for things you'd want to see in an artifact like that, let us know 👍. Will file an issue on our end soon to track ideas
from ksp.
Current KSName implementation is based on the qualified name spec.
To address this issue I will add a new property/function to KSName.
from ksp.
A KSName
returned by compiler/KSP is guaranteed to be unambiguous. As for getQualifier
, did you mean to get its package name? If so, KSDeclaration.getPackage
(to be added) might serve the purpose.
Forcing the notion of package in KSName would require all creation sites to supply package and the remaining identifier(s) separately. Although I agree that specifying package explicitly is much clearer, it is also less convenient.
As for the /
separator, it looks like an encoding / implementation choice of Kotlin metadata. Would getPackage
be more human friendly?
from ksp.
To add more context, on Kotlin language perspective names are separated by dot, and the case when you see names separated by slash is platform dependent (in this case, it is the JVM runtime name). In my opinion the right way to solve this is to provide KSDeclaration with a getPackage
API so that you can inspect package name for a nested class. However, you will have to make some adjustments to the KotlinPoet code you linked with this approach.
from ksp.
Alternative solution for this is shipped with android/kotlin#98
from ksp.
Related Issues (20)
- A failure occurred while executing com.google.devtools.ksp.gradle.KspAAWorkerAction HOT 8
- `KSP2` version `2.0.0-1.0.23` crashes on Moshi codegen with `NoSuchElementException: Collection contains no element matching the predicate.`
- Increase your Kotlin version and remove root level plugin and add this
- How to use KSP Processor provider on custom android library? HOT 2
- 2.0.20-Beta2 - [ksp] java.lang.NullPointerException
- Dagger hilt options were not recognized by ksp
- Accessing resources by name HOT 2
- IncompatibleClassChangeError with Kotlin 2.0.20-Beta2 HOT 1
- Dispatchers.IO Not Supported for File Creation
- generated kotlin code does not handle null properly when java generated code does HOT 1
- KSP2: Exception when using Moshi KSP and @ JsonQualifier HOT 1
- Better documentation of compatibility matching of ksp and gradle
- why this version not found in gradle? HOT 3
- [KSP2] getSymbolsWithAnnotation() doesn't work if the annotation is an alias in KOTLIN_LIB
- Room Entity with class function throws [ksp] [MissingType]
- incremental: aggregating outputs should always be invalidated
- Configuration with name 'kspJvm' not found. HOT 2
- Goog ksp 4 me
- Incremental compilation / processing issue HOT 1
- [KSP2] Qualified names of nested annotations from JAVA_LIB is null
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ksp.