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);
}
}
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()]));
}
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.");
}
}
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);
}
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));
}
Aggregations