Search in sources :

Example 1 with ModelDeclaration

use of org.whole.lang.models.model.ModelDeclaration in project whole by wholeplatform.

the class ModelsValidatorVisitor method visit.

@Override
public void visit(ModelDeclarations entity) {
    for (int i = 0; i < entity.wSize(); i++) {
        ModelDeclaration decl = (ModelDeclaration) entity.wGet(i);
        currentEntity = decl;
        decl.accept(this);
    }
}
Also used : ModelDeclaration(org.whole.lang.models.model.ModelDeclaration)

Example 2 with ModelDeclaration

use of org.whole.lang.models.model.ModelDeclaration in project whole by wholeplatform.

the class ResolversTest method testSimpleEntityResolverTighteningByIndex.

@Test
public void testSimpleEntityResolverTighteningByIndex() {
    ModelDeclaration modelDeclaration = createResolver(ModelsEntityDescriptorEnum.ModelDeclaration);
    ModelDeclarations modelDeclarations = mf.createModelDeclarations(modelDeclaration);
    int index = ModelsEntityDescriptorEnum.ModelDeclaration.indexOf(ModelsFeatureDescriptorEnum.name);
    try {
        modelDeclaration.wSet(index, mf.createSimpleName("testName"));
        Assert.fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) ModelDeclaration(org.whole.lang.models.model.ModelDeclaration) Test(org.junit.Test)

Example 3 with ModelDeclaration

use of org.whole.lang.models.model.ModelDeclaration in project whole by wholeplatform.

the class ResolversTest method testSimpleEntityResolverTighteningByFD.

@Test
public void testSimpleEntityResolverTighteningByFD() {
    ModelDeclaration modelDeclaration = createResolver(ModelsEntityDescriptorEnum.ModelDeclaration);
    ModelDeclarations modelDeclarations = mf.createModelDeclarations(modelDeclaration);
    modelDeclaration.wSet(ModelsFeatureDescriptorEnum.name, mf.createSimpleName("testName"));
    Assert.assertTrue(EntityUtils.isResolver(modelDeclaration));
    modelDeclaration.wSet(ModelsFeatureDescriptorEnum.componentType, mf.createSimpleName("testTypeName"));
    Assert.assertTrue(Matcher.matchImpl(ModelsEntityDescriptorEnum.CompositeEntity, modelDeclarations.wGet(0)));
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) ModelDeclaration(org.whole.lang.models.model.ModelDeclaration) Test(org.junit.Test)

Example 4 with ModelDeclaration

use of org.whole.lang.models.model.ModelDeclaration in project whole by wholeplatform.

the class Grammars2ModelsVisitor method visit.

@Override
public void visit(Productions entity) {
    ModelsEntityFactory mf = ModelsEntityFactory.instance;
    ScannerIterator<Production> i = IteratorFactory.<Production>childScannerIterator();
    i.reset(entity);
    for (Production p : i) {
        String eName = getMappedEntityName(p);
        ModelDeclaration mDecl = CommonsEntityAdapterFactory.createResolver(ModelsEntityDescriptorEnum.ModelDeclaration);
        productionMap.put(p.getName().getValue(), p);
        declarationMap.put(eName, mDecl);
        modelDeclarations.wAdd(mDecl);
        mDecl.setModifiers(mf.createEntityModifiers());
        mDecl.setName(mf.createSimpleName(eName));
        mDecl.setTypes(mf.createTypes());
    }
    super.visit(entity);
}
Also used : Production(org.whole.lang.grammars.model.Production) ModelsEntityFactory(org.whole.lang.models.factories.ModelsEntityFactory) ModelDeclaration(org.whole.lang.models.model.ModelDeclaration)

Example 5 with ModelDeclaration

use of org.whole.lang.models.model.ModelDeclaration in project whole by wholeplatform.

the class Grammars2ModelsVisitor method getModelDeclaration.

protected <T extends ModelDeclaration> T getModelDeclaration(String name, EntityDescriptor<T> ed) {
    ModelDeclaration e = declarationMap.get(name);
    T result = e.wResolveWith(ed);
    if (result != e)
        declarationMap.put(name, result);
    return result;
}
Also used : ModelDeclaration(org.whole.lang.models.model.ModelDeclaration)

Aggregations

ModelDeclaration (org.whole.lang.models.model.ModelDeclaration)6 Test (org.junit.Test)2 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)2 Production (org.whole.lang.grammars.model.Production)1 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)1