Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How I can get the contents of my DSL file(In runtime)
How I can get the contents of my DSL file [message #1053368] Sat, 04 May 2013 16:27 Go to next message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

I have my grammar for xbase...and my interpreter that evaluate var declaration.. when my user click on context menu option interpreter.. I tell the interpreter and give
String model = "var x = account(xxx)\n var y = account(xxxxxx)\n var z = 0\n z = x + y";
.. but.. how I can give to my interpreter the contents of the Editor which gave click?????..is my interpreter good implementation???... look at jEEjecutableExtension file in org.example.go.ui... thanks you by read this
Re: How I can get the contents of my DSL file [message #1053370 is a reply to message #1053368] Sat, 04 May 2013 16:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i am not sure if i get your problem.

http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How I can get the contents of my DSL file [message #1053371 is a reply to message #1053370] Sat, 04 May 2013 16:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
You may have a look at https://github.com/cdietrich/mql/blob/master/org.eclipse.xtext.mql.ui/src/org/eclipse/xtext/mqrepl/ui/handler/ModelQueryInterpreterHandler.java
too


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How I can get the contents of my DSL file [message #1053373 is a reply to message #1053370] Sat, 04 May 2013 16:44 Go to previous messageGo to next message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

yes, I use http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/...sorry for mi english..thanks
Re: How I can get the contents of my DSL file [message #1053375 is a reply to message #1053373] Sat, 04 May 2013 16:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
And what is your problem?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How I can get the contents of my DSL file [message #1053376 is a reply to message #1053375] Sat, 04 May 2013 16:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
And please make sure you use YoutdslExecutableExtensionFactory in your plugin.xml for the handler class.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How I can get the contents of my DSL file [message #1053377 is a reply to message #1053376] Sat, 04 May 2013 17:16 Go to previous messageGo to next message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

Thanks Christian.. is very good https://github.com/cdietrich/mql/blob/master/org.eclipse.xtext.mql.ui/src/org/eclipse/xtext/mqrepl/ui/handler/ModelQueryInterpreterHandler.java but .. how can get
ModelQueryLanguageView
..??? and where YoutdslExecutableExtensionFactory, in plugin.xml the org.example.go or org.example.go.ui???
Re: How I can get the contents of my DSL file [message #1053378 is a reply to message #1053377] Sat, 04 May 2013 17:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi the ui. As i do it in my blog

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How I can get the contents of my DSL file [message #1053379 is a reply to message #1053378] Sat, 04 May 2013 17:26 Go to previous messageGo to next message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

I go now for you Blog.. can you tell me the exact url???...I'll put your name in the acknowledgments of my thesis ... I can??
Re: How I can get the contents of my DSL file [message #1053381 is a reply to message #1053379] Sat, 04 May 2013 17:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
See 5. posts above

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How I can get the contents of my DSL file [message #1053382 is a reply to message #1053381] Sat, 04 May 2013 18:05 Go to previous message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

Fine.. works...thanks very....my jEEjecutableExtension.java final look ...
public Object execute(ExecutionEvent event) throws ExecutionException {
		// TODO Auto-generated method stub
	
		// Obteniendo el contenido del archivo
		IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
        final XtextEditor editor = (XtextEditor) activeEditor;
        XtextDocument doc = (XtextDocument) editor.getDocument();
        
        String r = doc.get();
		
        // Inject
        GOActivator.getInstance().getInjector("org.example.go.GO").injectMembers(this);
		Model m = null;
		try {
			m = parseHelper.parse(r);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("New run...");
		for  (XExpression decl : m.getExpressions()) {
			System.out.println(myInterpreter.evaluate(decl).getResult().toString());
		}
				
		
		return null;
	}
Previous Topic:Error with ParseHelper in Test xbase compiler
Next Topic:JavaIoFileSystemAccess - null pointer
Goto Forum:
  


Current Time: Thu Mar 28 09:30:23 GMT 2024

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

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

Back to the top