intellij-postfix-templates
intellij-postfix-templates copied to clipboard
Allow templates on types in Scala
I'd like to create templates that work on types instead of expressions. E.g. I tried:
.seqT : wrap type in Seq[ ]
ANY → Seq[$expr$]
to achieve something like def foo(x: Bar.seq) -> def foo(x: Seq[Bar])
but the .seqT template is not available in this context.
Correct. Types/classes are currently not supported as MATCHING_TYPE.
I have to look into it to see what I can do.
OK, this is unfortunately not easy to implement, because one has to replace the AncestorSelector in https://github.com/xylo/intellij-postfix-templates/blob/0f5a054b3652b7ab8baa46796bd293f3762fb4d9/src/de/endrullis/idea/postfixtemplates/languages/scala/CustomScalaStringPostfixTemplate.java#L75 with one that does not filter out the CodeReferenceElement. Unfortunately, AncestorSelector is not written in Java, so I cannot just adapt the code to make it work. Instead one has to convert the whole class to Java and adapt it or adapt the Scala file and somehow manage to import it into the plugin. Both solutions are very cumbersome and takes probably days of work. So I give up here. Sorry. But I keep the ticket open in case that someone else is willing to implement this feature.