Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » 15 Minute Tutorial Extended(Problems with the Generator)
15 Minute Tutorial Extended [message #915474] Mon, 17 September 2012 11:06 Go to next message
Natalie Cranston is currently offline Natalie CranstonFriend
Messages: 12
Registered: August 2012
Junior Member
Hello,

I am currently trying to do the 15 Minute Tutorial Extended. I was able to successfully complete the 15 Minute Tutorial. I am using Eclipse Juno and the latest version of Xtext.

I have a lot of JVM errors saying, 'Couldn't recognize reference to JVM type 'Entity', etc. Also, now when I try to save what I have it says that the save could not be completed because 'Some characters cannot be mapped using 'Cp1252' character encoding. Either change the encoding or remove the characters which are not supported by the 'Cp1252' characted encoding.'

I also continued looking through the document and found the 'Define the Mapping to JVM Concepts' (http://www.eclipse.org/Xtext/documentation.html#_8). I do not have a stub org/example/domainmodel/jvmmodel/DomainmodelJvmModelInferrer.xtend or anything similar.

Here is my code:

/*
* generated by Xtext
*/
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.eclipse.xtext.example.domainmodel.Entity
import org.eclipse.xtext.example.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(typeof(Entity))){fsa.generateFile(
e.fullyQuali´ČüedName.toString("/") +".java"
e.compile)
}
}

def compile(Entity e)'''
<<IF e.eContained != 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>>;
}
'''

}



Thanks for your help!
Re: 15 Minute Tutorial Extended [message #915652 is a reply to message #915474] Mon, 17 September 2012 17:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Hi,

you have to make sure that you generated the language - then a java class Entity should have been generated which you can use in the Inferrer (you need an import of course)
for the encoding problem it might be the easiest to set the workspace encoting to utf-8

~Christian
Re: 15 Minute Tutorial Extended [message #915911 is a reply to message #915652] Tue, 18 September 2012 07:53 Go to previous messageGo to next message
Natalie Cranston is currently offline Natalie CranstonFriend
Messages: 12
Registered: August 2012
Junior Member
Hello,

Setting the workspace encoding to UTF-8 worked, thanks. Very Happy

I cannot get the code to generate because there are errors. Maybe I have done something wrong following the tutorial, I am not sure. I am still getting errors saying 'Couldn't resolve type reference to Jvm type' for both the .Entity and .Feature.

Natalie

Re: 15 Minute Tutorial Extended [message #915915 is a reply to message #915911] Tue, 18 September 2012 07:56 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6499
Registered: July 2009
Senior Member
Can you share the complete inferrer and verify that the java classes
exist?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Previous Topic:Problem with simple grammar
Next Topic:How to embed new line character in string in xtend?
Goto Forum:
  


Current Time: Thu Nov 27 18:44:03 GMT 2014

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

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