Xtext: src-gen is empty [message #881243] |
Mon, 04 June 2012 03:58  |
Eclipse User |
|
|
|
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 ('.' '*')?;
|
|
|
|
|
|
|
|
|
Re: Xtext: src-gen is empty [message #881431 is a reply to message #881292] |
Mon, 04 June 2012 10:48   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
> ]
> }
> }
> }
> ]
> )
> }
> }
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.09576 seconds