Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » 15 Minute Tutorial Extended(Problems with the Generator)(Type mismatch: cannot convert from Class<DomainmodelGenerator> to Class<? extends IGenerator2>)
15 Minute Tutorial Extended(Problems with the Generator) [message #1729883] Tue, 19 April 2016 23:48 Go to next message
Tatiana Wert is currently offline Tatiana WertFriend
Messages: 3
Registered: April 2016
Junior Member
Hello!
I just started learning XTEXT. I successfully completed the 15 Minute Tutorial. I am using Eclipse Mars and the latest version of Xtext.

I am modified DomainmodelGenerator.xtend according to the tutorial in order to generate code for my future models. But every time I am trying to launch a new Eclipse Application I got an error (in file src-gen/org/example/domainmodel/AbstractDomainmodelRuntimeModule.java):

Type mismatch: cannot convert from Class<DomainmodelGenerator> to Class<? extends IGenerator2>

The error occurs in the generated file on that piece of code:
// contributed by org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2
public Class<? extends IGenerator2> bindIGenerator2() {
return DomainmodelGenerator.class;
}

Here is my code:

package org.example.domainmodel.generator

import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IGenerator
import org.eclipse.xtext.generator.IFileSystemAccess
import org.example.domainmodel.domainmodel.Entity
import org.example.domainmodel.domainmodel.Feature
import org.eclipse.xtext.naming.IQualifiedNameProvider

import com.google.inject.Inject

class DomainmodelGenerator implements IGenerator {

@Inject extension IQualifiedNameProvider

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

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

public class «e.name» «IF e.superType != null
»extends «e.superType.fullyQualifiedName» «ENDIF»{
«FOR f : e.features»
«f.compile»
«ENDFOR»
}
'''

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

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

public void set«f.name.toFirstUpper»(«f.type.fullyQualifiedName» «f.name») {
this.«f.name» = «f.name»;
}
'''
}


Thank you in advance with your help!
Re: 15 Minute Tutorial Extended(Problems with the Generator) [message #1729976 is a reply to message #1729883] Wed, 20 April 2016 15:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13186
Registered: July 2009
Senior Member
In xtext 2.9x you have to implement igenerator2

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: 15 Minute Tutorial Extended(Problems with the Generator) [message #1730154 is a reply to message #1729976] Thu, 21 April 2016 19:45 Go to previous message
Tatiana Wert is currently offline Tatiana WertFriend
Messages: 3
Registered: April 2016
Junior Member
Thank you for your reply
Previous Topic:Xtext & ANTLR IP questions
Next Topic:Qualified Name Provider
Goto Forum:
  


Current Time: Wed Nov 13 08:11:41 GMT 2019

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

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

Back to the top