Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext Code generator Problem
Xtext Code generator Problem [message #1023953] Mon, 25 March 2013 14:33 Go to next message
d 627 is currently offline d 627Friend
Messages: 28
Registered: March 2013
Junior Member
Hi everyone

I'm new in xtext. and I needed for the project of my tesis; I've been doing the 15 minutes tutorial but with several problems with the code generator. This is what I've done until now:

* generated by Xtext
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
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.xtext.example.mydsl.dmodel.Entity
import org.xtext.example.mydsl.dmodel.Feature


class DomainmodelGenerator implements IGenerator {

@Inject extension IQualifiedNameProvider nameProvider

override void doGenerate(Resource resource, IFileSystemAccess fsa) {
for(e: resource.allContents.toIterable.filter(typeof(Entity))) {
e.fullyQualifiedName.toString.replace(".", "/") + ".java",

def compile(Entity e) '''
«IF e.eContainer != null»
package «e.eContainer.fullyQualifiedName»;

public class «» «IF e.superType != null»
extends «e.superType.fullyQualifiedName» «ENDIF»{
«FOR f:e.features»

def compile(Feature f) '''
private «f.type.fullyQualifiedName» «»;

public «f.type.fullyQualifiedName» get«»() {
return «»;

public void set«»(«f.type.fullyQualifiedName» «») {
this.«» = «»;

I got 2 problems with 2 lines of the code
1) e.fullyQualifiedName.toString.replace(".", "/") + ".java". The editor tells: "The method fullyQualifiedName is undefined for the type DomainmodelGenerator" and "Couldn't resolve reference to JvmIdentifiableElement '+'"

2) e.compile : "The method compile is undefined for the type DomainmodelGenerator"
But in theory I've defined this methods in the same file.

I don't know if the problem is collegated whit the libraries that I have to import. In theory the steps I've done are similar to the tutorial but it seems that this one is refered to a previous version and some things have chance.

Thanks a lot for your cooperation.

Re: Xtext Code generator Problem [message #1024371 is a reply to message #1023953] Tue, 26 March 2013 07:00 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13613
Registered: July 2009
Senior Member

i actually cannot reproduce this. (using Xtext 2.4.0)
can you share your complete projects?


Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:WrappedException: The path is unmapped
Next Topic:Xtext: Referencing Elements of one DSL from another DSL Problem
Goto Forum:

Current Time: Mon Sep 28 23:26:53 GMT 2020

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

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

Back to the top