Transforms

Hi, Everybody

Can anybody show me example how to use left/right transforms?

Thanks in advance!

4 comments
Comment actions Permalink

Hi, Oleg

Here is eaxmple of right transform witch converit expression to array acces expression, when ones type '[' symbol.

side transform actions arrayAccess

     right transformed node: Expression tag: default_  //transforms array into array access expression

          condition : (operationContext, scope, model, sourceNode)->boolean {

                 return coerce(sourceNode.type :< concept = ArrayType as a).isNotNull && !(sourceNode.isInstanceOf(GenericNewExpression));

          }

     common initializer :

          <no common variables>

          ....................................

          <no common initializer>

      actions :

         add custom items  (output concept: ArrayAccessExpression)

              simple item

                   matching text

                               [

                   description text

                      array access

                   icon

                      <default>

                   type

                      <default>

                   do transform (operationContext, scope, model, sourceNode, pattern)->node< > {

                       node<ArrayAccessExpression> result = model.new node(ArrayAccessExpression , <no prototype>);

                       sourceNode.replace with(result);

                       result.array.set(sourceNode);

                       return result;

                   }

Also you can find a lot of examles in baseLanguage -> actions -> in folder sideTransforms

Picture.png

Regards,

Evgeny Kurbatsky.

0
Comment actions Permalink

I tried to write a test program which must replace node with "Concept1" concept when I type in "[[", but it is not works :-)

What I do incorrect? Project in attachment.



Attachment(s):
Test.zip
0
Comment actions Permalink

It works.

Try try to type somthing in RootConcept: [[abc|]].

Then place cursor at the end of the cell: [[abc]]|.

Type "[[".

You will get: [[no val]]. You old node of Concept1 was replaced with new node of Concept1.

0
Comment actions Permalink

Exactly!

Thanks, Evgeny!

0

Please sign in to leave a comment.