Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » CODE GENERATION WITH XTEXT: Someone please help(I need help generating java source file for my instance model)
CODE GENERATION WITH XTEXT: Someone please help [message #725783] Thu, 15 September 2011 18:48 Go to next message
AHOT Mising name is currently offline AHOT Mising nameFriend
Messages: 13
Registered: September 2011
Junior Member
I'm a new beginner xtext trying to use it for code synthesis, I have read the 15 minutes tutorial extended and acted on it.Having created the language grammar and the the code generator file (i.e *.extend file), I used the Run as Eclipse Application option to create another instance of my eclipse and created an instance model of my meta-model as instructed. The problem I'm having is "HOW TO GO FURTHER AND GENERATE THE SOURCE CODE FOR MY INSTANCE MODEL"; I created a source folder "src-gen" as instructed but nothing happened. I have read several books like the xtext documentation, oaw tutorial, and a few blogs by Sven Efftinge but have not been able to solve this problem, Can someone please help me out?
Re: CODE GENERATION WITH XTEXT: Someone please help [message #725788 is a reply to message #725783] Thu, 15 September 2011 19:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

seems everything ok. here once more the steps (2 mins with a new dsl)

(1) create a new xtext project using the default settings and generate the language
(2) implement the generator
package org.xtext.example.mydsl.generator

import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IGenerator
import org.eclipse.xtext.generator.IFileSystemAccess

class MyDslGenerator implements IGenerator {
	
	override void doGenerate(Resource resource, IFileSystemAccess fsa) {
		fsa.generateFile("test.txt","Hello Gen")
	}
}

(3) start a runtime app
(4) create a java project and place a test.mydsl file in the source folder (ask yes when asked about the xtext nature)
Hello World!

(5) create the src-gen source!!! folder

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: CODE GENERATION WITH XTEXT: Someone please help [message #725945 is a reply to message #725788] Fri, 16 September 2011 09:02 Go to previous message
AHOT Mising name is currently offline AHOT Mising nameFriend
Messages: 13
Registered: September 2011
Junior Member
Thanks a lot,
I have tried your example and it worked.
I will apply that to my work and if need be, I'll get back to you.
God bless you.
Previous Topic:lexer of Xtext (antlr)
Next Topic:How to use Static fields in MWE2 Files
Goto Forum:
  


Current Time: Wed Apr 24 15:48:51 GMT 2024

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

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

Back to the top