|
|
|
|
|
|
|
|
Re: How does one report errors in an IGenerator implementation? [message #1130028 is a reply to message #1097041] |
Wed, 09 October 2013 06:51 |
Uli Merkel 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 ""
}
|
|
|
Powered by
FUDForum. Page generated in 0.03702 seconds