|
|
|
|
|
|
|
Re: Xtext: src-gen is empty [message #881431 is a reply to message #881292] |
Mon, 04 June 2012 14:48 |
Hans-Georg Glöckler 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 |
Sebastian Zarnekow 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
> ]
> }
> }
> }
> ]
> )
> }
> }
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02097 seconds