use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class CoreOperationsDeployer method deploy.
public void deploy(ReflectionFactory platform) {
platform.addOperationFactory(EditorsLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new EditorsArtifactsGeneratorVisitor((ArtifactsGeneratorOperation) operation);
}
});
platform.addOperationFactory(GrammarsLanguageKit.URI, ContentAssistOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new GrammarsContentAssistVisitor();
}
});
platform.addOperationFactory(GrammarsLanguageKit.URI, ValidatorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new GrammarsValidatorVisitor();
}
});
if (!ReflectionFactory.getLanguageKit(GrammarsLanguageKit.URI, false, null).hasVisitor(InterpreterOperation.ID))
platform.addOperationFactory(GrammarsLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new GrammarsInterpreterVisitor();
else
return null;
}
});
platform.addPersistenceKit("org.whole.lang.grammars.GrammarEditor", GrammarsPersistenceKit.instance());
platform.addPersistenceKit("org.whole.lang.objectivec.ObjectiveCEditor", ObjectiveCPersistenceKit.instance());
platform.addPersistenceKit("org.whole.lang.mediawiki.MediaWikiEditor", MediaWikiPersistenceKit.instance());
platform.addOperationFactory(TemplatesLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new AbstractVisitor() {
public void visit(IEntity entity) {
BehaviorUtils.apply("whole:org.whole.lang.templates:TemplatesSemantics#toJava", entity, getBindings());
}
};
}
});
platform.addOperationFactory(PojoLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new PojoArtifactsGeneratorVisitor((ArtifactsGeneratorOperation) operation);
}
});
platform.addOperationFactory(FramesLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new FramesInterpreterVisitor();
else
return null;
}
});
// TODO test
// ReflectLibrary.deploy();
new ReflectLibraryDeployer().deploy(platform);
new ViewDerivationLibraryDeployer().deploy(platform);
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class TestsLanguageDeployer method deploy.
public void deploy(ReflectionFactory platform) {
platform.addLanguageKit(new TestsLanguageKit());
platform.addOperationFactory(TestsLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new TestsGenericBuilderAdapter((ITestsBuilder) strategy, entityContext);
}
});
platform.addOperationFactory(TestsLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new TestsSpecificBuilderAdapter(strategy, entityContext);
}
});
platform.addOperationFactory(TestsLanguageKit.URI, PrettyPrinterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new TestsPrettyPrinterVisitor((PrettyPrinterOperation) operation);
}
});
platform.addOperationFactory(TestsLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new TestsLearningInterpreterVisitor();
else
return null;
}
});
platform.addOperationFactory(TestsLanguageKit.URI, ContentAssistOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new TestsContentAssistVisitor();
}
});
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class SchemeLanguageDeployer method deploy.
public void deploy(ReflectionFactory platform) {
platform.addLanguageKit(new SchemeLanguageKit());
platform.addOperationFactory(SchemeLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new SchemeGenericBuilderAdapter((ISchemeBuilder) strategy, entityContext);
}
});
platform.addOperationFactory(SchemeLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new SchemeSpecificBuilderAdapter(strategy, entityContext);
}
});
platform.addOperationFactory(SchemeLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new SchemeInterpreterVisitor((InterpreterOperation) operation);
else
return null;
}
});
platform.addEditorKit(SchemeTextualEditorKit.ID);
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class ImpLanguageDeployer method deploy.
public void deploy(ReflectionFactory platform) {
platform.addLanguageKit(new ImpLanguageKit());
platform.addOperationFactory(ImpLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new ImpGenericBuilderAdapter((IImpBuilder) strategy, entityContext);
}
});
platform.addOperationFactory(ImpLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new ImpSpecificBuilderAdapter(strategy, entityContext);
}
});
platform.addOperationFactory(ImpLanguageKit.URI, PrettyPrinterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new ImpPrettyPrinterVisitor((PrettyPrinterOperation) operation);
}
});
platform.addOperationFactory(ImpLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new ImpInterpreterVisitor((InterpreterOperation) operation);
else
return null;
}
});
platform.addOperationFactory(ImpLanguageKit.URI, ValidatorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return ImpTraversalFactory.instance.topDown(ImpTraversalFactory.instance.sequence(new ImpResolverValidatorVisitor((ValidatorOperation) operation), new ImpDefUseValidatorVisitor((ValidatorOperation) operation)), false);
}
});
platform.addOperationFactory(ImpLanguageKit.URI, BytecodeGeneratorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new ImpBytecodeGeneratorVisitor((BytecodeGeneratorOperation) operation);
}
});
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class ExecuteSampleModelRunnable method run.
@Override
public void run(IOperationProgressMonitor pm) throws InvocationTargetException, InterruptedException {
IEntity selfEntity = EntityUtils.mapEntity(selfModel, EntityUtils.clone(EntityUtils.getCompoundRoot(selfModel)));
Set<String> initialNames = bm.wNames();
pm.beginTask("Executing sample...", IOperationProgressMonitor.TOTAL_WORK);
behaviorModel = BehaviorUtils.apply("whole:org.whole.lang.ui.views:SamplePerspectiveSemantics#SampleViewBehavior", behaviorModel, bm);
IEntity derivedModel = null;
try {
IEntityIterator<?> iterator = BehaviorUtils.lazyEvaluate(behaviorModel, 0, bm);
iterator.setBindings(selfBindings);
iterator.reset(selfEntity);
if (iterator.getClass().equals(ConstantIterator.class)) {
IEntity result = iterator.next();
if (result == null || !EntityUtils.isData(result))
derivedModel = result;
else {
Object resultValue = result.wGetValue();
derivedModel = IVisitor.class.isInstance(resultValue) ? BindingManagerFactory.instance.createValue(Matcher.match((IVisitor) resultValue, selfEntity)) : result;
}
} else if (iterator.hasNext()) {
derivedModel = MiscEntityFactory.instance.createMisc(0);
ITransactionScope transactionScope = BindingManagerFactory.instance.createTransactionScope();
bm.wEnterScope(transactionScope);
try {
for (IEntity result : iterator) {
transactionScope.commit();
derivedModel.wAdd(GenericEntityFactory.instance.create(CommonsEntityDescriptorEnum.SameStageFragment, // CommonsEntityFactory.instance.createSameStageFragment(
EntityUtils.clone(// TODO substitute with a no containment fragment
result)));
}
} finally {
transactionScope.rollback();
bm.wExitScope();
}
}
} catch (MissingVariableException e) {
addMissingVariables(contextModel, e);
} catch (OperationCanceledException e) {
// gracefully terminate execution
} catch (Exception e) {
if (e.getCause() instanceof MissingVariableException)
addMissingVariables(contextModel, (MissingVariableException) e.getCause());
} finally {
pm.endTask();
}
IEntity variablesModel = null;
if (derivedModel != null) {
EnvironmentEntityFactory ef = EnvironmentEntityFactory.instance;
variablesModel = ef.createBindings(0);
for (String name : new TreeSet<String>(bm.wLocalNames())) if (!initialNames.contains(name))
variablesModel.wAdd(ef.createBinding(ef.createName(name), ef.createValue(BindingUtils.wGet(bm, name))));
final IEntity contents = derivedModel;
final IEntity variables = variablesModel;
context.get(UISynchronize.class).asyncExec(new Runnable() {
public void run() {
context.get(IEntityPartViewer.class).setContents(null, contents);
context.get(IEventBroker.class).post(IE4UIConstants.TOPIC_UPDATE_VARIABLES, variables);
}
});
}
}
Aggregations