Skip to main content



      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 14:32 Go to next message
Eclipse UserFriend
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 14:34 Go to previous messageGo to next message
Eclipse UserFriend
body = '''<<Myclass>>'''
Re: How can I force JvmInferrer to import a class I used in a body statement [message #1746107 is a reply to message #1746102] Fri, 21 October 2016 21:19 Go to previous messageGo to next message
Eclipse UserFriend
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 19:31 Go to previous messageGo to next message
Eclipse UserFriend
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 00:08 Go to previous messageGo to next message
Eclipse UserFriend
Argggg I don have the French Guillemets « » guys on my phone keyboard
Thus I used <<>> in the posting
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 00:10 Go to previous messageGo to next message
Eclipse UserFriend
So please use

path = «Paths ».get(indexPath);
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 05:54 Go to previous messageGo to next message
Eclipse UserFriend
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 05:57 Go to previous messageGo to next message
Eclipse UserFriend
If the paths type imported in the generator ?
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 07:41 Go to previous message
Eclipse UserFriend
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: Sat May 31 19:44:28 EDT 2025

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

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

Back to the top