Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JvmTypeReference isAssignable
JvmTypeReference isAssignable [message #1739341] Sat, 30 July 2016 06:13 Go to next message
Didier Didos is currently offline Didier DidosFriend
Messages: 14
Registered: April 2016
Junior Member
Hello,

In a jvmModelInferer I'd like to test if a JvmTypeReference is a subtype of Number.

Xbase validator offer a method to get a LightWeighTypeRefernce from JvmTypeReference, but how to achieve the same operation in an infererr?

Thanks a lot.
Re: JvmTypeReference isAssignable [message #1739375 is a reply to message #1739341] Sun, 31 July 2016 07:26 Go to previous messageGo to next message
Stéphane Galland is currently offline Stéphane GallandFriend
Messages: 123
Registered: July 2014
Location: Belfort, France
Senior Member
Dear Didier.

I do the following in my inferrer:
class JvmInferrer {
    @Inject
    private CommonTypeComputationServices services;

    public LightweightTypeReference toLightweightTypeReference(
			JvmTypeReference typeRef) {
        return toLightweightTypeReference(typeRef, false);
    ]
    public LightweightTypeReference toLightweightTypeReference(
			JvmTypeReference typeRef,
			boolean keepUnboundWildcardInformation) {
	if (typeRef == null)  return null;
	StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef);
	LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner,
			keepUnboundWildcardInformation);
	return factory.toLightweightReference(typeRef);
    }
}
Re: JvmTypeReference isAssignable [message #1739389 is a reply to message #1739375] Sun, 31 July 2016 12:34 Go to previous message
Didier Didos is currently offline Didier DidosFriend
Messages: 14
Registered: April 2016
Junior Member
Thanks a lot Stéphane,
Merci
Previous Topic:Creating multiple elements at the root of the model
Next Topic:ImportNamespace scoping problem
Goto Forum:
  


Current Time: Thu Apr 25 23:37:44 GMT 2024

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

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

Back to the top