Search in sources :

Example 1 with Model

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

the class ModelFragmentsBuilderTest method testModelFeaturesBuilderWithFeatureEvents.

@Test
public void testModelFeaturesBuilderWithFeatureEvents() {
    ITemplateFactory<Model> modelsModel = new ModelsModelWithFeatureEvents();
    Features features = ModelsEntityFactory.instance.createFeatures(0);
    modelsModel.apply(new SpecificBuilderAdapterOperation(new ModelFeaturesBuilder(features)));
    int count = 0;
    Model model = modelsModel.create();
    AbstractPatternFilterIterator<Feature> i = IteratorFactory.<Feature>descendantOrSelfMatcherIterator().withPattern(ModelsEntityDescriptorEnum.Feature);
    i.reset(model);
    for (Feature feature : i) if (EntityUtils.isNotResolver(feature))
        count++;
    assertEquals(features.wSize(), count);
}
Also used : ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) Features(org.whole.lang.models.model.Features) ModelFeaturesBuilder(org.whole.lang.builders.builder.ModelFeaturesBuilder) Feature(org.whole.lang.models.model.Feature) Test(org.junit.Test)

Example 2 with Model

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

the class ModelFragmentsBuilderTest method testModelFeaturesBuilder.

@Test
public void testModelFeaturesBuilder() {
    ITemplateFactory<Model> modelsModel = new ModelsModel();
    final Features features = ModelsEntityFactory.instance.createFeatures(0);
    modelsModel.apply(new SpecificBuilderAdapterOperation(new ModelFeaturesBuilder(features)));
    int count = 0;
    Model model = modelsModel.create();
    AbstractPatternFilterIterator<Feature> i = IteratorFactory.<Feature>descendantOrSelfMatcherIterator().withPattern(ModelsEntityDescriptorEnum.Feature);
    i.reset(model);
    for (Feature feature : i) if (EntityUtils.isNotResolver(feature))
        count++;
    assertEquals(features.wSize(), count);
}
Also used : ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) Features(org.whole.lang.models.model.Features) ModelsModel(org.whole.lang.models.codebase.ModelsModel) ModelFeaturesBuilder(org.whole.lang.builders.builder.ModelFeaturesBuilder) Feature(org.whole.lang.models.model.Feature) Test(org.junit.Test)

Example 3 with Model

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

the class GrammarsUtilsTest method testGrammarToModelMapping.

@Test
public void testGrammarToModelMapping() {
    Model m = new XmlModel().create();
    Grammar g = new XmlGrammar().create();
    Model m1 = GrammarsUtils.deriveModel(g, true);
    Assert.assertTrue(Matcher.match(m, m1));
}
Also used : Model(org.whole.lang.models.model.Model) Grammar(org.whole.lang.grammars.model.Grammar) XmlGrammar(org.whole.lang.grammars.codebase.XmlGrammar) XmlGrammar(org.whole.lang.grammars.codebase.XmlGrammar) Test(org.junit.Test)

Example 4 with Model

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

the class ModelsJavaModelGeneratorVisitor method visit.

public void visit(Model modelOrig) {
    Model model = EntityUtils.clone(modelOrig);
    modelInfo = new ModelInfo(model);
    modelInfo.addInheritedFeatures(model);
    modelInfo.addUndeclaredTypes(model);
    modelInfo.sortFeatures(model);
    beforeModel(model);
    modelsGen.visitorsBuilder();
    modelsGen.entityInterfaceBuilder();
    modelsGen.entityFactoryBuilder();
    if (hasUI)
        modelsGen.partFactoryVisitorBuilder();
    model.getDeclarations().accept(this);
    model.getTypeRelations().accept(this);
    // modelsGen.applyTypeDeclarations();
    afterModel();
}
Also used : ModelInfo(org.whole.lang.models.util.ModelInfo) Model(org.whole.lang.models.model.Model)

Example 5 with Model

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

the class GrammarsJavaModelGeneratorVisitor method visit.

@Override
public void visit(Grammar entity) {
    TargetLanguage targetLanguage = entity.getTargetLanguage();
    if (Matcher.match(GrammarsEntityDescriptorEnum.LanguageDescriptor, targetLanguage)) {
        Model targetModel = GrammarsUtils.deriveModel(entity, true);
        stagedVisit(targetModel);
    }
}
Also used : Model(org.whole.lang.models.model.Model) TargetLanguage(org.whole.lang.grammars.model.TargetLanguage)

Aggregations

Model (org.whole.lang.models.model.Model)62 Test (org.junit.Test)55 PathExpression (org.whole.lang.queries.model.PathExpression)43 ITemplateManager (org.whole.lang.templates.ITemplateManager)41 IEntity (org.whole.lang.model.IEntity)40 XmlModel (org.whole.lang.models.codebase.XmlModel)30 ModelsModel (org.whole.lang.models.codebase.ModelsModel)25 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)19 IBindingManager (org.whole.lang.bindings.IBindingManager)15 SimpleEntity (org.whole.lang.models.model.SimpleEntity)14 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)12 DataEntity (org.whole.lang.models.model.DataEntity)10 Feature (org.whole.lang.models.model.Feature)9 ArrayList (java.util.ArrayList)6 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)6 CompositeEntity (org.whole.lang.models.model.CompositeEntity)4 Features (org.whole.lang.models.model.Features)4 EditorsModel (org.whole.lang.models.codebase.EditorsModel)3 EnumEntity (org.whole.lang.models.model.EnumEntity)3 SimpleName (org.whole.lang.models.model.SimpleName)3