Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How can I force JvmInferrer to import a class I used in a body statement(How can I force JvmInferrer to import a class I used in a body statement)
How can I force JvmInferrer to import a class I used in a body statement [message #1746101] Fri, 21 October 2016 18:32 Go to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
If I use a class inside a body=... statement the class does not get imported to the generated class.
How can I force JvmInferrer to import a class I used in a body statement?
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746102 is a reply to message #1746101] Fri, 21 October 2016 18:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11206
Registered: July 2009
Senior Member
body = '''<<Myclass>>'''

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746107 is a reply to message #1746102] Sat, 22 October 2016 01:19 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
Thanks
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746251 is a reply to message #1746102] Tue, 25 October 2016 23:31 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
Christian Dietrich wrote on Fri, 21 October 2016 14:34
body = '''<<Myclass>>'''


I tried the following:
members += element.toMethod("open", typeRef(void)) [
				visibility = JvmVisibility.PROTECTED
 				parameters += element.toParameter("indexPath", typeRef(String))
				body = '''
					<<java.nio.file.Paths>>
					<<org.apache.lucene.store.FSDirectory>>
					<<org.apache.lucene.index.DirectoryReader>>
			        path = Paths.get(indexPath);
			        directory = FSDirectory.open(path);
			        indexReader =  DirectoryReader.open(directory);
			        synchronized(this) {
			        	indexSearcher = null;
			        }
				'''
			]

and get this:
  protected void open(final String indexPath) {
    <<java.nio.file.Paths>>
    <<org.apache.lucene.store.FSDirectory>>
    <<org.apache.lucene.index.DirectoryReader>>
    			        path = Paths.get(indexPath);
    			        directory = FSDirectory.open(path);
    			        indexReader =  DirectoryReader.open(directory);
    			        synchronized(this) {
    			        	indexSearcher = null;
    			        }
  }


What I did wrong ?
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746254 is a reply to message #1746251] Wed, 26 October 2016 04:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11206
Registered: July 2009
Senior Member
Argggg I don have the French Guillemets « » guys on my phone keyboard
Thus I used <<>> in the posting


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746255 is a reply to message #1746254] Wed, 26 October 2016 04:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11206
Registered: July 2009
Senior Member
So please use

path = «Paths ».get(indexPath);


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746270 is a reply to message #1746255] Wed, 26 October 2016 09:54 Go to previous messageGo to next message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
Than I get the error "method or field Paths is undefined".
Still somthing missing ?
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746271 is a reply to message #1746270] Wed, 26 October 2016 09:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11206
Registered: July 2009
Senior Member
If the paths type imported in the generator ?

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746278 is a reply to message #1746271] Wed, 26 October 2016 11:41 Go to previous message
Olaf Bigalk is currently offline Olaf BigalkFriend
Messages: 141
Registered: July 2009
Location: Berlin
Senior Member
Thank you that works.
Previous Topic:Dealing with Eclipse XText syntax errors
Next Topic:Xtext Symbol
Goto Forum:
  


Current Time: Mon Sep 25 06:26:49 GMT 2017

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

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