Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to get returntype of xblockexpression(using scripting language)
How to get returntype of xblockexpression [message #1089775] Mon, 19 August 2013 08:20 Go to next message
Thomas Goossens is currently offline Thomas GoossensFriend
Messages: 32
Registered: August 2013
Member
(Using the example scripting language)

currently I use ITypeProvider to get a JvmTypeReference of the last expression's returntype in the xblockexpression

script.expressions.last



I have two questions:

1) I notice that the class is deprecated? What should I use instead?

2) What if I want it to be able "detect" my own classes as returntype (not only the java primitives and String). Do I have to register these type somewhere?

Thanks Smile

[Updated on: Mon, 19 August 2013 08:22]

Report message to a moderator

Re: How to get returntype of xblockexpression [message #1089778 is a reply to message #1089775] Mon, 19 August 2013 08:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

did you have a look at the domain model example? it shows how to deal with a implcit return type


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to get returntype of xblockexpression [message #1089813 is a reply to message #1089778] Mon, 19 August 2013 09:25 Go to previous messageGo to next message
Thomas Goossens is currently offline Thomas GoossensFriend
Messages: 32
Registered: August 2013
Member
Hi thanks for the quick response.

If I understand it correctly, in the example they rely on the fact that a Feature has a 'type' field. And pass that to the 'toMethod' method?

[Updated on: Mon, 19 August 2013 09:27]

Report message to a moderator

Re: How to get returntype of xblockexpression [message #1089857 is a reply to message #1089813] Mon, 19 August 2013 10:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi

isnt the return type optional? have a look at the inferrer


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to get returntype of xblockexpression [message #1100695 is a reply to message #1089775] Tue, 03 September 2013 13:02 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 08/19/2013 10:20 AM, Thomas Goossens wrote:
> (Using the example scripting language)
>
> currently I use ITypeProvider to get the returntype of the last
> expression in the xblock
>
> script.expressions.last
>
>
> I have two questions:
>
> 1) I notice that the class is deprecated? What should I use instead?
>
> 2) What if I want it to be able "detect" my own classes as returntype
> (not only the java primitives and String). Do I have to register these
> type somewhere?
>
> Thanks :)

Hi

as far as I know, now you should inject a

IBatchTypeResolver typeResolver

and then do something like

typeResolver.resolveTypes(e).
getActualType(e)?.toTypeReference

to get the type reference.

In order for this mechanism to work, you must make sure that the
expression is passed to the TypeComputer otherwise types will not be
resolved.

This requires that the main xexpression block is logically contained in
inferred java method.

If you want to give custom types to some expressions you can implement
your own TypeComputer. An example can be found in the 7 languages examples.

hope this helps
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
XTEXT BOOK:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Previous Topic:ValueConverterException
Next Topic:Simplest way to build Xtext (TMF) from source code
Goto Forum:
  


Current Time: Fri Apr 26 20:38:47 GMT 2024

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

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

Back to the top