Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Beginners Question - 15 minute Tutorial Extended(Errors when trying to compose Xtend file)
Beginners Question - 15 minute Tutorial Extended [message #697936] Mon, 18 July 2011 12:18 Go to next message
mm  is currently offline mm Friend
Messages: 3
Registered: July 2011
Junior Member
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!
Re: Beginners Question - 15 minute Tutorial Extended [message #697939 is a reply to message #697936] Mon, 18 July 2011 12:29 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

you are missing the import for Entity. The simplest way is invoking code completion at the end of "Entity", you then select the Entity interface of the domainmodel example. This inserts the needed import. Note that there is no "organise imports" for Xtend2 yet.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Beginners Question - 15 minute Tutorial Extended [message #697943 is a reply to message #697936] Mon, 18 July 2011 12:37 Go to previous message
mm  is currently offline mm Friend
Messages: 3
Registered: July 2011
Junior Member
OK, yes, of course - that was it!!
So it was a stupid mistake... Thanks so much for the quick support!!
Previous Topic:Generator POC fails on OSGi
Next Topic:com.google.common shipped with Xtext
Goto Forum:
  


Current Time: Fri Sep 25 11:35:41 GMT 2020

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

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

Back to the top