Automatic code conversion on paste like "convert java code when paste it to .kt file" Follow
I want to implement plugin for IntelliJ IDEA, which will convert HTML code to kotlinx.html (https://github.com/Kotlin/kotlinx.html)
I understand how to implement it by action (for example by selecting html text and pressing shortcut). But I can't find any documentation on how to implement behavior like automatic Java to Kotlin conversion when pasting Java code to .kt file.
Hot to register action, which will work on "paste" action in .kt file?
Please sign in to leave a comment.
Isn't com.intellij.codeInsight.editorActions.CopyPastePreProcessor is what you need?
Yes, I didn't find it in the documentation, but I found Java -> Kotlin conversion example code - https://www.google.com/url?q=https://github.com/JetBrains/kotlin/blob/master/idea/src/org/jetbrains/kotlin/idea/conversion/copy/ConvertJavaCopyPasteProcessor.kt%23L57&sa=D&ust=1553855720417000&usg=AFQjCNFCHL_LYX1j02jZ40xAChzErOBXQA
Plugin development documentation is not a full reference, unfortunately. It's more like jump start, giving you an architectural overview and examples for your first steps.
Next step is search IDEA itself for classes and read javadocs, usually classes have human-friendly names. For example in you case `Go To Class` and `CopyPaste` could help a lot. Not all classes and interfaces are documented properly though, again, unfortunately. In such cases - debugging may help.
And this forum ofc.