0

Xtext 2.27.0: update your Xbase compiler tests

 2 years ago
source link: https://www.lorenzobettini.it/2022/06/xtext-2-27-0-update-your-xbase-compiler-tests/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Xtext 2.27.0: update your Xbase compiler tests

If you update to Xtext 2.27.0 and have compiler tests for your Xbase DSL that assert the output of the compilation, you’ll get lots of failures after the update.

I am guilty of that 😉
Well, for a good reason, at least 🙂

In fact, I worked on this issue: https://github.com/eclipse/xtext-extras/issues/772 and its fix is included in Xtext 2.27.0.

Now, the Xbase compilation mechanism does not generate useless empty lines anymore (before, it added lines with two spaces). Your compiler tests will fail because the output is different.

I personally fixed my tests in my DSLs by simply using the Find/Replace mechanism of Eclipse with this substitution pattern (there are two space characters between the tab character and the newline character):

xtext-replace-1.png?resize=625%2C587

If you have deep nesting in your compilation output, you might have to repeat this substitution with more than two characters, but this should not be required unless you generate nested classes or something like that.

With the above substitution a test like the following one:

xtext-replace-1-1.png?resize=625%2C524

will become like the following one (you see the difference: no empty line with two characters between the two generated constructors:

xtext-replace-2-1.png?resize=625%2C530

Now your tests should be fixed 🙂

Like this:

Loading...

This entry was posted in Tips and Tricks and tagged eclipse, xtext on June 14, 2022.

Post navigation

← Configure Arch Pacman


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK