Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » toField and newTypeRef question(real newbie questions inside :))
icon5.gif  toField and newTypeRef question [message #1434811] Tue, 30 September 2014 16:32 Go to next message
Alexander Shutyaev is currently offline Alexander ShutyaevFriend
Messages: 4
Registered: July 2009
Junior Member
Hi all!

I'm having a trouble with the following simple situation. I took the greeting sample and changed the jvm model inferrer to:
class MyDslJvmModelInferrer extends AbstractModelInferrer {

   	def dispatch void infer(Model element, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
		acceptor.accept(element.toClass('Greeting')).initializeLater[
			members += element.toField('texts', element.newTypeRef(List, element.newTypeRef(String)))
		]
   	}

}

The generated code is as follows:
@SuppressWarnings("all")
public class Greeting {
  private java.util.List texts;
}

There are two things I'm having trouble with:

1) Why is List not parametrized with String? I thought I've specified it explicitly in newTypeRef...
2) Is there any way to automatically generate the imports section so that simple names are used in code (where possible, in case of simple name collissions - stick with the fully qualified name)? If yes, how can this be achieved?

Thanks in advance! Razz
Re: toField and newTypeRef question [message #1435220 is a reply to message #1434811] Wed, 01 October 2014 07:13 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

the code you wrote should work just fine. Which Java compiler version is
configured in your project? Is it 1.4 by accident? Also the imports
should be maintained automatically. Also for those, the generated code
that you posted indicates a problem with your project config. Maybe it's
not the Java version but a missing JRE?
If the problem persists, could you please file a ticket and attach a
reproducable example?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: toField and newTypeRef question [message #1435566 is a reply to message #1435220] Wed, 01 October 2014 17:39 Go to previous message
Alexander Shutyaev is currently offline Alexander ShutyaevFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Sebastian,

you were right - the reason was missing JRE. I thought that java comes into play only when (and if) generated code is compiled. But it turns out it is required during code generation phase too. Anyway, thanks for help.
Previous Topic:infer annotation with key-value Pairs
Next Topic:share state between composed validators
Goto Forum:
  


Current Time: Fri Apr 26 08:10:24 GMT 2024

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

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

Back to the top