Making an IntelliJ `FoldingBuilder` plugin for Kot...
# random
y
Making an IntelliJ
FoldingBuilder
plugin for Kotlin (to "prettify" certain calls by changing their display), and I have a couple questions: 1. Is this the right way to check that a
KtSimpleNameExpression
uses backticks? `expression.text.startsWith('`') && expression.text.endsWith('`')` 2. Would the following code properly detect if a library call is annotated, and would it have access to its annotation value, or do I need to do something more complicated?
Copy code
val reference = expression.mainReference.resolve() as? KtAnnotated ?: return
val annotation = reference.findAnnotation(PRETTY_FQNAME) ?: return
val name = annotation.valueArguments.singleOrNull()?.constValue as? String ?: return
In particular, I'm not sure if
resolve
works for a library (i.e. not local) call, and if it works, I'm not sure if the
annotation
can be found with its value argument intact