Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Formatting conflict
Formatting conflict [message #1868439] Fri, 19 July 2024 13:07 Go to next message
Ralph Hummeling is currently offline Ralph HummelingFriend
Messages: 7
Registered: July 2024
Junior Member
I'm a bit puzzled by a
ConflictingFormattingException
while implementing formatting using Xtext 2.34.0:

!MESSAGE org.eclipse.xtext.util.ExceptionAcceptor - Conflicting Regions.
{{{}}}: newLine=2 at offset=286 length=1
[[[]]]: newLine=1-1-2 at offset=286 length=1

My interpretation is that the first region requires 2 new lines while the following region requires at least 1 new line but 2 new lines is the maximum. In this sense, placing 2 new lines between these regions would be the solution, right? Indeed, this is my intention.
So why is this exception thrown?

As can be seen, the first region has
append[setNewLine(2)]
while the following region has
prepend[setNewLines(1, 1, 2)]


Regards,
Ralph
Re: Formatting conflict [message #1868442 is a reply to message #1868439] Fri, 19 July 2024 13:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14723
Registered: July 2009
Senior Member
as i have no idea can you provide a minimum reproducer?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Formatting conflict [message #1868445 is a reply to message #1868442] Fri, 19 July 2024 13:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14723
Registered: July 2009
Senior Member
(org.eclipse.xtext.formatting2.ConflictingFormattingException) org.eclipse.xtext.formatting2.ConflictingFormattingException: Conflicting values for 'newLineMin': '2' and '1'.

cannot tell you what the design considerations are for that


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Formatting conflict [message #1868448 is a reply to message #1868445] Fri, 19 July 2024 15:04 Go to previous messageGo to next message
Ralph Hummeling is currently offline Ralph HummelingFriend
Messages: 7
Registered: July 2024
Junior Member
I can reproduce the issue in the Entities example from Bettini' book.
In the EntitiesFormatter.xtend file, just add a
prepend[newLine]
to the attribute at line 44:
 attribute.prepend[newLine].append[setNewLines(1, 1, 2)]


Three following sample.entities code will reproduce the exception:
entity MyFirstEntity {
    string s;
    int a;
}

[Updated on: Fri, 19 July 2024 15:10]

Report message to a moderator

Re: Formatting conflict [message #1868451 is a reply to message #1868448] Fri, 19 July 2024 16:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14723
Registered: July 2009
Senior Member
maybe you can workaround this using
some conditionally formatting.

if (! a after b) b.prepend ....

or if (a after b) set 2 to both otherwise ...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Fri, 19 July 2024 16:25]

Report message to a moderator

Re: Formatting conflict [message #1868457 is a reply to message #1868451] Fri, 19 July 2024 18:16 Go to previous messageGo to next message
Ralph Hummeling is currently offline Ralph HummelingFriend
Messages: 7
Registered: July 2024
Junior Member
You're right, of course I can find a workaround but in this case I think it might be a bug that needs to be reported.
I didn't look at the source code yet because I don't have time at the moment... unfortunately.
Re: Formatting conflict [message #1868616 is a reply to message #1868457] Sat, 20 July 2024 03:38 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14723
Registered: July 2009
Senior Member
Looking at the code the behavior looks intentional.
But I cannot tell you the design considerations


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:Xtend java source version configuration (maven)
Next Topic:Xtext 2.36.0.M3 is out
Goto Forum:
  


Current Time: Sun Oct 13 01:44:56 GMT 2024

Powered by FUDForum. Page generated in 0.04643 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top