Search in sources :

Example 6 with FieldDeclaration

use of org.whole.lang.java.model.FieldDeclaration in project whole by wholeplatform.

the class SelectQueriesTest method testSelectTupleOfTemplatesAs.

@Test
public void testSelectTupleOfTemplatesAs() {
    Model model = new XmlModel().create();
    ITemplateManager tm = SelectQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("selectTupleOfTemplatesAs");
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
        FieldDeclaration f = (FieldDeclaration) tuple.wGet(0);
        SingleVariableDeclaration p = (SingleVariableDeclaration) tuple.wGet(1);
        ExpressionStatement s = (ExpressionStatement) tuple.wGet(2);
        Feature e = (Feature) tuple.wGet(3);
        String ptype = e.getType().wStringValue();
        String pname = e.getName().wStringValue();
        assertSame(f, bm.wGet("field"));
        assertEquals(ptype, f.getType().wStringValue());
        assertSame(p, bm.wGet("param"));
        assertEquals(ptype, p.getType().wStringValue());
        assertEquals(pname, p.getName().wStringValue());
        assertSame(s, bm.wGet("init"));
        assertEquals(pname, ((Assignment) s.getExpression()).getRightHandSide().wStringValue());
    }
}
Also used : Assignment(org.whole.lang.java.model.Assignment) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) SingleVariableDeclaration(org.whole.lang.java.model.SingleVariableDeclaration) ExpressionStatement(org.whole.lang.java.model.ExpressionStatement) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) IBindingManager(org.whole.lang.bindings.IBindingManager) XmlModel(org.whole.lang.models.codebase.XmlModel) ITemplateManager(org.whole.lang.templates.ITemplateManager) Feature(org.whole.lang.models.model.Feature) FieldDeclaration(org.whole.lang.java.model.FieldDeclaration) Test(org.junit.Test)

Example 7 with FieldDeclaration

use of org.whole.lang.java.model.FieldDeclaration in project whole by wholeplatform.

the class SelectQueriesTest method testSelectTupleWithTemplates.

@Test
public void testSelectTupleWithTemplates() {
    ITemplateManager tm = SelectQueriesTemplateManager.instance();
    Grammar model = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    PathExpression query = (PathExpression) tm.create("selectTupleWithTemplates");
    for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
        FieldDeclaration fd = (FieldDeclaration) tuple.wGet(0);
        Feature f = (Feature) tuple.wGet(1);
        As e = (As) tuple.wGet(2);
        assertEquals(e.getName().getValue(), fd.getFragments().wGet(0).wGet(0).wStringValue());
        assertEquals(e.getRule().wStringValue(), fd.getType().wStringValue());
        assertEquals(e.getName().getValue(), f.getName().wStringValue());
        assertEquals(e.getRule().wStringValue(), f.getType().wStringValue());
    }
}
Also used : As(org.whole.lang.grammars.model.As) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Feature(org.whole.lang.models.model.Feature) FieldDeclaration(org.whole.lang.java.model.FieldDeclaration) Test(org.junit.Test)

Example 8 with FieldDeclaration

use of org.whole.lang.java.model.FieldDeclaration in project whole by wholeplatform.

the class FieldDeclarationPart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    List<IEntity> list = new ArrayList<IEntity>(4);
    FieldDeclaration fieldDeclaration = getModelEntity();
    list.add(fieldDeclaration.getJavadoc());
    list.add(fieldDeclaration.getModifiers());
    list.add(fieldDeclaration.getType());
    list.add(fieldDeclaration.getFragments());
    return list;
}
Also used : IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) FieldDeclaration(org.whole.lang.java.model.FieldDeclaration)

Aggregations

FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)8 Test (org.junit.Test)7 PathExpression (org.whole.lang.queries.model.PathExpression)7 ITemplateManager (org.whole.lang.templates.ITemplateManager)7 XmlModel (org.whole.lang.models.codebase.XmlModel)6 Model (org.whole.lang.models.model.Model)6 IEntity (org.whole.lang.model.IEntity)5 Feature (org.whole.lang.models.model.Feature)5 IBindingManager (org.whole.lang.bindings.IBindingManager)4 ArrayList (java.util.ArrayList)1 As (org.whole.lang.grammars.model.As)1 Grammar (org.whole.lang.grammars.model.Grammar)1 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)1 Assignment (org.whole.lang.java.model.Assignment)1 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)1 ExpressionStatement (org.whole.lang.java.model.ExpressionStatement)1 SingleVariableDeclaration (org.whole.lang.java.model.SingleVariableDeclaration)1 SimpleEntity (org.whole.lang.models.model.SimpleEntity)1