Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext: src-gen is empty
Xtext: src-gen is empty [message #881243] Mon, 04 June 2012 07:58 Go to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
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 116 times)
Re: Xtext: src-gen is empty [message #881255 is a reply to message #881243] Mon, 04 June 2012 08:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Van you post your jvmmodelinferrer

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: src-gen is empty [message #881257 is a reply to message #881255] Mon, 04 June 2012 08:30 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
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 08:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi a jvmmodelinferrer is a class in your run time project!

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: src-gen is empty [message #881276 is a reply to message #881263] Mon, 04 June 2012 09:11 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
Thanks, now I have understand.
I have found the class.
Have a lot of thanks.

[Updated on: Mon, 04 June 2012 09:15]

Report message to a moderator

Re: Xtext: src-gen is empty [message #881283 is a reply to message #881276] Mon, 04 June 2012 09:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi please compare your projects with the one from the domain model
example. Especially the grammar and workflow


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: src-gen is empty [message #881292 is a reply to message #881283] Mon, 04 June 2012 09:45 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
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 14:48 Go to previous messageGo to next message
Hans-Georg Glöckler is currently offline Hans-Georg GlöcklerFriend
Messages: 88
Registered: July 2009
Member
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 113 times)
Re: Xtext: src-gen is empty [message #881452 is a reply to message #881431] Mon, 04 June 2012 15:25 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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: Thu Mar 28 22:22:32 GMT 2024

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

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

Back to the top