Unable to indent code with TextGen Follow
I was not able to indent code from TextGen, this
result in
Then I looked at ForStatement_TextGen, here foreach is used so I tried
with result
Using $list{} has the same result.
I successfully indented code where my node is not a root node with (node type is a concept similar to a /** */ comment from baseLanguage)
But I don't know why it's actually working or better why the other cases are not working.
Thx
append {/** test 1} \n ; with indent { append {Line1} \n ; append {Line2} \n ; } append \n ;
result in
/** test 1 Line1 Line2
Then I looked at ForStatement_TextGen, here foreach is used so I tried
string[] lines1 = {"Line 1", "Line 2"}; append {/** test 2} \n ; with indent { foreach line in lines1 { append ${line} \n ; } } append \n ;
with result
/** test 2 Line 1 Line 2
Using $list{} has the same result.
I successfully indented code where my node is not a root node with (node type is a concept similar to a /** */ comment from baseLanguage)
with indent { foreach line in node.lines { append ${line} \n ; } }
But I don't know why it's actually working or better why the other cases are not working.
Thx
Please sign in to leave a comment.
whereas the working example is translated into
It's strange because the source TextGen code appears, to me, the same... it's a with index + foreach construct although the type of the cycle variable is different.
Alternatively, you can manually insert the current indentation by the "indent buffer;" command before calling "append".
However for a beginner like me a better name for with indent could be with increasing depth seen that "with indent" does not indent all the statements it contains (that should be indented one by one through the inspector), it just sorrounds the statements with increase/decrease depth.
Nevertheless MPS is a great tool and thx to point me to the inspector.
For example, the TextGen for ReturnStatement:
only the first append - "{return}" - needs to be indented, not the other ones, since these should follow right after the "return".