copy-pastemps

Copy code from text editor and past into Jetbrains MPS


I would like to copy a json fragment from a text editor and past that into my json language. So, I have to parse that fragment and create AST from it, not a problem. But, how do I integrate that action into MPS? Paste Wrappers and Copy and Paste Handlers are meant to be used for Copy&Paste action inside MPS, because they work already with the AST, right? Is it possible to hook into "plain text" paste action? Any suggestions or examples I can steal from?


Solution

  • MPS has this for Java code, it's implemented as a custom action (a separate context menu item). The implementation is in the action named PasteAsJavaClass (URL: http://127.0.0.1:63320/node?ref=r%3Ac6bc30d1-d0d1-44c6-ba7e-90e78619615e%28jetbrains.mps.ide.java.actions%29%2F2872212824181502651)

    Answered by Sergej Koščejev, MPS Slack

    Another approach with Antlr:
    Suppose you have a custom text based DSL and you want import the DSL code into MPS, then you have to parse it and you have to map the parse tree to your MPS model.
    Frederico Tomasetti wrote a blog post about how to integrate antlr and mps.