|
Re: TortoiseShell - is there simple way to run the interpreter to run a program ? [message #1807244 is a reply to message #1807243] |
Sat, 25 May 2019 17:24 |
|
The usual way to load a model I showed here
https://www.eclipse.org/forums/index.php/t/1098976/
With no specifics about the npe?
i cannot help!
Maybe there are injects in the interpreter and you should create it with the injector
you also may have a look at the prjects unit tests
/*******************************************************************************
* Copyright (c) 2019 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.xtext.tortoiseshell;
import java.io.IOException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.util.StringInputStream;
import org.xtext.tortoiseshell.interpreter.TortoiseShellInterpeter;
import org.xtext.tortoiseshell.lib.Tortoise;
import com.google.inject.Injector;
/**
* @author dietrich - Initial contribution and API
*/
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new TortoiseShellStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("file:/home/dietrich/Downloads/2019-03-RC1/wswm22/org.xtext.tortoiseshell.examples/src/org/xtext/tortoiseshell/example/Pentgram.tortoiseshell"), true);
r.load(null);
TortoiseShellInterpeter interpreter = i.getInstance(TortoiseShellInterpeter.class);
Tortoise tortoise = new Tortoise();
tortoise.addListener((e)->{
System.out.println(e);
});
EcoreUtil.resolveAll(r);
EObject program = r.getContents().get(0);
System.out.println(program);
interpreter.run(tortoise, program, -100);
System.out.println("done");
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Sat, 25 May 2019 18:44] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04058 seconds