Search in sources :

Example 1 with GExpressionsStandaloneSetup

use of org.eclipse.gemoc.gexpressions.xtext.GExpressionsStandaloneSetup in project gemoc-studio by eclipse.

the class TestXtextSerializer2 method loadGexpressionTestFile.

public static void loadGexpressionTestFile() {
    // Getting the serializer
    GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
    Injector injector = setup.createInjectorAndDoEMFRegistration();
    GexpressionsPackage.eINSTANCE.eClass();
    Serializer serializer = injector.getInstance(Serializer.class);
    // Load the model
    URI modelURI = URI.createFileURI("/home/flatombe/thesis/gemoc/git/gemoc-dev/org/eclipse/gemoc/GEL/org.eclipse.gemoc.gel.gexpressions.test/model/test.gexpressions");
    XtextResourceSet resSet = injector.getInstance(XtextResourceSet.class);
    resSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
    Resource resource = resSet.getResource(modelURI, true);
    GProgram program = (GProgram) resource.getContents().get(0);
    List<GExpression> exps = program.getExpressions();
    for (GExpression exp : exps) {
        // Serializing
        String s = serializer.serialize(exp);
        System.out.println(s);
    }
}
Also used : GExpression(org.eclipse.gemoc.gexpressions.GExpression) Injector(com.google.inject.Injector) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) GProgram(org.eclipse.gemoc.gexpressions.GProgram) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI) GExpressionsStandaloneSetup(org.eclipse.gemoc.gexpressions.xtext.GExpressionsStandaloneSetup) Serializer(org.eclipse.xtext.serializer.impl.Serializer)

Example 2 with GExpressionsStandaloneSetup

use of org.eclipse.gemoc.gexpressions.xtext.GExpressionsStandaloneSetup in project gemoc-studio by eclipse.

the class TestXtextSerializer method main.

public static void main(String[] args) {
    // Getting the serializer
    GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
    Injector injector = setup.createInjectorAndDoEMFRegistration();
    Serializer serializer = injector.getInstance(Serializer.class);
    // Creating a model
    GexpressionsFactory factory = GexpressionsFactory.eINSTANCE;
    GAdditionExpression exp = factory.createGAdditionExpression();
    GIntegerExpression un = factory.createGIntegerExpression();
    un.setValue(1);
    GStringExpression deux = factory.createGStringExpression();
    deux.setValue("deux");
    exp.setLeftOperand(un);
    exp.setRightOperand(deux);
    // Serializing
    String s = serializer.serialize(exp);
    System.out.println(s);
}
Also used : GexpressionsFactory(org.eclipse.gemoc.gexpressions.GexpressionsFactory) Injector(com.google.inject.Injector) GStringExpression(org.eclipse.gemoc.gexpressions.GStringExpression) GIntegerExpression(org.eclipse.gemoc.gexpressions.GIntegerExpression) GAdditionExpression(org.eclipse.gemoc.gexpressions.GAdditionExpression) GExpressionsStandaloneSetup(org.eclipse.gemoc.gexpressions.xtext.GExpressionsStandaloneSetup) Serializer(org.eclipse.xtext.serializer.impl.Serializer)

Aggregations

Injector (com.google.inject.Injector)2 GExpressionsStandaloneSetup (org.eclipse.gemoc.gexpressions.xtext.GExpressionsStandaloneSetup)2 Serializer (org.eclipse.xtext.serializer.impl.Serializer)2 URI (org.eclipse.emf.common.util.URI)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 GAdditionExpression (org.eclipse.gemoc.gexpressions.GAdditionExpression)1 GExpression (org.eclipse.gemoc.gexpressions.GExpression)1 GIntegerExpression (org.eclipse.gemoc.gexpressions.GIntegerExpression)1 GProgram (org.eclipse.gemoc.gexpressions.GProgram)1 GStringExpression (org.eclipse.gemoc.gexpressions.GStringExpression)1 GexpressionsFactory (org.eclipse.gemoc.gexpressions.GexpressionsFactory)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1