Search in sources :

Example 56 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class MatcherTest method testDataSubstitute.

@Test
public void testDataSubstitute() {
    SimpleEntity entityPattern = new SimpleEntityPattern().create();
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    bindings.wDefValue("entityName", "SE");
    Matcher.substitute(entityPattern, bindings, false);
    assertEquals("SE", entityPattern.getName().wStringValue());
    assertEquals(ModelsEntityDescriptorEnum.SimpleName, entityPattern.getName().wGetEntityDescriptor());
}
Also used : SimpleEntity(org.whole.lang.models.model.SimpleEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 57 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class MatcherTest method testMatchBindings.

@Test
public void testMatchBindings() {
    IEntity pattern = buildArtifactsPattern(true);
    IEntity model = buildArtifactsPattern(false);
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    if (Matcher.match(pattern, model, bindings)) {
        assertEquals("LGPL", bindings.wStringValue("licenseText"));
        return;
    }
    fail();
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 58 with IBindingManager

use of org.whole.lang.bindings.IBindingManager 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 59 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class IteratorFactoryTest method testVariableIterator.

@Test
public void testVariableIterator() {
    Grammar g = new TestXmlGrammar().create();
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    IEntityIterator<IEntity> i = IteratorFactory.variableIterator("testVar");
    i.setBindings(bindings);
    assertFalse(i.hasNext());
    i.reset(g);
    assertFalse(i.hasNext());
    bindings.wDef("testVar", g);
    assertTrue(i.hasNext());
    IEntity g1 = i.next();
    assertSame(g, g1);
    assertFalse(i.hasNext());
    i.reset(g);
    assertTrue(i.hasNext());
    g1 = i.next();
    assertSame(g, g1);
    assertFalse(i.hasNext());
    bindings = BindingManagerFactory.instance.createBindingManager();
    bindings.wDef("testVar", g);
    i = IteratorFactory.variableIterator("testVar");
    i.setBindings(bindings);
    assertTrue(i.hasNext());
    g1 = i.next();
    assertSame(g, g1);
    assertFalse(i.hasNext());
    i.reset(g);
    IEntityIterator<IEntity> i2 = i.clone();
    assertTrue(i.hasNext());
    g1 = i.next();
    assertSame(g, g1);
    assertFalse(i.hasNext());
    assertTrue(i2.hasNext());
    g1 = i2.next();
    assertSame(g, g1);
    assertFalse(i2.hasNext());
}
Also used : IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) IBindingManager(org.whole.lang.bindings.IBindingManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Test(org.junit.Test)

Example 60 with IBindingManager

use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.

the class ResourceArtifactsGeneratorTest method test1GenerateWorkspace.

@Test
public void test1GenerateWorkspace() {
    assertTrue(workspaceFolder.exists());
    IBindingManager bindings = BindingManagerFactory.instance.createArguments();
    bindings.wDefValue("folderLocation", workspaceFolder.getAbsolutePath());
    ArtifactsGeneratorOperation.generate(artifacts, bindings);
    File genFolder = new File("data/gen");
    assertTrue(genFolder.exists());
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) File(java.io.File) Test(org.junit.Test)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)223 IEntity (org.whole.lang.model.IEntity)141 Test (org.junit.Test)91 PathExpression (org.whole.lang.queries.model.PathExpression)49 ITemplateManager (org.whole.lang.templates.ITemplateManager)40 Grammar (org.whole.lang.grammars.model.Grammar)28 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)27 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)17 Model (org.whole.lang.models.model.Model)15 Production (org.whole.lang.grammars.model.Production)14 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)14 File (java.io.File)12 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)12 XmlModel (org.whole.lang.models.codebase.XmlModel)11 SimpleEntity (org.whole.lang.models.model.SimpleEntity)10 VisitException (org.whole.lang.visitors.VisitException)9 IBindingScope (org.whole.lang.bindings.IBindingScope)6 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)6 HashMap (java.util.HashMap)5 IFile (org.eclipse.core.resources.IFile)5