Search in sources :

Example 31 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class SchemaUtils method deploy.

// public static void deploy(String namespaceURI, String schemaLocationURI, String folderLocation) {
// deploy(namespaceURI, schemaLocationURI, folderLocation, null);
// }
public static void deploy(String namespaceURI, String schemaLocationURI, String folderLocation, /* was LSResourceResolver, workaround for Android compatibility */
ResourceResolver lsResourceResolver) {
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    bindings.wDefValue("folderLocation", folderLocation);
    bindings.wDefValue("lsResourceResolver", lsResourceResolver);
    deploy(namespaceURI, schemaLocationURI, bindings);
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 32 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class TextInterpreterVisitor method visit.

@Override
public void visit(ITextEntity entity) {
    IVisitor ov = op().setVisitor(entity, 0, op().getVisitor(entity, 1));
    op().stagedVisit(entity);
    op().setVisitor(entity, 0, ov);
    IBindingManager bm = getBindings();
    bm.setResult(TextEntityFactory.instance.createText(toPrettyPrintString(bm.getResult())));
}
Also used : IVisitor(org.whole.lang.visitors.IVisitor) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 33 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class BindVariablesInPathTest method testBindVariablesInPathOK2.

@Test
public void testBindVariablesInPathOK2() throws Exception {
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    IEntity compilationUnits = BindVariablesInPathTemplateManager.instance().create("compilationUnit");
    PathExpression findClassDeclarationsOK2 = (PathExpression) BindVariablesInPathTemplateManager.instance().create("findClassDeclarationsOK2");
    IEntityIterator<IEntity> iterator;
    iterator = BehaviorUtils.<IEntity>compileAndLazyEvaluate(findClassDeclarationsOK2, compilationUnits, bindings);
    while (iterator.hasNext()) {
        assertNotNull(iterator.next());
        assertTrue(bindings.wIsSet("methodDeclaration"));
    }
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 34 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class BindVariablesInPathTest method testBindVariablesInPathOK1.

@Test
public void testBindVariablesInPathOK1() throws Exception {
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    IEntity compilationUnits = BindVariablesInPathTemplateManager.instance().create("compilationUnit");
    PathExpression findClassDeclarationsOK1 = (PathExpression) BindVariablesInPathTemplateManager.instance().create("findClassDeclarationsOK1");
    IEntityIterator<IEntity> iterator;
    iterator = BehaviorUtils.<IEntity>compileAndLazyEvaluate(findClassDeclarationsOK1, compilationUnits, bindings);
    while (iterator.hasNext()) {
        assertNotNull(iterator.next());
        assertTrue(bindings.wIsSet("methodDeclaration"));
    }
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 35 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class ControlQueriesTest method testIf4.

@Test
public void testIf4() {
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("if4");
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    IEntity queryExp1 = qef.createDivision(qef.createIntLiteral(10), qef.createIntLiteral(8));
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, queryExp1, bm);
    assertTrue(iterator.hasNext());
    IEntity exp1 = iterator.next();
    assertSame(queryExp1.wGet(0), exp1);
    assertTrue(bm.wIsSet("a"));
    assertFalse(bm.wIsSet("b"));
    assertFalse(bm.wIsSet("exp1"));
    assertFalse(bm.wIsSet("exp2"));
    assertTrue(iterator.hasNext());
    IEntity exp2 = iterator.next();
    assertSame(queryExp1.wGet(1), exp2);
    assertFalse(bm.wIsSet("a"));
    assertTrue(bm.wIsSet("b"));
    assertFalse(bm.wIsSet("exp1"));
    assertFalse(bm.wIsSet("exp2"));
    assertFalse(iterator.hasNext());
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) Test(org.junit.Test)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)223 IEntity (org.whole.lang.model.IEntity)141 Test (org.junit.Test)91 PathExpression (org.whole.lang.queries.model.PathExpression)49 ITemplateManager (org.whole.lang.templates.ITemplateManager)40 Grammar (org.whole.lang.grammars.model.Grammar)28 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)27 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)17 Model (org.whole.lang.models.model.Model)15 Production (org.whole.lang.grammars.model.Production)14 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)14 File (java.io.File)12 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)12 XmlModel (org.whole.lang.models.codebase.XmlModel)11 SimpleEntity (org.whole.lang.models.model.SimpleEntity)10 VisitException (org.whole.lang.visitors.VisitException)9 IBindingScope (org.whole.lang.bindings.IBindingScope)6 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)6 HashMap (java.util.HashMap)5 IFile (org.eclipse.core.resources.IFile)5