Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Conflicting Regions for new line
Conflicting Regions for new line [message #1781102] Thu, 01 February 2018 12:34 Go to next message
Claudia Irvine is currently offline Claudia IrvineFriend
Messages: 23
Registered: July 2015
Junior Member
I am using Xtext 2.13 and Formatter2. I am trying to put two lines between sections. But within the section, I only want one line. Because each section can have a list of different types of items, I can't determine what will be the last list item. Therefore, I am getting a conflicting regions error even though the code does format the way I want.

Is there another solution to avoid the error?

Grammar snippet:
Model :
   inputSection=InputSection
   actionSection=ActionSection
   outputSection=OutputSection
   ;
   
InputSection :
   {InputSection} (inputs+=Input)*
   ;

Input :
   (Infile  | Inprocedure)
   ;

Infile:
   ('/INFILE' | '/INFILES') ('=' | '=(') fileNames+=FileName (',' fileNames+=FileName)* (')')?
   (statements+=InputStatement)*
   ;

InputStatement:
    InputOption |
	Process |
	AdvancedField 
	;


Formatter snippet:
	def dispatch void format(InputSection object, extension IFormattableDocument document) {
		object.append[setNewLines(1, 2, 2)]

		for (input : object.inputs) {
			input.format
		}
	}

	def dispatch void format(Infile object, extension IFormattableDocument document) {
		object.append[newLine]
		object.regionFor.keyword("=").surround[noSpace]
		object.interior[indent]

		for (stmt : object.statements) {
			stmt.append[newLine]
			stmt.format
		}
	}


Intended output:
/INFILES=random_file_placeholder
	/PROCESS=RANDOM
	/FIELD=(PRESIDENT, TYPE=ALPHA_DIGIT, POS=1, SIZE=26)
	/FIELD=(SERVICE, TYPE=ALPHA_DIGIT, POS=28, SIZE=9)

/REPORT

/OUTFILE=stdout
	/PROCESS=RECORD
	/FIELD=(PRESIDENT, TYPE=ALPHA_DIGIT, POS=1, SIZE=26)
	/FIELD=(SERVICE, TYPE=ALPHA_DIGIT, POS=28, SIZE=9)


Re: Conflicting Regions for new line [message #1781118 is a reply to message #1781102] Thu, 01 February 2018 15:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11964
Registered: July 2009
Senior Member
hi, could you share a complete minimal reproducing example so that i can have a look

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Conflicting Regions for new line [message #1781198 is a reply to message #1781118] Fri, 02 February 2018 13:26 Go to previous message
Claudia Irvine is currently offline Claudia IrvineFriend
Messages: 23
Registered: July 2015
Junior Member
I was able to avoid the error by adding highPriority to the section setNewLines. Thanks anyways.
Previous Topic:Refer to elements of a derived model in IDerivedStateComputer
Next Topic:Xtend templates execution : unable to print return value of a method when used in forEach
Goto Forum:
  


Current Time: Thu May 24 08:23:14 GMT 2018

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

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

Back to the top