[IJvmModelInferrer] Referencing not yet existing classes [message #1123300] |
Wed, 02 October 2013 08:16  |
Eclipse User |
|
|
|
Hello!
I have Xtext grammar like
Entity: 'entity' name=ID ('extends' ext=[Entity])?;
Using IJvmModelInferrer I generate interfaces for each entity:
* Entity1 => interface IEntity1
* Entity2 => interface IEntity2
Now, if I extend Entity2 from Entity1 I want to extend generated interfaces as well:
* Entity1 => interface IEntity1
* Entity2 extends Entity1 => interface IEntity2 extends IEntity1
In order to infer Entity2 in this case I have to get JvmTypeReference for the IEntity1 interface. If the order of the generation is Entity1, Entity2 this isn't a problem. Inferring Entity2 first otherwise results in a problem, that IEntity1 doesn't exist yet.
Is there a standard way to use classes/interfaces, that doesn't yet exist?
(Besides using appender appending full qualified name of the class as string?)
Thank you in advice!
Cheers,
Boris
|
|
|
Re: [IJvmModelInferrer] Referencing not yet existing classes [message #1128058 is a reply to message #1123300] |
Mon, 07 October 2013 05:40  |
Eclipse User |
|
|
|
Let me be more concrete:
When getting a reference to a not yet inferred class/interface, JvmTypesBuilder.newTypeRef() returns an instance of the JvmUnknownTypeReference class with the required canonical name saved in it. You can use this reference. This is fine, but it has at least following problems:
1. Adding such reference to the "superTypes" list of the class always produces "implements" no matter whether JvmUnknownTypeReference points to the class or interface. (There are currently no way to detect or set this)
2. No import manager get used making the generated code complex to test. Your test depends on the order of class inference. For example, you trying to get "interface A extends B". Then generated code imports B, if it was already inferred and doesn't import B using canonical name, if B wasn't inferred yet: "interface A extends org.eclipse.text.B".
Is there some workarounds? Especially to "1"?
Thank you!
Xtext 2.4.3
|
|
|
Powered by
FUDForum. Page generated in 0.04909 seconds