Skip to main content



      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 15:39 Go to next message
Eclipse UserFriend
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 15:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

yes i think so. only validators should do it.
Re: How does one report errors in an IGenerator implementation? [message #1097041 is a reply to message #1096723] Thu, 29 August 2013 02:59 Go to previous messageGo to next message
Eclipse UserFriend
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 03:04 Go to previous messageGo to next message
Eclipse UserFriend
hmmm looks like a possible enhancement request
Re: How does one report errors in an IGenerator implementation? [message #1097468 is a reply to message #1097046] Thu, 29 August 2013 15:21 Go to previous messageGo to next message
Eclipse UserFriend
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 15:50 Go to previous messageGo to next message
Eclipse UserFriend
simply file a ticket to bugzilla
Re: How does one report errors in an IGenerator implementation? [message #1097754 is a reply to message #1097480] Fri, 30 August 2013 01:57 Go to previous messageGo to next message
Eclipse UserFriend
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 02:05] by Moderator

Re: How does one report errors in an IGenerator implementation? [message #1097755 is a reply to message #1097754] Fri, 30 August 2013 01:59 Go to previous messageGo to next message
Eclipse UserFriend
https://bugs.eclipse.org/bugs/
Re: How does one report errors in an IGenerator implementation? [message #1130028 is a reply to message #1097041] Wed, 09 October 2013 02:51 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 17:35:41 EDT 2025

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

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

Back to the top