Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Debug "Produced region is inconsistent"
Debug "Produced region is inconsistent" [message #1779853] Sun, 14 January 2018 21:22 Go to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello,

going further with the instrumentation to get debugging for non trivial language I stumble upon the following errors: "Produced region is inconsistent"

I understand that the trace annotations are not in line with what is expected but I fail to understand how this happens.

Let me be more specific, with the following dsl code everything is fine:

InExpression (for all @EXPRESSION.Value as value) {
    if (value.valueString in ('foo', 'bar')) {
          // save value
    }
}


https://imgur.com/CSWTXbj

Now here is my problem:
1) I carefully checked my stacktrace and no of the method are missing the @Traced
2) What happens exactly, I see the result but I fail to understand the process
3) How can I unit test this. It is pretty tedious to have to start eclipse.

Many thanks for your help




However uncommenting the save valuer statement in the if yield to
8337014 [Worker-21] ERROR org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider  - Produced region is inconsistent with parent, this: TraceRegion [myOffset=699, myLength=49] associations={
  LocationData [TextRegionWithLineInformation [153:22][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
},
...

What is interesting is that in the first case the region are clearly whereas not in the second case because the code of the save (createOrUpdate) is outside of the ]03,02]
https://imgur.com/v4vrn23


Re: Debug "Produced region is inconsistent" [message #1779854 is a reply to message #1779853] Sun, 14 January 2018 21:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
Hmmmm your questions getting more and more advanced and
I don't have the time to create an example to reproduce your stufff.

Regarding unit tests:
Can you post a stacktrace of where the error happens


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779855 is a reply to message #1779854] Sun, 14 January 2018 21:36 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello Cristian,

thanks for looking at it. Here is some more information and the full strack trace. (just a note to say that it works for toy examples)

	@Traced def dispatch  generate(IfStatement statement, GeneratorContext context) {
		'''
			if («statement.condition.generate(context)») {
			    «statement.then.generate( context)»        //This calls the block statement code below, if remove everything goes fine
			} «IF statement.^else!==null»else {
						    «statement.^else.generate(context)»
			}«ENDIF»
		'''
	}


	@Traced def dispatch  generate(BlockStatement statement, GeneratorContext context) {
		'''
			«FOR s : statement.statements»
				int i = 0;                //<--- This is not the real code, normally at this we can treat any statement but just putting a hardcoded statement reproduces the problem
			«ENDFOR»
		'''
	}


309590 [Worker-8] ERROR org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider  - Produced region is inconsistent with parent, this: TraceRegion [myOffset=699, myLength=15] associations={
  LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
}, parent: TraceRegion [myOffset=581, myLength=132] associations={
  LocationData [TextRegionWithLineInformation [112:64][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
} nestedRegions={
  TraceRegion [myOffset=585, myLength=106] associations={
    LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
  } nestedRegions={
    TraceRegion [myOffset=585, myLength=106] associations={
      LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
    } nestedRegions={
      TraceRegion [myOffset=586, myLength=104] associations={
        LocationData [TextRegionWithLineInformation [116:35][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
      } nestedRegions={
        TraceRegion [myOffset=610, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [138:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=617, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [145:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=633, myLength=56] associations={
          LocationData [TextRegionWithLineInformation [116:17][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        } nestedRegions={
          TraceRegion [myOffset=634, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
          TraceRegion [myOffset=665, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
        }
      }
    }
  }
  TraceRegion [myOffset=699, myLength=15] associations={
    LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
  }
}
java.lang.IllegalArgumentException: Produced region is inconsistent with parent, this: TraceRegion [myOffset=699, myLength=15] associations={
  LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
}, parent: TraceRegion [myOffset=581, myLength=132] associations={
  LocationData [TextRegionWithLineInformation [112:64][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
} nestedRegions={
  TraceRegion [myOffset=585, myLength=106] associations={
    LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
  } nestedRegions={
    TraceRegion [myOffset=585, myLength=106] associations={
      LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
    } nestedRegions={
      TraceRegion [myOffset=586, myLength=104] associations={
        LocationData [TextRegionWithLineInformation [116:35][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
      } nestedRegions={
        TraceRegion [myOffset=610, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [138:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=617, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [145:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=633, myLength=56] associations={
          LocationData [TextRegionWithLineInformation [116:17][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        } nestedRegions={
          TraceRegion [myOffset=634, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
          TraceRegion [myOffset=665, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
        }
      }
    }
  }
  TraceRegion [myOffset=699, myLength=15] associations={
    LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
  }
}
	at org.eclipse.xtext.generator.trace.AbstractStatefulTraceRegion.<init>(AbstractStatefulTraceRegion.java:36)
	at org.eclipse.xtext.generator.trace.TraceRegion.<init>(TraceRegion.java:58)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer$IdentityStrategy.createRegion(TraceRegionSerializer.java:63)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer$IdentityStrategy.createRegion(TraceRegionSerializer.java:53)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:334)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:337)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:337)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:337)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:285)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.readTraceRegionFrom(TraceRegionSerializer.java:169)
	at org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider$CachedTraces.getTraceRegion(AbstractTraceForURIProvider.java:125)
	at org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider$1.getTraceRegion(AbstractTraceForURIProvider.java:208)
	at org.eclipse.xtext.generator.trace.internal.AbstractTrace.doGetRootTraceRegion(AbstractTrace.java:126)
	at org.eclipse.xtext.generator.trace.internal.AbstractTrace.getRootTraceRegion(AbstractTrace.java:102)
	at org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant.findRootTraceRegion(DebugSourceInstallingCompilationParticipant.java:200)
	at org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant.buildFinished(DebugSourceInstallingCompilationParticipant.java:125)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:235)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)

!ENTRY org.apache.log4j 4 0 2018-01-14 22:35:21.369
!MESSAGE org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider  - Produced region is inconsistent with parent, this: TraceRegion [myOffset=699, myLength=15] associations={
  LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
}, parent: TraceRegion [myOffset=581, myLength=132] associations={
  LocationData [TextRegionWithLineInformation [112:64][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
} nestedRegions={
  TraceRegion [myOffset=585, myLength=106] associations={
    LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
  } nestedRegions={
    TraceRegion [myOffset=585, myLength=106] associations={
      LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
    } nestedRegions={
      TraceRegion [myOffset=586, myLength=104] associations={
        LocationData [TextRegionWithLineInformation [116:35][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
      } nestedRegions={
        TraceRegion [myOffset=610, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [138:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=617, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [145:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=633, myLength=56] associations={
          LocationData [TextRegionWithLineInformation [116:17][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        } nestedRegions={
          TraceRegion [myOffset=634, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
          TraceRegion [myOffset=665, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
        }
      }
    }
  }
  TraceRegion [myOffset=699, myLength=15] associations={
    LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
  }
}

!STACK 0
java.lang.IllegalArgumentException: Produced region is inconsistent with parent, this: TraceRegion [myOffset=699, myLength=15] associations={
  LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
}, parent: TraceRegion [myOffset=581, myLength=132] associations={
  LocationData [TextRegionWithLineInformation [112:64][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
} nestedRegions={
  TraceRegion [myOffset=585, myLength=106] associations={
    LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
  } nestedRegions={
    TraceRegion [myOffset=585, myLength=106] associations={
      LocationData [TextRegionWithLineInformation [115:37][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
    } nestedRegions={
      TraceRegion [myOffset=586, myLength=104] associations={
        LocationData [TextRegionWithLineInformation [116:35][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
      } nestedRegions={
        TraceRegion [myOffset=610, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [138:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=617, myLength=5] associations={
          LocationData [TextRegionWithLineInformation [145:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        }
        TraceRegion [myOffset=633, myLength=56] associations={
          LocationData [TextRegionWithLineInformation [116:17][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
        } nestedRegions={
          TraceRegion [myOffset=634, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
          TraceRegion [myOffset=665, myLength=5] associations={
            LocationData [TextRegionWithLineInformation [116:5][lineNumber=5, endLineNumber=5]][path=Conditions-1.0.0.wkfs]
          }
        }
      }
    }
  }
  TraceRegion [myOffset=699, myLength=15] associations={
    LocationData [TextRegionWithLineInformation [153:23][lineNumber=5, endLineNumber=7]][path=Conditions-1.0.0.wkfs]
  }
}
	at org.eclipse.xtext.generator.trace.AbstractStatefulTraceRegion.<init>(AbstractStatefulTraceRegion.java:36)
	at org.eclipse.xtext.generator.trace.TraceRegion.<init>(TraceRegion.java:58)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer$IdentityStrategy.createRegion(TraceRegionSerializer.java:63)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer$IdentityStrategy.createRegion(TraceRegionSerializer.java:53)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:334)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:337)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:337)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:337)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.doReadFrom(TraceRegionSerializer.java:285)
	at org.eclipse.xtext.generator.trace.TraceRegionSerializer.readTraceRegionFrom(TraceRegionSerializer.java:169)
	at org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider$CachedTraces.getTraceRegion(AbstractTraceForURIProvider.java:125)
	at org.eclipse.xtext.generator.trace.internal.AbstractTraceForURIProvider$1.getTraceRegion(AbstractTraceForURIProvider.java:208)
	at org.eclipse.xtext.generator.trace.internal.AbstractTrace.doGetRootTraceRegion(AbstractTrace.java:126)
	at org.eclipse.xtext.generator.trace.internal.AbstractTrace.getRootTraceRegion(AbstractTrace.java:102)
	at org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant.findRootTraceRegion(DebugSourceInstallingCompilationParticipant.java:200)
	at org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant.buildFinished(DebugSourceInstallingCompilationParticipant.java:125)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:235)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)

[Updated on: Sun, 14 January 2018 21:38]

Report message to a moderator

Re: Debug "Produced region is inconsistent" [message #1779856 is a reply to message #1779855] Sun, 14 January 2018 21:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
The exception already shows tostring of the regions so you should see the inconsistency there

You should be able to combine GeneratorNodeProcessor and the traceregion serializer in a unit test


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779857 is a reply to message #1779856] Sun, 14 January 2018 21:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
And as I tried to hint. A simple reproduce example with just the problem would help me
(And possible you) so having an example with and if else and a hard coded for only would help
And maybe Understand if this is a bug or something else.

The interesting point is that this is a offf by one issue so
Are you on windows or a Unix like os?

What happens if you do the if else and the for all in one line including the ''''''


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779868 is a reply to message #1779857] Mon, 15 January 2018 06:40 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello Christian,

thanks for the unit test. I got the hint don't worry I will try to build a simple and reproducible unit test.
As for the other question, I am on windows. By the way, how did you detect the off by one with the trace?
Re: Debug "Produced region is inconsistent" [message #1779869 is a reply to message #1779868] Mon, 15 January 2018 06:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
[myOffset=581, myLength=132]
[myOffset=699, myLength=15]

581+132 = 713
699 + 15 = 714

maybe similar issue to https://github.com/eclipse/xtext-core/issues/483 ? which xtext version do you use?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779918 is a reply to message #1779869] Mon, 15 January 2018 19:18 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Thanks for the explanation, using 2.12
Trying to build a unit test
Re: Debug "Produced region is inconsistent" [message #1779925 is a reply to message #1779918] Mon, 15 January 2018 19:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
please give it a test with 2.13 too

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779927 is a reply to message #1779925] Mon, 15 January 2018 19:46 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
ok I can confirm that the problems comes from the for loop, removing and externalizing it solves the problem for that portion of code.
However I can reproduce it with a
«IF statement.^else!==null»else {
    «statement.^else.generate(context)»
}«ENDIF»


So I guess the problem is more general.
Will move to 2.13 that may take some time.

[Updated on: Mon, 15 January 2018 19:47]

Report message to a moderator

Re: Debug "Produced region is inconsistent" [message #1779929 is a reply to message #1779927] Mon, 15 January 2018 19:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
You can try 13 with a separate eclipse/workspace

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779933 is a reply to message #1779929] Mon, 15 January 2018 20:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
btw could not reproduce with

Model:
	ifStatement=IfStatement;

IfStatement:
	'if' condition=BooleanLiteral
	then=BlockStatement
	('else'
	else=BlockStatement)?;

BooleanLiteral:
	value?="true" | {BooleanLiteral} "false";

BlockStatement:
	{BlockStatement} "{"
	statements+=Literal*
	"}";

Literal:
	value=ID;


class MyDslGenerator extends AbstractGenerator {
	
	@TracedAccessors(MyDslFactory)
	static class MyDslTraceExtension {
		
	}
	
	@Inject extension MyDslTraceExtension

	override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
		val model = resource.contents.head as Model
		
		fsa.generateTracedFile("test.txt", model,'''
			«model.ifStatement.generate(context)»
		''')
	}
	
	@Traced def dispatch  generate(IfStatement statement, IGeneratorContext context) {
		'''
			if («statement.condition.generate(context)») {
			    «statement.then.generate( context)»        //This calls the block statement code below, if remove everything goes fine
			} «IF statement.^else!==null»else {
						    «statement.^else.generate(context)»
			}«ENDIF»
		'''
	}
	
	@Traced def dispatch  generate(BlockStatement statement, IGeneratorContext context) {
		'''
			«FOR s : statement.statements»
				int i = 0;                //<--- This is not the real code, normally at this we can treat any statement but just putting a hardcoded statement reproduces the problem
			«ENDFOR»
		'''
	}
	
	@Traced def dispatch  generate(BooleanLiteral statement, IGeneratorContext context) {
		'''«statement._value»'''
	}
	
}	


if true
{
	x
	y
	z
} else {
	a
	b
	c
}


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1779943 is a reply to message #1779933] Tue, 16 January 2018 00:04 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Still have the problem with 2.13, and according to your test, it is something peculiar in my setting. Will try to build a minimum viable unit test to reproduce
Re: Debug "Produced region is inconsistent" [message #1779949 is a reply to message #1779943] Tue, 16 January 2018 05:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
So my example works on your machine?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1780012 is a reply to message #1779949] Tue, 16 January 2018 14:24 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Hello,

still trying to create the unit test regarding the serialisation
		val CompositeGeneratorNode rootNote = tracingSugar.trace(expr, expr.generateBody(context))
		val GeneratorNodeProcessor.Result result = processor.process(rootNote)

		val OutputStream outputStream = new BufferedOutputStream(new FileOutputStream("trace.txt"));
		serializer.writeTraceRegionTo(result.traceRegion, outputStream)
		outputStream.close


The generated file is not readable and the process does not generate an exception (with the production code)
Am I missing something?
Re: Debug "Produced region is inconsistent" [message #1780014 is a reply to message #1780012] Tue, 16 January 2018 14:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
shouldnt the call to the serializer already fail?
simply calling the whole doGenerate is not an option?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1780015 is a reply to message #1780014] Tue, 16 January 2018 14:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
and the file extension should be ._trace
and it should already fail there

and againthe question: my example works on your machine?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1780026 is a reply to message #1780015] Tue, 16 January 2018 15:22 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
No actually the simple example does not work and also yields an exception when I open the ._trace. Interestingly enough I do not get the exception during code generation.
Re: Debug "Produced region is inconsistent" [message #1780027 is a reply to message #1780026] Tue, 16 January 2018 15:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
yes but you should be able to have a look at the trace file tree at least. the problems is that the uris to source and target file will be invalid in your test i think.
can you share anything that lets me easly reproduce. even with calling the generator?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1780029 is a reply to message #1780027] Tue, 16 January 2018 15:34 Go to previous messageGo to next message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Sorry false alarm. Actually the problem in the small example was comming from the fact that I had two dsl files and the target test.txt is hardcoded. When I put a random file name. It works without exception
Re: Debug "Produced region is inconsistent" [message #1780035 is a reply to message #1780029] Tue, 16 January 2018 16:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12185
Registered: July 2009
Senior Member
still with no reproducible example i cannot help ....

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Debug "Produced region is inconsistent" [message #1780036 is a reply to message #1780035] Tue, 16 January 2018 16:41 Go to previous message
Steve Hostettler is currently offline Steve HostettlerFriend
Messages: 81
Registered: June 2016
Member
Indeed, and now I am completly confused, I cannot reproduce the error at all (included with my code). I am ... lost. Will redo it step by step...
Previous Topic:How to remove prefix in cross-reference
Next Topic:Xtext Proposal Provider: Remove "super" etc. from list
Goto Forum:
  


Current Time: Fri Aug 17 02:04:27 GMT 2018

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

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

Back to the top