cross reference / multiple files / JvmModelInferer [message #1049847] |
Fri, 26 April 2013 10:43 |
Andreas Flügge Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Hello!
I started making my first steps with Xtext and the following simple model:
grammar myDSL with org.eclipse.xtext.xbase.annotations.XbaseWithAnnotations
generate myDSL "..."
Model:
PackageDeclaration
importSection = XImportSection?
(entities += Entity)*;
PackageDeclaration:
'package' name = QualifiedName;
Entity:
(annotations += Annotation)*
(abstract ?= 'abstract')? 'entity' name = ID ('extends' superType = [Entity])? '{'
(members += Member)*
'}';
Member:
(annotations += Annotation)*
type = JvmTypeReference name = ID;
Annotation:
annotation = XAnnotation;
... and three files ...
Base.model:
package mymodel
abstract entity Base {
String key
String value
}
TypeA.model:
package mymodel.packageA
import java.util.Set
abstract entity TypeA extends Base {
String name
Set<String> properties
}
TypeB.model:
package mymodel.packageB
import java.util.Set
import mymodel.Base
abstract entity TypeB {
String name
Set<Base> properties
}
Everything works fine, code completion, highlighting, organize imports, ...
except the "extends Base" in file TypeA.model.
The error message is:
"Couldn't resolve reference to Entity 'Base'."
Because of the fact, that 'Base' is also correctly referenced in file TypeB.model, I suppose some issue with qualified names/JvmTypeReference and/or the JvmModelInferrer in the context of the 'superType' rule!?
My current JvmModelInferrer:
class MyDSLJvmModelInferrer extends AbstractModelInferrer {
@Inject extension JvmTypesBuilder
@Inject extension IQualifiedNameProvider
def dispatch void infer(Entity element, IJvmDeclaredTypeAcceptor acceptor,
boolean isPrelinkingPhase) {
acceptor.accept(element.toClass(element.fullyQualifiedName)).initializeLater [
documentation = element.documentation
for (member : element.members) {
members += member.toField(member.name, member.type)
members += member.toSetter(member.name, member.type)
members += member.toGetter(member.name, member.type)
}
]
}
}
Is there someone who can tell me what's wrong?
Thank you very much in advance,
Andreas
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03389 seconds