Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext: src-gen is empty
Xtext: src-gen is empty [message #881243] Mon, 04 June 2012 03:58 Go to next message
Eclipse UserFriend
I have a grammar (Ytext based on Xbase) and a model.
In the model-File I can create my model
In the model I have created the folder src-gen.
My Problem is:
When I save my Modelfile, there is no java-File in the src-gen folder

I send you a picture of my model.

My grammar is
grammar org.lunifera.metamodel.dsl.entity.Entity with org.eclipse.xtext.xbase.Xbase

generate entity "http://www.lunifera.org/metamodel/dsl/entity/Entity"

DomainModel:
	elements+=AbstractElement*;

AbstractElement:
	PackageDeclaration | Entity | Import;

PackageDeclaration:
	'package' name=QualifiedName elements+=AbstractElement* ';'	;

Import:
	'import' importedNamespace=QualifiedNameWithWildCard';';

Entity:
	'entity' name=ValidID ('extends' superType=JvmParameterizedTypeReference)? '{'
		features+=Feature*
	'}';

Feature:
	Property | Operation;

Property:
	(modifier=Modifier) name=ValidID ':' type=JvmTypeReference ';';

Operation:
	(modifier=Modifier) 'def' name=ValidID '(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')' ':' type=JvmTypeReference 
		body=XBlockExpression;

Modifier:
	 final?='final'? & static?='static'? & visibility=Visibility;	

enum Visibility:
	 PACKAGE='package' | PRIVATE='private' | PROTECTED='protected' |  PUBLIC='public';

QualifiedNameWithWildCard :
	QualifiedName  ('.' '*')?;
  • Attachment: Unbenannt.png
    (Size: 124.69KB, Downloaded 138 times)
Re: Xtext: src-gen is empty [message #881255 is a reply to message #881243] Mon, 04 June 2012 04:20 Go to previous messageGo to next message
Eclipse UserFriend
Van you post your jvmmodelinferrer
Re: Xtext: src-gen is empty [message #881257 is a reply to message #881255] Mon, 04 June 2012 04:30 Go to previous messageGo to next message
Eclipse UserFriend
I get no jvmmodelinferrer.
When I save the file "Sample01.entity" then happens nothing.
The file is saved, thats all.
Re: Xtext: src-gen is empty [message #881263 is a reply to message #881257] Mon, 04 June 2012 04:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi a jvmmodelinferrer is a class in your run time project!
Re: Xtext: src-gen is empty [message #881276 is a reply to message #881263] Mon, 04 June 2012 05:11 Go to previous messageGo to next message
Eclipse UserFriend
Thanks, now I have understand.
I have found the class.
Have a lot of thanks.

[Updated on: Mon, 04 June 2012 05:15] by Moderator

Re: Xtext: src-gen is empty [message #881283 is a reply to message #881276] Mon, 04 June 2012 05:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi please compare your projects with the one from the domain model
example. Especially the grammar and workflow
Re: Xtext: src-gen is empty [message #881292 is a reply to message #881283] Mon, 04 June 2012 05:45 Go to previous messageGo to next message
Eclipse UserFriend
Thanks, now I have understand.
Have a lot of thanks.
Step by Step I understand more
Smile
Re: Xtext: src-gen is empty [message #881431 is a reply to message #881292] Mon, 04 June 2012 10:48 Go to previous messageGo to next message
Eclipse UserFriend
I have no solved the Problem.
But I have one more problem. The java-class is saved in the src-gen folder in the default-package.
What must I do, that it saved in the correct package in the src-gen folder

My code is
package org.lunifera.metamodel.dsl.entity.jvmmodel

import com.google.inject.Inject
import org.eclipse.xtext.common.types.JvmDeclaredType
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.eclipse.xtext.util.IAcceptor
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
import org.lunifera.metamodel.dsl.entity.entity.Entity
import org.lunifera.metamodel.dsl.entity.entity.Operation
import org.lunifera.metamodel.dsl.entity.entity.Property

class EntityJvmModelInferrer extends AbstractModelInferrer {
	@Inject extension JvmTypesBuilder
	@Inject extension IQualifiedNameProvider

   	def dispatch void infer(Entity e, IAcceptor<JvmDeclaredType> acceptor, boolean isPrelinkingPhase) {
		acceptor.accept(
			e.toClass( e.fullyQualifiedName ) [
				documentation = e.documentation
				if (e.superType != null)
					superTypes += e.superType.cloneWithProxies
					
				for ( f : e.features ) {
					switch f {
				
						Property : {
							members += f.toField(f.name, f.type)
							members += f.toGetter(f.name, f.type)
							members += f.toSetter(f.name, f.type)
						}
				
						Operation : {
							members += f.toMethod(f.name, f.type) [
								documentation = f.documentation
								for (p : f.params) {
									parameters += p.toParameter(p.name, p.parameterType)
								}
								body = f.body
							]
						}
					}
				}
			]
		)
   	}
}


  • Attachment: Bild 1.png
    (Size: 133.44KB, Downloaded 131 times)
Re: Xtext: src-gen is empty [message #881452 is a reply to message #881431] Mon, 04 June 2012 11:25 Go to previous message
Eclipse UserFriend
Hans-Georg,

you should start and write unit tests and learn more about EMF, Xtext
and debugging. Your grammar clearly separates packages by semicolon thus
the defined entity is not contained in something that has the name
org.sample.

Please be aware of the fact that most people in this forum do this in
their spare time. It's not often a good idea to throw screen shots,
complete model inferers and grammars into a question and let others do
your homework.

Best regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 04.06.12 16:48, schrieb hans-georg Mising name:
> I have no solved the Problem.
> But I have one more problem. The java-class is saved in the src-gen folder in the default-package.
> What must I do, that it saved in the correct package in the src-gen folder
>
> My code is
>
> package org.lunifera.metamodel.dsl.entity.jvmmodel
>
> import com.google.inject.Inject
> import org.eclipse.xtext.common.types.JvmDeclaredType
> import org.eclipse.xtext.naming.IQualifiedNameProvider
> import org.eclipse.xtext.util.IAcceptor
> import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
> import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
> import org.lunifera.metamodel.dsl.entity.entity.Entity
> import org.lunifera.metamodel.dsl.entity.entity.Operation
> import org.lunifera.metamodel.dsl.entity.entity.Property
>
> class EntityJvmModelInferrer extends AbstractModelInferrer {
> @Inject extension JvmTypesBuilder
> @Inject extension IQualifiedNameProvider
>
> def dispatch void infer(Entity e, IAcceptor<JvmDeclaredType> acceptor, boolean isPrelinkingPhase) {
> acceptor.accept(
> e.toClass( e.fullyQualifiedName ) [
> documentation = e.documentation
> if (e.superType != null)
> superTypes += e.superType.cloneWithProxies
>
> for ( f : e.features ) {
> switch f {
>
> Property : {
> members += f.toField(f.name, f.type)
> members += f.toGetter(f.name, f.type)
> members += f.toSetter(f.name, f.type)
> }
>
> Operation : {
> members += f.toMethod(f.name, f.type) [
> documentation = f.documentation
> for (p : f.params) {
> parameters += p.toParameter(p.name, p.parameterType)
> }
> body = f.body
> ]
> }
> }
> }
> ]
> )
> }
> }
>
>
>
Previous Topic:Serialise Models in jar Models
Next Topic:Lists and Attributes without order
Goto Forum:
  


Current Time: Mon Jul 14 21:44:27 EDT 2025

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

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

Back to the top