Create multiple child nodes when pasting from clipboard

Hi guys,

I am just getting started with MPS and this is my first time posting on this forum so I apologize in advance if I violate any forum rules or conventions.

I am trying to add support to my DSL for creating multiple child nodes when a user pastes a bunch of newline sepertated text.
Namely it would create a new child node for each new line in the text and set the nodes name equal to that lines text.

I've tried using paste handlers, refactoring, substitution menus and a few other things but I haven't quite gotten anything to work.

Namely nothing seems to split the text properly and in the case of the paste handler I can't see a way to get it to alter the nodes in the editor easily.

I was just wondering if this is something that MPS supports, and if there is something stupid that I am missing :)

 

For reference my structure for the root concept looks like this.

concept Schema extends BaseConcept
implements INamedConcept

instance can be root: true
alias: <no alias>
short description: <no short description>

properties:
<< ... >>

children:
fields : TableField[1..n]

references:
<< ... >>

and my child concept's structure looks like this

concept TableField extends BaseConcept
implements INamedConcept

instance can be root: false
alias: <no alias>
short description: <no short description>

properties:
<< ... >>

children:
<< ... >>

references:
<< ... >>

thanks and kind regards,

Ryan Weyers

1 comment
Comment actions Permalink

I think in the paste handler you have access to the pasted node and you can modify it but you can also add a sibling to it (or several).

Apart from that you could define your own custom "paste as multiline text" action where you would define the behavior. The BaseLanguage implementation in MPS contains an action called PasteAsJavaStatements that you can look up and copy.

0

Please sign in to leave a comment.