Search in sources :

Example 21 with IBindingManager

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

the class JDTJavaBuilderPersistenceKit method ensureBuiltProject.

protected void ensureBuiltProject(IPersistenceProvider pp) throws CoreException {
    IBindingManager bm = pp.getBindings();
    IProject project = (IProject) bm.wGetValue("project");
    // perform an incremental build to ensure class files are generated
    if (project.hasNature(JavaCore.NATURE_ID))
        project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, ResourceUtils.getProgressMonitor(bm));
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) IProject(org.eclipse.core.resources.IProject)

Example 22 with IBindingManager

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

the class GrammarBasedUnparserVisitor method visit.

@Override
public void visit(Literal entity) {
    IEntity result;
    if (EntityUtils.isFragment(entity)) {
        IBindingManager bindings = getBindings();
        bindings.wEnterScope();
        bindings.wDef("self", model);
        result = BehaviorUtils.evaluate(entity, 0, bindings);
        bindings.wExitScope();
    } else
        result = entity;
    append(result.wStringValue());
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 23 with IBindingManager

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

the class WorkflowsDynamicCompilerVisitor method visit.

@Override
public void visit(InvokeJavaClassMethod entity) {
    final Variable resultVariable = entity.getResult();
    Expressions arguments = entity.getArguments();
    int size = arguments.wSize();
    IEntityIterator<?>[] runnableIterators = new IEntityIterator<?>[2 + size];
    entity.getClassName().accept(this);
    runnableIterators[0] = getResultIterator();
    entity.getMethod().accept(this);
    runnableIterators[1] = getResultIterator();
    for (int i = 0; i < size; i++) {
        arguments.get(i).accept(this);
        runnableIterators[2 + i] = getResultIterator();
    }
    setResultIterator(IteratorFactory.multiValuedRunnableIterator(new AbstractWorkflowsRunnable() {

        public void run(IEntity selfEntity, IBindingManager bm, IEntity... argsEntities) {
            String className = argsEntities[0].wStringValue();
            IEntity methodData = argsEntities[1];
            Method method;
            if (DataTypeUtils.getDataKind(methodData).isString())
                method = JavaReflectUtils.getMethod(className, methodData.wStringValue(), ReflectionFactory.getClassLoader(bm));
            else
                method = (Method) methodData.wGetValue();
            Object[] arguments = toArguments(method.getParameterTypes(), method.isVarArgs(), argsEntities);
            Object resultValue = JavaReflectUtils.invokeMethod(null, method, arguments);
            setResult(bm, resultVariable, resultValue, method.getReturnType());
        }
    }, runnableIterators).withSourceEntity(entity));
}
Also used : Variable(org.whole.lang.workflows.model.Variable) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Expressions(org.whole.lang.workflows.model.Expressions) InvokeJavaClassMethod(org.whole.lang.workflows.model.InvokeJavaClassMethod) InvokeJavaInstanceMethod(org.whole.lang.workflows.model.InvokeJavaInstanceMethod) Method(java.lang.reflect.Method) IEntityIterator(org.whole.lang.iterators.IEntityIterator)

Example 24 with IBindingManager

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

the class PojoMappingUtils method getModel.

public static Model getModel(Library library) {
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    PathExpression pojoModelToModels = new PojoModelToModelsQuery().create();
    Library normalizedLibrary = NormalizerOperation.normalize(EntityUtils.clone(library));
    Model model = BehaviorUtils.<Model>evaluateFirstResult(pojoModelToModels, normalizedLibrary, bindings);
    Matcher.removeVars(model, true);
    return model;
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) PojoModelToModelsQuery(org.whole.lang.pojo.templates.PojoModelToModelsQuery) IBindingManager(org.whole.lang.bindings.IBindingManager) Model(org.whole.lang.models.model.Model) Library(org.whole.lang.pojo.model.Library)

Example 25 with IBindingManager

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

the class ArtifactsSynchronizerVisitor method initialize.

private IArtifactsEntity initialize(IArtifactsEntity entity) {
    IEntity model;
    if (isLoading) {
        if (entity == null) {
            // build from scratch
            model = createFilesystemModel(entity, null, false);
            this.compareToEntityStack.push(cloneArtifact(model));
        } else {
            IEntity basePath = createBasePath(entity);
            model = createFilesystemModel(entity, basePath, false);
            this.compareToEntityStack.push(EntityUtils.clone(entity));
        }
    } else {
        IEntity basePath = createBasePath(entity);
        if (basePath != null) {
            IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
            model = EntityUtils.clone(basePath);
            IEntityIterator<IEntity> i = IteratorFactory.childIterator();
            i.reset(getChildren(entity));
            for (IEntity child : i) {
                bindings.wDef(SUB_TREE_ROOT, EntityUtils.clone(child));
                Matcher.substitute(model, bindings, false);
            }
            Matcher.removeVars(model, true);
        } else
            model = EntityUtils.clone(entity);
        // initialize the synchronization model
        IEntity filesystemModel = createFilesystemModel(entity, basePath, true);
        this.compareToEntityStack.push(filesystemModel);
    }
    return (IArtifactsEntity) model;
}
Also used : IArtifactsEntity(org.whole.lang.artifacts.model.IArtifactsEntity) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager)

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