15 Minute Tutorial Extended [message #915474] |
Mon, 17 September 2012 07:06  |
Eclipse User |
|
|
|
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.fullyQualifiedName.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!
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03922 seconds