Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Creating method parameter "Class" instead "Class<?>"
Creating method parameter "Class" instead "Class<?>" [message #1726152] Thu, 10 March 2016 07:59 Go to next message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
Hi,

In my inferrer (XBase based language) I need to create a non-generic paramter of type "Class". It is mandatory because it is an implementation of an interface of XStream, which I cannot change.

Name clash: The method canConvert(Class<?>) of type MyXStreamConverterImpl has the same erasure as canConvert(Class) of type com.thoughtworks.xstream.converters.ConverterMatcher but does not override it


I'm creating the parameter like
parameters += toParameter( 'clazz', typeRefs.getTypeForName( Class, x ) )


This task is very important to me,
any ideas how I can create it without <?>?

Thanks
~Ingo
Re: Creating method parameter "Class" instead "Class<?>" [message #1726157 is a reply to message #1726152] Thu, 10 March 2016 08:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14355
Registered: July 2009
Senior Member
parameters += element.toParameter("clazz", Class.typeRef) works fine for me

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Creating method parameter "Class" instead "Class<?>" [message #1726159 is a reply to message #1726157] Thu, 10 March 2016 08:41 Go to previous messageGo to next message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
Hi Christian,

you don't get a <?>... sounds good, but I don't find the method ".typeRef". From which extension class is that coming from?
Re: Creating method parameter "Class" instead "Class<?>" [message #1726160 is a reply to message #1726159] Thu, 10 March 2016 08:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14355
Registered: July 2009
Senior Member
class MyDslJvmModelInferrer extends AbstractModelInferrer {

	@Inject extension JvmTypesBuilder

	def dispatch void infer(Element element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
		acceptor.accept(element.toClass("test."+element.name.toFirstUpper)) [
			members += element.toMethod("demo", Void.TYPE.typeRef()) [
				parameters += element.toParameter("clazz", Class.typeRef)
				body = element.body
			]
		]
	}
}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Creating method parameter "Class" instead "Class<?>" [message #1726161 is a reply to message #1726160] Thu, 10 March 2016 08:49 Go to previous messageGo to next message
Ingo Meyer is currently offline Ingo MeyerFriend
Messages: 162
Registered: July 2009
Senior Member
Interesting... I don't see that method. I have Xtext version 2.9.0.v201510300426
Re: Creating method parameter "Class" instead "Class<?>" [message #1726162 is a reply to message #1726161] Thu, 10 March 2016 09:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14355
Registered: July 2009
Senior Member
i use 2.9.2 but this method is stoneage old.
it binds to JvmTypeReferences.TypeRef(Class?, JvmTypeReference....)


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Creating method parameter &quot;Class&quot; instead &quot;Class&lt;?&gt;& [message #1726220 is a reply to message #1726159] Thu, 10 March 2016 15:21 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1794
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 10/03/2016 09:41, Ingo Meyer wrote:
> Hi Christian,
>
> you don't get a <?>... sounds good, but I don't find the method
> ".typeRef". From which extension class is that coming from?

It's in JvmTypeReferenceBuilder; it was introduced a few Xtext versions
ago (I think 2.7.0).

--
Prof. Lorenzo Bettini, Computer Science, DISIA, Univ. Firenze
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Previous Topic:How to disable partial parsing in xtext?
Next Topic:Xtext web editor -- how to deploy?
Goto Forum:
  


Current Time: Thu Oct 06 16:12:27 GMT 2022

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

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

Back to the top