Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How does one report errors in an IGenerator implementation?
How does one report errors in an IGenerator implementation? [message #1096723] Wed, 28 August 2013 19:39 Go to next message
Ed Staub is currently offline Ed StaubFriend
Messages: 12
Registered: July 2009
Junior Member
When an IGenerator implementation detects an error in its input, how should it report it?

I suspect there's something useful to inject, but I don't see it, and (surprisingly) I can't find any examples of generators that emit errors. So I suspect that my question is invalid in some way.

Should only validators detect errors?

Re: How does one report errors in an IGenerator implementation? [message #1096726 is a reply to message #1096723] Wed, 28 August 2013 19:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

yes i think so. only validators should do it.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How does one report errors in an IGenerator implementation? [message #1097041 is a reply to message #1096723] Thu, 29 August 2013 06:59 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Ed Staub wrote on Wed, 28 August 2013 15:39
When an IGenerator implementation detects an error in its input, how should it report it?

I suspect there's something useful to inject, but I don't see it, and (surprisingly) I can't find any examples of generators that emit errors. So I suspect that my question is invalid in some way.

Should only validators detect errors?


But how to put some log notes to a file during generation?
Like "entity XYZ: fieldname ABC1234567890ABC shortened to 12 characters"
The length of fieldname in the DSL is not limited (so not a case for validator),
only in the context of the generated file, there is a maximum length.

Because these notes come from the generation process directly,
it seems impossible to generate the normal outputfile at first
and the logfile afterwards.

Re: How does one report errors in an IGenerator implementation? [message #1097046 is a reply to message #1097041] Thu, 29 August 2013 07:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hmmm looks like a possible enhancement request

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How does one report errors in an IGenerator implementation? [message #1097468 is a reply to message #1097046] Thu, 29 August 2013 19:21 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Christian Dietrich wrote on Thu, 29 August 2013 03:04
hmmm looks like a possible enhancement request


How can I get this party started ?
Re: How does one report errors in an IGenerator implementation? [message #1097480 is a reply to message #1097468] Thu, 29 August 2013 19:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
simply file a ticket to bugzilla

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How does one report errors in an IGenerator implementation? [message #1097754 is a reply to message #1097480] Fri, 30 August 2013 05:57 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Christian Dietrich wrote on Thu, 29 August 2013 15:50
simply file a ticket to bugzilla


Hi Christian, where can I reach this xtext bugzilla?
I have absolutely no experience in this area,
so a URL and some hints will be helpful

TIA, Uli

Edit: I found the "looking glass" entry, but login seems to be not that easy.
Do I have to register somewhere?

Edit2: Solved.

[Updated on: Fri, 30 August 2013 06:05]

Report message to a moderator

Re: How does one report errors in an IGenerator implementation? [message #1097755 is a reply to message #1097754] Fri, 30 August 2013 05:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How does one report errors in an IGenerator implementation? [message #1130028 is a reply to message #1097041] Wed, 09 October 2013 06:51 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
at the very end (I'm a novice in JAVA, ECLIPSE, ...) the following worked for me:

class UmeCif1Generator implements IGenerator {
// *** Collections to handle log and error messages
static Collection<String> logLines = new LinkedList();
static Collection<String> errLines = new LinkedList();

override void doGenerate(Resource resource, IFileSystemAccess fsa) {
var String scriptFileName = resource.getURI().lastSegment.toString();
var String outFileBase = scriptFileName.substring(0,scriptFileName.lastIndexOf("."));
fsa.generateFile( outFileBase + '.CIF',
makeTheCif(resource.contents.head as Model));
// *** output of log and error messages
if (logLines.size() > 0) fsa.generateFile( outFileBase + '.LOG',
reportLog());
if (errLines.size() > 0) fsa.generateFile( outFileBase + '.ERR',
reportErr());
}

<snip>
/* Description max 20 char long, no TAB, CRNLs */
def makeTheDescription(String description) '''
«IF description.length < 21»
-#ED «escapeStringToCif(description)»
«ELSE»
-#ED «escapeStringToCif(description).substring(0,20)»
«addLog("reduced description to 20 for " + description)»
«ENDIF»
'''
<snip>
// *** utilities to handle log and error messages
def reportLog() '''
«FOR String s : logLines»
«s»
«ENDFOR»
'''
def reportErr() '''
«FOR String s : errLines»
«s»
«ENDFOR»
'''
def addLog(String str) {
logLines.add(str)
return ""
}
def addErr(String str) {
errLines.add(str)
return ""
}
Previous Topic:How to change order of proposals
Next Topic:How to trigger the Xtext indexer programmatically
Goto Forum:
  


Current Time: Thu Mar 28 11:38:45 GMT 2024

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

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

Back to the top