JetBrains / JetBrains/MPS-extensions
How to control plaintextgenerated indent?
- Dominant language
- JetBrains MPS
- Stars
- 88
- Forks
- 60
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 15
Description
# Scenario
```
Given I am generating an XML file
Which has an embedded python dialect (which is indentation-sensitive)
And I use the mps.core.xml language for xml
And I use the plaintextgen for describing the generated python
When I run it
Then surprisingly, I see the python code indented relative to the xml nesting
But I'd expect instead: to be able to teach the `TextgenText` to restart the indentation level from `0` (maybe even by default)
```
# How can I work around this?
Plaintextgen indentation comes from the mps textgen `indent buffer;` ([source](http://127.0.0.1:63320/node?ref=r%3A4752c29d-6163-4693-b1d7-3c8befc060cd%28com.dslfoundry.plaintextgen.textGen%29%2F5407518469085614939)). It relies on the [MPS TextArea](https://github.com/JetBrains/MPS/blob/master/core/textgen/source/jetbrains/mps/text/impl/TextAreaImpl.java#L30), which does not publish absolute manipulation of the indentation depth. So to fix this we'd need to work on private fields of `TextAreaImpl`. That's nasty. How can I get outta here?
Here are some screenshots of my example. To respect my NDA, I had to censor it. Sorry for that.
## The xml:

## And this python:

## Generate into
Note that the xml indentation of `` is correct. Just the indentation of the CDATA and each other python line is wrong (marked with the pink arrows):

By the way: I'd be glad to support in fixing it once we have a useful plan…Until then, I'll move my python code into a stringbuilder and fill the xml CDATA with a property macro.
Contributor guide
Assessment
This issue has not been assessed yet.