Editor: ability to enter "mixed" (text and entity) content

Is it possible to add support to MPS editors module to use cells that support input of plain text (as string) and concept instance (maybe using IDEA-live-templates-like shortcut mechanism)?
It would be very handy for developing many language models, for example, wiki language.
7 comments
What about using node substitute actions or it? You can check liveTemplates root from MPS baseLanguage to see examples of such actions.
0
Tried to write addon to Calculator tutorial that uses same principles as those in liveTemplates and adds new InputField for unknown values while writing an expression for OutputField (attached a file tutorial.zip (690KB)).
At first it worked when I used Ctrl+Space. But then when I tried it without using suggest box MPS started to generate nodes each time I write in a new letter (you can see it in Mumbo-Jumbo sandbox model). Is there any way to run an action's "create child node" only after suggest box item selection?

Tried also wrapper but it didn't worked at all (displaying red ?field? saying "Unresolved reference. Error: incompitable target concept in role 'field'") - samples in tutorial2.zip (672KB)

Also, will JavaDocs be available for nodes/autocomplete box items? :)
0
Is there any way to work with unmatched entered input text other than to use substitute action's "pattern" parameter?
0
I was talking about "live templates" where you create new child node (not a reference to another node created nearby..)

I've modified inlineInputFieldGeneration substitute action in order to check if currentTargetNode is exact instance of Expression (abstract super-concept of InputFieldReference) and create new InputFieldReference only in this case:
add custom items  (output concept: InputFieldReference)      
  simple item   
    can substitute             
      <default> 
    matching text              
      (operationContext, scope, model, parentNode, childConcept, currentTargetNode, pattern)->string { 
  if (currentTargetNode.concept.isExactly(Expression)) { return pattern; } 
  return null; 
}              
    description text           
      (operationContext, scope, model, parentNode, childConcept, currentTargetNode, pattern)->string { 
  "add field " + pattern; 
}    
    icon        
      <default> 
    type        
      <default> 
    create child node          
      (operationContext, scope, model, parentNode, childConcept, currentTargetNode, pattern)->node<InputFieldReference> { 
  node<InputField> newField = new node<InputField>(); 
  newField.name = pattern; 
  parentNode.ancestor<concept = Calculator>.inputField.add(newField); 
  node<InputFieldReference> newReference = new node<InputFieldReference>(); 
  newReference.field = newField; 
  newReference; 
}
prettyPrint();

Seems like with such kind of condition you can do what you want.

Also, will JavaDocs be available for nodes/autocomplete box items? :)

Well, definitely in future..
0
Another way is to add an action available by specific keyboard shortcut and handle this situation there (like in MPS then you press Ctrl+R on error cell) or use intentions for it.
0
I thought it's almost the same, because I also have to add this new entity to a collection in case of wiki-markup. Thank's for suggest, I'll try it and answer if something goes wrong.
0

Please sign in to leave a comment.