trying to build a compiler plugin that targets cla...
# arrow-meta
s
trying to build a compiler plugin that targets classes annotated with
@ValueClass
and generates
toString
equals
and
hashCode
(without copy) I figured out how to generate
toString
and
hashCode
(working on
equals
next, and probably
componentX
) I figured out how to add functions to a class (Based on the Lens plugin) question: how would I add this code only to classes annotated with
@ValueClass
?
Copy code
private fun isValueClass(ktClass: KtClass): Boolean =
    !ktClass.isData() &&
        ktClass.primaryConstructorParameters.isNotEmpty() &&
        ktClass.primaryConstructorParameters.all { !it.isMutable } &&
        ktClass.typeParameters.isEmpty()
missing a check for my annotation ☝️
r
Checkout the higher kind plugin. It checks for the annotation value
It's in the meta sources in master. Sorry on my phone now.
s
Thanks
👍 1
r
don’t forget supertypes etc for the class
👍 1
or it will break the structure. Checkout the full id template for the classes
the template may have some flaws since the string it’s not typechecked by ank
I see some weird
}
r
that plugin needs to be rewritten, lenses will be projected by type proofs that are autogenerated so no need for class expansion in quotes
s
anyway, even with the lack of documentation, this took an afternoon to write..... so great job with arrow-meta all of you ❤️
❤️ 1