Editor actions question

Hi. I need some help refining editor behaviour.

Suppose we want to build something resembling Scala's generics with upper bounds, for instance there can be a List[Bar] and a List[Foo < Bar]. Lets call "Bar" an upper bound, and "Foo" is an (optional) default type.

ListType concept then naturally has
  upperBound : Type[1]
  defaultType : Type[0..1]

and ListTypeEditor looks something like
  [- List [ ?[- % defaultType % < -] % upperBound % ] -]

where "defaultType <" part is shown conditionally.

Now the question: how to implement the following:
1. Typing "<" before %upperBound% adds new defaultType
2. Typing "<" after %upperBould% sets defaultType to upperBound and upperBound to new empty node

I tried playing with keymaps (defining "<" event on upperBound) and side transform actions but MPS just makes "<" symbol part of the upperBound name.

Any ideas?
0
4 comments
Hey,
Side transform actions should be the right tool for that problem. If MPS just extent the name, something goes wrong with the action. Check the condition.
0
condition is very simple: node.defaultType.isNull

I guess my question is how MPS is supposed to understand that "<" can't be part of the name and should invoke a transform action?
0
It's some time ago, that I've implemented this. You could try
1) set an explicit side-transform-anchor-tag in the editor cell and the action and/or
2) use a left-side-transform-action at the following cell.
0
tried both of these.
My question of how MPS understands when to trigger side transformations still holds
0

Please sign in to leave a comment.