Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Cross reference problem when building after a Clean
Cross reference problem when building after a Clean [message #769029] Wed, 21 December 2011 04:28 Go to next message
Eclipse UserFriend
Hi!

My language has models in diferents files. It can have references from one to another, and this is working fine if the referenced model is already compiled (partial build). The problem comes when I do a Clean Project. What I have from the cross reference is a proxy class, so I can't validate neither infer Jvm, because I can't get the JvmTypeReference of the referenced model. I do this by getting the fullQualifiedName of the cross reference, but when it is a proxy, I get NULL.

How can I get the JvmTypeReference for cross references on this situation?

Thanks!
Re: Cross reference problem when building after a Clean [message #769157 is a reply to message #769029] Wed, 21 December 2011 08:47 Go to previous messageGo to next message
Eclipse UserFriend
The recommended way of creating Java from your own DSL is to implement
an IJvmModelInferrer and use the JvmModelGenerator to generate the Java
code from that model.

The JVM model can then be referred to form other models without the
actual Java code in place. Xtext's index should transparently handle
that for you.

If you're already using this setup, make sure your inferred JVM model is
indexed properly (IDefaultResourceDescriptionStrategy).

Am 21.12.11 10:28, schrieb rjarana:
> Hi!
>
> My language has models in diferents files. It can have references from
> one to another, and this is working fine if the referenced model is
> already compiled (partial build). The problem comes when I do a Clean
> Project. What I have from the cross reference is a proxy class, so I
> can't validate neither infer Jvm, because I can't get the
> JvmTypeReference of the referenced model. I do this by getting the
> fullQualifiedName of the cross reference, but when it is a proxy, I get
> NULL.
>
> How can I get the JvmTypeReference for cross references on this situation?
>
> Thanks!


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Cross reference problem when building after a Clean [message #769163 is a reply to message #769157] Wed, 21 December 2011 09:01 Go to previous messageGo to next message
Eclipse UserFriend
Maybe I'm inferring the JvmTypeReference of cross reference wrong. I'm doing this (superType is the cross reference to another Definition):

@Inject private TypeReferences references
...
def dispatch infer(Definition e, IAcceptor<JvmDeclaredType> acceptor, boolean prelinkingPhase) {
    var JvmTypeReference superType = references.getTypeForName(e.superType.fullyQualifiedName.toString, e);

    jvmClass.superTypes += superType;
...


So when it's a compilation after a Clean Project, e.superType.fullyQualifiedName is null.
Re: Cross reference problem when building after a Clean [message #769576 is a reply to message #769163] Thu, 22 December 2011 06:01 Go to previous messageGo to next message
Eclipse UserFriend
You should not resolve cross-references during the JVM model inferrence.
Try use EcoreUtil2.cloneWithProxies() to create a copy of the proxied
superType and add this as superType instead.

If that does not work, try to debug the IQualifiedNameProvider of your
language.


Am 21.12.11 15:01, schrieb rjarana:
> Maybe I'm inferring the JvmTypeReference of cross reference wrong. I'm
> doing this (superType is the cross reference to another Definition):
>
>
> @Inject private TypeReferences references
> ..
> def dispatch infer(Definition e, IAcceptor<JvmDeclaredType> acceptor,
> boolean prelinkingPhase) {
> var JvmTypeReference superType =
> references.getTypeForName(e.superType.fullyQualifiedName.toString, e);
>
> jvmClass.superTypes += superType;
> ..
>
>
> So when it's a compilation after a Clean Project,
> e.superType.fullyQualifiedName is null.


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Cross reference problem when building after a Clean [message #769594 is a reply to message #769576] Thu, 22 December 2011 06:47 Go to previous messageGo to next message
Eclipse UserFriend
EcoreUtil2.cloneWithProxies() returns an EObject, and superTypes requires JvmTypeReference.
Re: Cross reference problem when building after a Clean [message #769603 is a reply to message #769594] Thu, 22 December 2011 07:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

downcasting should work

(JvmTypeReference)EcoreUtil2.cloneWithProxies(ref)

~Christian
Re: Cross reference problem when building after a Clean [message #769610 is a reply to message #769603] Thu, 22 December 2011 07:10 Go to previous messageGo to next message
Eclipse UserFriend
Doesn't work:

java.lang.ClassCastException: org.dsl.mylang.impl.DefinitionImpl cannot be cast to org.eclipse.xtext.common.types.JvmTypeReference

Re: Cross reference problem when building after a Clean [message #769617 is a reply to message #769610] Thu, 22 December 2011 07:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

are we talking about the supertype of the model or inferred supertype in the jvm world
jan actually meant something like in the domain model example

the cloned supertype in the model world is of course still a odd model object (in your case a definition)

so you might actually have to go the
"debugging" way

~Christian

[Updated on: Thu, 22 December 2011 07:19] by Moderator

Re: Cross reference problem when building after a Clean [message #769629 is a reply to message #769617] Thu, 22 December 2011 07:43 Go to previous messageGo to next message
Eclipse UserFriend
I'm now totally lost.

My language is something like this:

Definition:
    'definition' name=ValidID ('extends' superType=[Definition|QualifiedName])? '{'
        features += Feature*
    '}'
;

Feature:
    Attribute | Property
;

Property:
    'property' name=ValidID ('{' 
        features+=Feature*
    '}')?
;

Attribute:
    id=ValidID '=' value=XTReference
;

Referenciable:
    Property | Definition
;

XTReference:
    'ref' value=[Referenciable|QualifiedName]
;



So as you can see, I have cross-reference in Definition super type and in Attribute, referring to a Definition or a Property (in the same or different Definition, that's why I use QualifiedName).

When I infer the Jvm model, I create a class for every Definition and Property. So I need to get the JvmTypeReference of the referenced element to generate the correct method signature in Java.

Any suggestion?
Re: Cross reference problem when building after a Clean [message #769636 is a reply to message #769629] Thu, 22 December 2011 07:54 Go to previous message
Eclipse UserFriend
Hi,

since you have a refernce to a Definition
and not a JvmTypeReference there is no easy solution for that.
if you do not have imports in your dsl you
could use the NodeModelUtil to find out the actual text in the model file at the place of the refernce.

maybe jan has an idea how to do this nice without resolving the proxy.

~Christian
Previous Topic:Xtext editor to insert single proposals automatically without showing content assist popup
Next Topic:IContainer.Manager returns weird things i've never imported???
Goto Forum:
  


Current Time: Fri Nov 07 04:41:59 EST 2025

Powered by FUDForum. Page generated in 0.05177 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top