Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » how2 append to a generated file?
how2 append to a generated file? [message #1151178] Wed, 23 October 2013 07:14 Go to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Recently, I added some logging/Errorreport functionality to my Generator.

But when I use fsa.generateFile(), the old file is purged at first.
Is there an easy way to just append to existing files?

My code looks like:
**********************************
«addLog("creating a new entry for " + modul.name)»
**********************************
// *** Collections to handle log and error messages
static Collection<String> logLines = new LinkedList();
static Collection<String> errLines = new LinkedList();
// *** 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 ""
}

/* now the main thing */
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
var String scriptFileName = resource.getURI().lastSegment.toString();
var String outFileBase = scriptFileName.substring(0,scriptFileName.lastIndexOf("."));
// *** output of log and error messages
if (logLines.size() > 0) fsa.generateFile( outFileBase + '.LOG',
reportLog());
if (errLines.size() > 0) fsa.generateFile( outFileBase + '.ERR',
reportErr());
}
Re: how2 append to a generated file? [message #1151211 is a reply to message #1151178] Wed, 23 October 2013 07:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,


i think you have to customize IFileSystemAccess so that
it works as you wish.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: how2 append to a generated file? [message #1151242 is a reply to message #1151211] Wed, 23 October 2013 08:04 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Thank you Christian, I will have a look into that area. Uli


Found some hints at:

http://xtextcasts.org/episodes/15-output-configurations?autoplay=true

Well, not quite the solution because it protects file from beeing overwritten, but seems not to append the new info. Still on the quest

[Updated on: Wed, 23 October 2013 08:37]

Report message to a moderator

Previous Topic:Problem with expensive validation
Next Topic:New Xtext Installation in Eclipse
Goto Forum:
  


Current Time: Thu Apr 18 00:44:18 GMT 2024

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

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

Back to the top