Hello! I’m writing a custom rule with autoCorrect....
# ktlint
b
Hello! I’m writing a custom rule with autoCorrect. To do so I need to add
.trimMargin()
after a
KtStringTemplateExpression
but I don’t know how to manipulate the psi to do that. I tried to find an example in the ktlint code base but the ones that I find doesn’t work for my use case.
Right now I have this and it doesn’t work:
Copy code
expression.addAfter(LeafPsiElement(ElementType.IDENTIFIER, ".trimIndent()"), expression)
p
Best thing that you can do is first write the code sample that you're targeting at. Then next use 'ktlint --print-ast' to output the AST you have to replicate.
b
Good one! Thanks!