entity cross references in domainmodel [message #756794] |
Tue, 15 November 2011 07:08 |
tiange zhang Messages: 16 Registered: February 2011 Location: Shanghai, China |
Junior Member |
|
|
hi,
I modify the org.eclipse.xtext.examples.domainmodel grammar from:
'entity' name=ValidID ('extends' superType=JvmParameterizedTypeReference)? '{'
to:
'entity' name=ValidID ('extends' superType=[Entity])? '{'...
I also modify the related code of DomainmodelJvmModelInferrer.xtend form:
if (e.superType != null)
superTypes += e.superType.cloneWithProxies
to:
if (e.superType != null)
//superTypes += e.superType.jvmElements.filter(typeof(JvmType)).head.createTypeRef()
superTypes += typeReferences.findDeclaredType(e.superType.fullyQualifiedName.toString,e).createTypeRef()
First reason of this modification is I want the supertype of entity must be another entity. Another reason is each entity will generate a java interface and an implementation.
The problem is, the entity must defined in the right sequence, otherwise will cause NullPointerException during source generation dur to typeReferences.findDeclaredType returns null.
following model is ok in editor, but cann't generate java source.
package a{
entity A extends B{
}
entity B{
}
}
I think the real problem is, if any generated java source will be referenced via TypeReferences.findDeclaredType or IJvmModelAssociations.getJvmElements(), success or not depends on the definition sequence.
For a large model, especially attribute/operation are introduced,it is difficult to arrange sequence of type definitions , so are there some way to fix this problem systematically? I noticed that there is a parameter named prelinkingPhase in IJvmModelInferrer.infer(...), is it for this problem?
Thanks.
Tiange Zhang
|
|
|
|
Powered by
FUDForum. Page generated in 0.01719 seconds