Skip to main content


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: 155
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: 14665
Registered: July 2009
Senior Member
body = '''<<Myclass>>'''

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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: 155
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: 155
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: 14665
Registered: July 2009
Senior Member
Argggg I don have the French Guillemets « » guys on my phone keyboard
Thus I used <<>> in the posting


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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: 14665
Registered: July 2009
Senior Member
So please use

path = «Paths ».get(indexPath);


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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: 155
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: 14665
Registered: July 2009
Senior Member
If the paths type imported in the generator ?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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: 155
Registered: July 2009
Location: Berlin
Senior Member
Thank you that works.
Previous Topic:How can I get theGenModelURI for a grammar in the same eclipse instance
Next Topic:[SOLVED] Xtext editor crashes when deployed as part of product
Goto Forum:
  


Current Time: Fri Apr 19 05:15:35 GMT 2024

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

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

Back to the top