Search in sources :

Example 6 with IBindingManager

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

the class RevisionPart method refreshVisuals.

@Override
protected void refreshVisuals() {
    int index = 0, additions = 0, deletions = 0;
    Revision entity = getModelEntity();
    if (EntityUtils.hasParent(entity))
        index = entity.wGetParent().wIndexOf(entity);
    try {
        IBindingManager bm = BindingManagerFactory.instance.createArguments();
        IEntity result = BehaviorUtils.apply("whole:org.whole.lang.changes:RevisionsLibrarySemantics#revisionSummary", entity, bm);
        additions = result.wGet(0).wIntValue();
        deletions = result.wGet(1).wIntValue();
    } catch (Exception e) {
    }
    getFigure().updateData(index, additions, deletions);
}
Also used : Revision(org.whole.lang.changes.model.Revision) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 7 with IBindingManager

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

the class TestsHelpers method updateFilterBody.

public static IEntity updateFilterBody(IEntity pattern, IEntity model, Sequence sequence) {
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    boolean match = false;
    while (!match) {
        try {
            bindings.wEnterScope();
            // try to match
            new GenericMatcher().withBindings(bindings).match(applyFilter(sequence, EntityUtils.clone(pattern), bindings), applyFilter(sequence, EntityUtils.clone(model), bindings));
            // eventually matches
            match = true;
        } catch (MatchException e) {
            // update normalization
            sequence.wAdd(QueriesEntityFactory.instance.createDelete(QueriesUtils.createRootPath(e.pattern)));
        } finally {
            // clear scope
            bindings.wExitScope();
        }
    }
    return sequence;
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) MatchException(org.whole.lang.matchers.MatchException) GenericMatcher(org.whole.lang.matchers.GenericMatcher)

Example 8 with IBindingManager

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

the class ReusablesDynamicCompilerVisitor method visit.

@Override
public void visit(FileSystem entity) {
    entity.getPersistence().accept(this);
    IEntityIterator<?> persistenceIterator = getResultIterator();
    entity.getContent().accept(this);
    IEntityIterator<?> contentIterator = getResultIterator();
    setResultIterator(IteratorFactory.composeIterator(IteratorFactory.singleValuedRunnableIterator(new ResourcePersistenceRunnable() {

        protected IPersistenceProvider getPersistenceProvider(String path, IBindingManager bm) {
            return new FilePersistenceProvider(new File(path), bm);
        }
    }, new int[] { 0 }, persistenceIterator).withSourceEntity(entity), contentIterator));
}
Also used : FilePersistenceProvider(org.whole.lang.codebase.FilePersistenceProvider) IBindingManager(org.whole.lang.bindings.IBindingManager) File(java.io.File)

Example 9 with IBindingManager

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

the class SemanticsInterpreterVisitor method visit.

@Override
public void visit(SemanticFunction entity) {
    FunctionBody rules = entity.getRules();
    if (Matcher.match(SemanticsEntityDescriptorEnum.InferenceRules, rules))
        return;
    FunctionLibraryRegistry.instance().putFunctionModel(getLibraryUri(entity) + "#" + entity.getName().getValue(), entity);
    IBindingManager bm = getBindings();
    if (!bm.wIsSet("LazyInterpretation") || !bm.wBooleanValue("LazyInterpretation"))
        DynamicCompilerOperation.compile(entity, getBindings());
}
Also used : FunctionBody(org.whole.lang.semantics.model.FunctionBody) IBindingManager(org.whole.lang.bindings.IBindingManager)

Example 10 with IBindingManager

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

the class SemanticsInterpreterVisitor method visit.

@Override
public void visit(EnvironmentVariable entity) {
    IEntity oldSematics = setFeature(SemanticsUtils.USE_IDENTIFIER_SEMANTICS, true);
    try {
        entity.getEnvironment().accept(this);
        IBindingManager bm = getBindings().wGetEnvironmentManager().getEnvironment(getResult().wStringValue());
        entity.getVariable().accept(this);
        String varName = getResult().wStringValue();
        IEntity varValue = bm.wGet(varName);
        if (varValue == null)
            throw new MissingVariableException(entity.getVariable().toString()).withSourceEntity(entity).withBindings(getBindings());
        setResult(varValue);
    } finally {
        setFeature(SemanticsUtils.USE_IDENTIFIER_SEMANTICS, oldSematics);
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) MissingVariableException(org.whole.lang.visitors.MissingVariableException)

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