Beginners Question - 15 minute Tutorial Extended [message #697936] |
Mon, 18 July 2011 08:18  |
Eclipse User |
|
|
|
Hi!
I am just starting out with Xtext 2.0 and hence am working through the 15 minute tutorial. I have arrived at the 15 minute extended tutorial
and just entered the following part of the suggested code into the file DomainmodelGenerator.xtend.
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 static extension org.eclipse.xtext.xtend2.lib.ResourceExtensions.*
import org.example.domainmodel.Domainmodel.xtext
import org.eclipse.xtext.naming.IQualifiedNameProvider
import com.google.inject.Inject
class DomainmodelGenerator implements IGenerator {
@Inject extension IQualifiedNameProvider nameProvider
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
for(e: resource.allContentsIterable.filter(typeof(Entity))) {
}
}
}
Unfortunately I get the following two errors at the point typeof(Entity).
- Incompatible types. Expected java.lang.Class<void> but was
java.lang.Class<void>
- Couldn't resolve reference to JvmType 'Entity'.
Probably this is just a very stupid mistake - but I just don't seem to be able to find it. Can you possibly help me?
I have attached my DSL-File as well:
Domainmodel:
(elements += AbstractElement)*
;
PackageDeclaration:
'package' name = QualifiedName '{'
(elements += AbstractElement)*
'}'
;
AbstractElement:
PackageDeclaration | Type | Import
;
QualifiedName:
ID ('.' ID)*
;
Import:
'import' importedNamespace = QualifiedNameWithWildcard
;
QualifiedNameWithWildcard:
QualifiedName '.*'?
;
Type:
DataType | Entity
;
DataType:
'datatype' name=ID
;
Entity:
'entity' name = ID
('extends' superType = [Entity | QualifiedName])?
'{'
(features += Feature)*
'}'
;
Feature:
(many ?= 'many')? name = ID ':' type = [Type | QualifiedName]
;
Thank you so much!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.14169 seconds