Search in sources :

Example 16 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testPathWithKindAndLogicFiltersIterator.

@Test
public void testPathWithKindAndLogicFiltersIterator() {
    ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate((PathExpression) tm.create("path2"), new TestXmlGrammar().create())) Assert.assertTrue(p.wGetEntityKind().equals(EntityKinds.SIMPLE) || p.wGetEntityKind().equals(EntityKinds.DATA));
    for (IEntity p : BehaviorUtils.compileAndLazyEvaluate((PathExpression) tm.create("path3"), new TestXmlGrammar().create())) Assert.assertFalse(p.wGetEntityKind().equals(EntityKinds.COMPOSITE));
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) ITemplateManager(org.whole.lang.templates.ITemplateManager) Test(org.junit.Test)

Example 17 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testChildStepByIndex.

@Test
public void testChildStepByIndex() {
    Model model = new XmlModel().create();
    ModelDeclarations decls = model.getDeclarations();
    IEntity decl3 = decls.wGet(3);
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    IEntity result = BehaviorUtils.evaluateFirstResult(ef.createFilter(ef.createChildStep(), ef.createIndexTest(ef.createIntLiteral(3))), decls);
    Assert.assertSame(decl3, result);
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Example 18 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class ControlQueriesTest method testQueryDecl7.

@Test
public void testQueryDecl7() {
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    JavaEntityFactory jef = JavaEntityFactory.instance;
    IEntity queryExp1 = qef.createDivision(qef.createMultiplication(qef.createIntLiteral(10), qef.createIntLiteral(8)), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
    IEntity queryExp2 = qef.createDivision(qef.createIntLiteral(10), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
    IEntity javaExp1 = jef.createInfixExpression(jef.createInfixExpression(jef.createIntLiteral(10), jef.createInfixOperator(InfixOperatorEnum.times), jef.createIntLiteral(8), jef.createExpressions(0)), jef.createInfixOperator(InfixOperatorEnum.divide), jef.createInfixExpression(jef.createIntLiteral(2), jef.createInfixOperator(InfixOperatorEnum.plus), jef.createIntLiteral(1), jef.createExpressions(0)), jef.createExpressions(0));
    IEntity javaExp2 = EntityUtils.clone(javaExp1);
    javaExp2.wSet(JavaFeatureDescriptorEnum.leftOperand, jef.createIntLiteral(10));
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("queryDecl7");
    assertTrue(Matcher.match(javaExp2, BehaviorUtils.evaluateFirstResult(query, queryExp2)));
    assertTrue(Matcher.match(javaExp1, BehaviorUtils.evaluateFirstResult(query, queryExp1)));
}
Also used : JavaEntityFactory(org.whole.lang.java.factories.JavaEntityFactory) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ITemplateManager(org.whole.lang.templates.ITemplateManager) Test(org.junit.Test)

Example 19 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class ControlQueriesTest method testIf5.

@Test
public void testIf5() {
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("if5");
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    IEntity queryExp1 = qef.createDivision(qef.createIntLiteral(10), qef.createIntLiteral(8));
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    IEntity queryRes1 = BehaviorUtils.evaluateFirstResult(query, queryExp1, bm);
    assertNotSame(queryExp1.wGet(0), queryRes1.wGet(0));
    assertTrue(Matcher.match(queryExp1.wGet(0), queryRes1.wGet(0)));
    assertNotSame(queryExp1.wGet(1), queryRes1.wGet(1));
    assertTrue(Matcher.match(queryExp1.wGet(1), queryRes1.wGet(1)));
    assertTrue(bm.wIsSet("a"));
    assertTrue(bm.wIsSet("b"));
    assertFalse(bm.wIsSet("exp1"));
    assertFalse(bm.wIsSet("exp2"));
}
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)

Example 20 with QueriesEntityFactory

use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testLanguageTest.

@Test
public void testLanguageTest() throws Exception {
    IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/templates/codebase/TemplateManagerArtifactsTemplates.xwl"));
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    for (IEntity e : BehaviorUtils.compileAndLazyEvaluate(ef.createFilter(ef.createDescendantOrSelfStep(), ef.createLanguageTest("http://lang.whole.org/Java")), model)) Assert.assertEquals("http://lang.whole.org/Java", e.wGetLanguageKit().getURI());
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ClasspathPersistenceProvider(org.whole.lang.codebase.ClasspathPersistenceProvider) Test(org.junit.Test)

Aggregations

QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)21 IEntity (org.whole.lang.model.IEntity)17 Test (org.junit.Test)11 PathExpression (org.whole.lang.queries.model.PathExpression)6 ITemplateManager (org.whole.lang.templates.ITemplateManager)6 Actions (org.whole.lang.actions.model.Actions)4 GroupAction (org.whole.lang.actions.model.GroupAction)4 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)4 ILanguageKit (org.whole.lang.reflect.ILanguageKit)4 XmlModel (org.whole.lang.models.codebase.XmlModel)3 Model (org.whole.lang.models.model.Model)3 ArrayList (java.util.ArrayList)2 IBindingManager (org.whole.lang.bindings.IBindingManager)2 ClasspathPersistenceProvider (org.whole.lang.codebase.ClasspathPersistenceProvider)2 Path (org.whole.lang.queries.model.Path)2 HashSet (java.util.HashSet)1 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 ActionsEntityFactory (org.whole.lang.actions.factories.ActionsEntityFactory)1 ActionCall (org.whole.lang.actions.model.ActionCall)1 ActionFactory (org.whole.lang.e4.ui.actions.ActionFactory)1