on Paste code - suggest imports(custom lang implementation) Follow
on Paste code - suggest imports(custom lang implementation)
I was searching for it in code and descriptor, PasteProvider, CopyPasteReferenceProcessor,CopyPastePostProcessor, but still can't figure out which class should I implement and how to make it work.
How to achieve such functionality with dialog?
Please sign in to leave a comment.
For Java it's done using custom CopyPastePostProcessor implementation (JavaCopyPasteReferenceProcessor) - an entity which can extract additional data from source on copy and apply them to target on paste. You can write something similar for your language, potentially extending CopyPasteReferenceProcessor base class, if it will fit your needs.
I seen that class,
how to add implementation for it?
<copyPastePostProcessor?
I found this:
<copyPastePostProcessor
implementation=
"org.jetbrains.plugins.groovy.editor.GroovyReferenceCopyPasteProcessor"
/>
JavaCopyPasteReferenceProcessor extends CopyPasteReferenceProcessor<PsiJavaCodeReferenceElement>
I seen PsiJavaCodeReferenceElementImpl, it looks pretty complicated, despite implementation for language I am working on seems to me pretty straightforward.
So I don't get idea of this class.
I tried before something, but it seems like "addReference" was handled when I used to copy text in IDEA
PsiJavaCodeReferenceElement[] refs)
I guess this method should be called on paste
Yes, just like any extension is added - see
https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Plugin+Structure#IntelliJIDEAPluginStructure-PluginExtensions.
You don't need to extend CopyPasteReferenceProcessor, you can write an implementation of CopyPastePostProcessor yourselves.
Thanks, it was tough but I did it.