Skip to main content



      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 08:18 Go to next message
Eclipse UserFriend
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 08:29 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Beginners Question - 15 minute Tutorial Extended [message #697943 is a reply to message #697936] Mon, 18 July 2011 08:37 Go to previous message
Eclipse UserFriend
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 Jul 04 09:39:10 EDT 2025

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

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

Back to the top