Search in sources :

Example 6 with IBindingScope

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

the class ArtifactsGeneratorTest method testGenerateArtifacts.

@Test
public void testGenerateArtifacts() {
    IBindingManager env = BindingManagerFactory.instance.createArguments();
    IEntity artifact = getMetadataPattern();
    IBindingScope args = BindingManagerFactory.instance.createSimpleScope();
    args.wDefValue("packageName", "artifact.test");
    Matcher.substitute(artifact, args, false);
    args.wClear();
    args.wDefValue("templateManagerName", "MyTM");
    Matcher.substitute(artifact, args, false);
    ArtifactsGeneratorOperation.generate(artifact, env);
// String pn = env.wStringValue("packageName");
// String fn = env.wStringValue("fileName");
// String l = env.wStringValue("location");
// String n = env.wStringValue("name");
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingScope(org.whole.lang.bindings.IBindingScope) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 7 with IBindingScope

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

the class IteratorFactory method oneIterator.

public static IEntityIterator<IEntity> oneIterator(IEntityIterator<IEntity> fromClause, IEntityIterator<IEntity> satisfiesClause) {
    return new AbstractSingleValuedRunnableIterator<IEntity>(fromClause, satisfiesClause) {

        protected void run(IEntity selfEntity, IBindingManager bm) {
            IBindingScope laScope = null;
            for (IEntity e : argsIterators[0]) {
                if (!argsIterators[1].evaluate(e, bm).wBooleanValue())
                    continue;
                if (laScope != null) {
                    bm.setResult(BindingManagerFactory.instance.createValue(false));
                    return;
                } else {
                    laScope = BindingManagerFactory.instance.createSimpleScope();
                    laScope.wAddAll(argsIterators[0].lookaheadScope());
                    laScope.wAddAll(argsIterators[1].lookaheadScope());
                }
            }
            if (laScope == null) {
                bm.setResult(BindingManagerFactory.instance.createValue(false));
                return;
            }
            bm.wAddAll(laScope);
            bm.setResult(BindingManagerFactory.instance.createValue(true));
        }

        public void toString(StringBuilder sb) {
            sb.append("one(");
            // TODO startOf
            argsIterators[0].toString(sb);
            sb.append(" satisfies ");
            // TODO startOf
            argsIterators[1].toString(sb);
            sb.append(")");
        }
    };
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingScope(org.whole.lang.bindings.IBindingScope) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 8 with IBindingScope

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

the class ReusablesArtifactsGeneratorVisitor method visit.

public void visit(IReusablesEntity entity) {
    IReusablesEntity entityClone = EntityUtils.clone(entity);
    IBindingScope resultsScope = InterpreterOperation.interpret(entityClone);
    for (IEntity result : resultsScope.getResultIterator()) {
        IEntity adaptee = result.wGetAdaptee(false);
        stagedVisit(adaptee);
    }
}
Also used : IBindingScope(org.whole.lang.bindings.IBindingScope) IEntity(org.whole.lang.model.IEntity) IReusablesEntity(org.whole.lang.reusables.model.IReusablesEntity)

Example 9 with IBindingScope

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

the class LaunchConfigurationUtils method loadBindingScope.

@SuppressWarnings("unchecked")
public static IBindingScope loadBindingScope(ILaunchConfiguration configuration) throws CoreException {
    Map<String, String> environmentMap = configuration.getAttribute(ENVIRONMENT, (Map<String, String>) null);
    IBindingScope scope = BindingManagerFactory.instance.createSimpleScope();
    if (environmentMap == null)
        return scope;
    for (String name : environmentMap.keySet()) try {
        IEntity entity = XmlBuilderPersistenceKit.instance().readModel(new StringPersistenceProvider(environmentMap.get(name)));
        scope.wDef(name, entity);
    } catch (Exception e) {
        WholePlugin.log(e);
    }
    return scope;
}
Also used : StringPersistenceProvider(org.whole.lang.codebase.StringPersistenceProvider) IBindingScope(org.whole.lang.bindings.IBindingScope) IEntity(org.whole.lang.model.IEntity) CoreException(org.eclipse.core.runtime.CoreException)

Example 10 with IBindingScope

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

the class JavaCompilerOperation method getGenerator.

public JavaModelGenerator getGenerator() {
    if (generator == null) {
        setGenerator(createGenerator());
        IBindingScope pe = getOperationEnvironment();
        if (pe.wIsSet("author"))
            generator.setAuthor(pe.wStringValue("author"));
        if (pe.wIsSet("copyright"))
            generator.setCopyright(pe.wStringValue("copyright"));
        if (pe.wIsSet("license"))
            generator.setLicense(pe.wStringValue("license"));
        if (pe.wIsSet("packageName"))
            generator.setBasePackagePrefix(pe.wStringValue("packageName"));
        if (pe.wIsSet("URI"))
            generator.setURI(pe.wStringValue("URI"));
    }
    return generator;
}
Also used : IBindingScope(org.whole.lang.bindings.IBindingScope)

Aggregations

IBindingScope (org.whole.lang.bindings.IBindingScope)13 IEntity (org.whole.lang.model.IEntity)8 IBindingManager (org.whole.lang.bindings.IBindingManager)5 Test (org.junit.Test)3 CoreException (org.eclipse.core.runtime.CoreException)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 IFile (org.eclipse.core.resources.IFile)1 Status (org.eclipse.core.runtime.Status)1 IOConsole (org.eclipse.ui.console.IOConsole)1 IFilePersistenceProvider (org.whole.lang.codebase.IFilePersistenceProvider)1 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)1 StringPersistenceProvider (org.whole.lang.codebase.StringPersistenceProvider)1 Model (org.whole.lang.models.model.Model)1 SimpleEntity (org.whole.lang.models.model.SimpleEntity)1 SimpleName (org.whole.lang.models.model.SimpleName)1 IOperationProgressMonitor (org.whole.lang.operations.IOperationProgressMonitor)1 OperationProgressMonitorAdapter (org.whole.lang.operations.OperationProgressMonitorAdapter)1 IReusablesEntity (org.whole.lang.reusables.model.IReusablesEntity)1