use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(InvokeQuery entity) {
Variable queryName = entity.getQueryName();
Arguments arguments = entity.getArguments();
IEntityIterator<? extends IEntity>[] argsIterators = new IEntityIterator<?>[0];
Set<String> filterNames = getOperation().getResultsScope().wNames();
IBindingManager args = BindingManagerFactory.instance.createBindingManager(BindingManagerFactory.instance.createExcludeFilterScope(filterNames).wWithEnclosingScope(getBindings()), getBindings().wGetEnvironmentManager());
if (!EntityUtils.isNotResolver(arguments)) {
setResultValue(argsIterators);
arguments.accept(this);
argsIterators = (IEntityIterator<?>[]) getResultValue();
} else if (Matcher.match(WorkflowsEntityDescriptorEnum.Expressions, arguments)) {
IEntity selfEntity = getBindings().wGet("self");
argsIterators = new IEntityIterator<?>[arguments.wSize()];
for (int i = 0; i < argsIterators.length; i++) {
((Expressions) arguments).get(i).accept(this);
argsIterators[i] = getResultIterator();
setResultIterator(null);
resetSelfEntity(selfEntity);
}
} else
define(args, (Assignments) arguments);
IEntityIterator<?> iterator = QueriesIteratorFactory.callIterator(queryName.getValue(), argsIterators);
iterator.setBindings(args);
resetIterator(iterator);
while (iterator.hasNext()) iterator.next();
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class GenericGrammarBasedPrettyPrinterVisitor method visit.
@Override
public void visit(IEntity entity) {
IBindingManager bm = getBindings();
Grammar grammar = null;
String grammarUri = GrammarsUtils.getGrammarUri(bm);
if (grammarUri != null)
grammar = GrammarsRegistry.instance().getGrammar(grammarUri);
if (grammar == null) {
Collection<Grammar> grammars = GrammarsRegistry.instance().getGrammarsFor(entity);
if (grammars.isEmpty())
throw new IllegalArgumentException("cannot find a suitable grammar to unparse the entity");
grammar = grammars.iterator().next();
}
new GrammarBasedPrettyPrinterVisitor(entity, out, bm).visit(grammar);
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class GrammarsInterpreterVisitor method visit.
@Override
public void visit(Grammar grammar) {
grammar = normalize(grammar);
GrammarsRegistry.instance().putGrammar(grammar);
TargetLanguage targetLanguage = grammar.getTargetLanguage();
ILanguageKit languageKit = null;
final String languageUri;
IBindingManager bm = getBindings();
if (Matcher.match(GrammarsEntityDescriptorEnum.URI, targetLanguage)) {
languageUri = targetLanguage.wStringValue();
languageKit = ReflectionFactory.getLanguageKit(languageUri, true, bm);
} else {
languageUri = ((LanguageDescriptor) targetLanguage).getUri().getValue();
stagedVisit(GrammarsUtils.deriveModel(grammar, false));
languageKit = (ILanguageKit) bm.getResult().wGetValue();
}
if (languageKit.isDynamic()) {
DynamicLanguageKit dynamicLanguageKit = (DynamicLanguageKit) languageKit;
GrammarBasedDataTypeParser dataTypeParser = new GrammarBasedDataTypeParser(grammar.getUri().getValue());
dynamicLanguageKit.setDataTypeParser(DataTypeParsers.PERSISTENCE, dataTypeParser);
dynamicLanguageKit.setDataTypeParser(DataTypeParsers.PRESENTATION, dataTypeParser);
}
ReflectionFactory.updatePersistenceAndEditorKits(languageKit);
ReflectionFactory.deploy(new AbstractLanguageExtensionDeployer() {
public void deploy(ReflectionFactory platform) {
platform.addOperationFactory(languageUri, PrettyPrinterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new GenericGrammarBasedPrettyPrinterVisitor((PrettyPrinterOperation) operation);
}
});
platform.addOperationFactory(languageUri, ValidatorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new GenericGrammarBasedValidatorVisitor();
}
});
}
});
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class GrammarsDefaultDataTypeParser method format.
protected String format(EntityDescriptor<?> ed, Object value) {
Format format = grammarBasedDataTypeParser.getDataTerminal(ed).getFormat();
if (EntityUtils.isFragment(format)) {
IBindingManager bindings = getBindings();
bindings.wEnterScope();
bindings.wDefValue("self", value);
IEntity entity = BehaviorUtils.evaluate(format, 0, bindings);
bindings.wExitScope();
return entity.wStringValue();
} else {
Formatter formatter = new Formatter(grammarBasedDataTypeParser.getLocale());
return formatter.format(format.getValue(), value).toString();
}
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class TestsUIInterpreterVisitor method reportError.
@Override
protected void reportError(String name, RuntimeException e) {
super.reportError(name, e);
IBindingManager debugEnv = getBindings();
IEclipseContext context = (IEclipseContext) debugEnv.wGetValue("eclipse#eclipseContext");
if ((debugEnv.wIsSet("debug#reportModeEnabled") && !debugEnv.wBooleanValue("debug#reportModeEnabled")) || (debugEnv.wIsSet("debug#debugModeEnabled") && !debugEnv.wBooleanValue("debug#debugModeEnabled")) || (debugEnv.wIsSet("debug#breakpointsEnabled") && !debugEnv.wBooleanValue("debug#breakpointsEnabled")))
return;
else
E4Utils.suspendOrReportException(context, SuspensionKind.RECOVERABLE_ERROR, "Model test error", "Error while executing " + name + " test", e, debugEnv);
}
Aggregations