How I can get the contents of my DSL file [message #1053368] |
Sat, 04 May 2013 16:27 |
|
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 #1053382 is a reply to message #1053381] |
Sat, 04 May 2013 18:05 |
|
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;
}
|
|
|
Powered by
FUDForum. Page generated in 0.05494 seconds