Search in sources :

Example 1 with SimpleName

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

the class ModelsJavaModelGeneratorVisitor method visit.

public void visit(Types types) {
    AbstractPatternFilterIterator<SimpleName> i = IteratorFactory.<SimpleName>childMatcherIterator().withPattern(ModelsEntityDescriptorEnum.SimpleName);
    i.reset(types);
    for (SimpleName name : i) {
        String typeName = name.wStringValue();
        anyEntityBuilder.addTypeDeclaration(typeName);
        modelsGen.visitorsBuilder().addType(entityName, typeName);
    }
}
Also used : SimpleName(org.whole.lang.models.model.SimpleName)

Example 2 with SimpleName

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

the class ModelsJavaModelGeneratorVisitor method visit.

public void visit(SupertypesOf entity) {
    List<String> types = new ArrayList<String>();
    AbstractPatternFilterIterator<SimpleName> i = IteratorFactory.<SimpleName>childMatcherIterator().withPattern(ModelsEntityDescriptorEnum.SimpleName);
    i.reset(entity.getTypes());
    for (SimpleName name : i) types.add(name.wStringValue());
    ForeignType foreignType = entity.getForeignType();
    if (Matcher.matchImpl(ModelsEntityDescriptorEnum.AnyType, foreignType))
        modelsGen.entityDescriptorEnumBuilder().addSetAssignableFromAll(types.toArray(new String[types.size()]));
    else
        modelsGen.entityDescriptorEnumBuilder().addSetAssignableFromForeignType(foreignType.wStringValue(), types.toArray(new String[types.size()]));
}
Also used : ForeignType(org.whole.lang.models.model.ForeignType) SimpleName(org.whole.lang.models.model.SimpleName) ArrayList(java.util.ArrayList)

Example 3 with SimpleName

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

the class ModelsValidatorVisitor method visit.

@Override
public void visit(Types entity) {
    AbstractPatternFilterIterator<SimpleName> i = IteratorFactory.<SimpleName>childMatcherIterator().withPattern(ModelsEntityDescriptorEnum.SimpleName);
    i.reset(entity);
    for (SimpleName t : i) {
        String typeName = t.getValue();
        if (modelInfo.undefinedTypes.contains(typeName))
            getDecorationManager().addWarning(t, "Reference to the undeclared type: " + typeName, location(entity));
        if (!modelInfo.simpleEntityTypes.contains(typeName) && !modelInfo.markerTypes.contains(typeName) && !modelInfo.undefinedTypes.contains(typeName))
            getDecorationManager().addError(t, "Only Simple entities can be extended", location(entity));
        // TODO in entity visit
        if (currentEntity != null && !currentEntity.wGetEntityDescriptor().equals(ModelsEntityDescriptorEnum.SimpleEntity)) {
            for (String name : modelInfo.allSuperTypes(typeName)) if (!modelInfo.markerTypes.contains(name) && !modelInfo.undefinedTypes.contains(name))
                getDecorationManager().addError(t, "The supertypes of a " + currentEntity.wGetEntityDescriptor().getName() + " must be marker types (SimpleEntities without features)", location(entity));
        }
        isSimpleNameEmpty(t, "Reference type name is empty.");
    }
}
Also used : SimpleName(org.whole.lang.models.model.SimpleName)

Example 4 with SimpleName

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

the class MatcherTest method testMultipleSubstitute.

@Test
public void testMultipleSubstitute() {
    Model modelPattern = new ModelPattern().create();
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    bindings.wDefValue("dataEntity", "DE");
    IBindingScope args = BindingManagerFactory.instance.createSimpleScope();
    args.wDefValue("dataEntity", "DE");
    Matcher.substitute(modelPattern, args, false);
    SimpleName var1 = (SimpleName) modelPattern.getDeclarations().wGet(0).wGet(ModelsFeatureDescriptorEnum.features).wGet(0).wGet(ModelsFeatureDescriptorEnum.type);
    SimpleName var2 = (SimpleName) modelPattern.getDeclarations().wGet(1).wGet(ModelsFeatureDescriptorEnum.name);
    assertEquals("DE", var1.wStringValue());
    assertEquals("DE", var2.wStringValue());
    assertNotSame(var1, var2);
}
Also used : IBindingScope(org.whole.lang.bindings.IBindingScope) SimpleName(org.whole.lang.models.model.SimpleName) TestingModel(org.whole.lang.testentities.codebase.TestingModel) Model(org.whole.lang.models.model.Model) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 5 with SimpleName

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

the class Grammars2ModelsVisitor method ensureType.

protected void ensureType(Types types, String typeName) {
    AbstractPatternFilterIterator<SimpleName> i = IteratorFactory.<SimpleName>childMatcherIterator().withPattern(ModelsEntityDescriptorEnum.SimpleName);
    i.reset(types);
    for (SimpleName type : i) if (typeName.equals(type.getValue()))
        return;
    types.wAdd(ModelsEntityFactory.instance.createSimpleName(typeName));
}
Also used : SimpleName(org.whole.lang.models.model.SimpleName)

Aggregations

SimpleName (org.whole.lang.models.model.SimpleName)11 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 ForeignType (org.whole.lang.models.model.ForeignType)2 Model (org.whole.lang.models.model.Model)2 IBindingManager (org.whole.lang.bindings.IBindingManager)1 IBindingScope (org.whole.lang.bindings.IBindingScope)1 IEntity (org.whole.lang.model.IEntity)1 XmlModel (org.whole.lang.models.codebase.XmlModel)1 FeatureModifiers (org.whole.lang.models.model.FeatureModifiers)1 SimpleEntity (org.whole.lang.models.model.SimpleEntity)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 TestingModel (org.whole.lang.testentities.codebase.TestingModel)1