Search in sources :

Example 6 with IVisitorFactory

use of org.whole.lang.visitors.IVisitorFactory in project whole by wholeplatform.

the class LegacyOperationsDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    // TODO move to MappingStrategyRegistry?
    MappingStrategyRegistry.instance().putMappingStrategy(new CommonsMappingStrategy());
    InterpreterOperation.interpret(new SchemaActions().create());
    platform.addOperationFactory(XsdLanguageKit.URI, PrettyPrinterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return new XsdPrettyPrinterVisitor();
        }
    });
    // TODO rewrite using queries/actions in SchemaActions
    // platform.addOperationFactory(XsdLanguageKit.ID, ArtifactsGeneratorOperation.ID,
    // new IVisitorFactory() {
    // public IVisitor create(IOperation operation, int stage) {
    // return new Xsd2ModelsArtifactsGeneratorVisitor((ArtifactsGeneratorOperation) operation);
    // }
    // });
    InterpreterOperation.interpret(new MappingActions().create());
    // FIXME requires WorkflowsInterpreter see WorkflowsInterpreterDeployer
    XsdRegistry.initialize();
    platform.addPersistenceKit("org.whole.lang.xsd.XsdSourceEditor", XsdPersistenceKit.instance());
    platform.addPersistenceKit("org.whole.lang.xsd.XsiSourceEditor", XsiPersistenceKit.instance());
    InterpreterOperation.interpret(new SchemaModelsActions().create());
}
Also used : IOperation(org.whole.lang.operations.IOperation) SchemaActions(org.whole.lang.xsd.codebase.SchemaActions) CommonsMappingStrategy(org.whole.lang.xsd.codebase.CommonsMappingStrategy) XsdPrettyPrinterVisitor(org.whole.lang.xsd.visitors.XsdPrettyPrinterVisitor) IVisitor(org.whole.lang.visitors.IVisitor) MappingActions(org.whole.lang.xsd.codebase.MappingActions) SchemaModelsActions(org.whole.lang.xsd.codebase.SchemaModelsActions) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory)

Example 7 with IVisitorFactory

use of org.whole.lang.visitors.IVisitorFactory 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);
}
Also used : IOperation(org.whole.lang.operations.IOperation) AbstractVisitor(org.whole.lang.visitors.AbstractVisitor) EditorsArtifactsGeneratorVisitor(org.whole.lang.editors.visitors.EditorsArtifactsGeneratorVisitor) GrammarsInterpreterVisitor(org.whole.lang.grammars.visitors.GrammarsInterpreterVisitor) IVisitor(org.whole.lang.visitors.IVisitor) IEntity(org.whole.lang.model.IEntity) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) FramesInterpreterVisitor(org.whole.lang.frames.visitors.FramesInterpreterVisitor) GrammarsContentAssistVisitor(org.whole.lang.grammars.visitors.GrammarsContentAssistVisitor) PojoArtifactsGeneratorVisitor(org.whole.lang.pojo.visitors.PojoArtifactsGeneratorVisitor) ReflectLibraryDeployer(org.whole.lang.ReflectLibraryDeployer) ArtifactsGeneratorOperation(org.whole.lang.operations.ArtifactsGeneratorOperation) ViewDerivationLibraryDeployer(org.whole.lang.ViewDerivationLibraryDeployer) GrammarsValidatorVisitor(org.whole.lang.grammars.visitors.GrammarsValidatorVisitor)

Example 8 with IVisitorFactory

use of org.whole.lang.visitors.IVisitorFactory 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();
                }
            });
        }
    });
}
Also used : IOperation(org.whole.lang.operations.IOperation) GrammarBasedDataTypeParser(org.whole.lang.grammars.parsers.GrammarBasedDataTypeParser) LanguageDescriptor(org.whole.lang.grammars.model.LanguageDescriptor) AbstractLanguageExtensionDeployer(org.whole.lang.reflect.AbstractLanguageExtensionDeployer) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) ILanguageKit(org.whole.lang.reflect.ILanguageKit) DynamicLanguageKit(org.whole.lang.reflect.DynamicLanguageKit) ReflectionFactory(org.whole.lang.reflect.ReflectionFactory) IBindingManager(org.whole.lang.bindings.IBindingManager) TargetLanguage(org.whole.lang.grammars.model.TargetLanguage)

Example 9 with IVisitorFactory

use of org.whole.lang.visitors.IVisitorFactory 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();
        }
    });
}
Also used : IBuilder(org.whole.lang.builders.IBuilder) IOperation(org.whole.lang.operations.IOperation) PrettyPrinterOperation(org.whole.lang.operations.PrettyPrinterOperation) IVisitor(org.whole.lang.visitors.IVisitor) TestsLearningInterpreterVisitor(org.whole.lang.tests.visitors.TestsLearningInterpreterVisitor) IEntityContext(org.whole.lang.contexts.IEntityContext) ITestsBuilder(org.whole.lang.tests.builders.ITestsBuilder) TestsSpecificBuilderAdapter(org.whole.lang.tests.builders.TestsSpecificBuilderAdapter) IBuilderFactory(org.whole.lang.builders.IBuilderFactory) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) TestsContentAssistVisitor(org.whole.lang.tests.visitors.TestsContentAssistVisitor) TestsGenericBuilderAdapter(org.whole.lang.tests.builders.TestsGenericBuilderAdapter) TestsPrettyPrinterVisitor(org.whole.lang.tests.visitors.TestsPrettyPrinterVisitor)

Example 10 with IVisitorFactory

use of org.whole.lang.visitors.IVisitorFactory 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);
}
Also used : IBuilder(org.whole.lang.builders.IBuilder) IOperation(org.whole.lang.operations.IOperation) IVisitor(org.whole.lang.visitors.IVisitor) IEntityContext(org.whole.lang.contexts.IEntityContext) SchemeGenericBuilderAdapter(org.whole.lang.scheme.builders.SchemeGenericBuilderAdapter) SchemeSpecificBuilderAdapter(org.whole.lang.scheme.builders.SchemeSpecificBuilderAdapter) ISchemeBuilder(org.whole.lang.scheme.builders.ISchemeBuilder) IBuilderFactory(org.whole.lang.builders.IBuilderFactory) SchemeInterpreterVisitor(org.whole.lang.scheme.visitors.SchemeInterpreterVisitor) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory)

Aggregations

IOperation (org.whole.lang.operations.IOperation)36 IVisitorFactory (org.whole.lang.visitors.IVisitorFactory)36 IVisitor (org.whole.lang.visitors.IVisitor)34 IBuilder (org.whole.lang.builders.IBuilder)20 IBuilderFactory (org.whole.lang.builders.IBuilderFactory)20 IEntityContext (org.whole.lang.contexts.IEntityContext)20 PrettyPrinterOperation (org.whole.lang.operations.PrettyPrinterOperation)13 ResourceArtifactsGeneratorVisitor (org.whole.lang.artifacts.visitors.ResourceArtifactsGeneratorVisitor)2 IBindingManager (org.whole.lang.bindings.IBindingManager)2 IImpBuilder (org.whole.examples.lang.imp.builders.IImpBuilder)1 ImpGenericBuilderAdapter (org.whole.examples.lang.imp.builders.ImpGenericBuilderAdapter)1 ImpSpecificBuilderAdapter (org.whole.examples.lang.imp.builders.ImpSpecificBuilderAdapter)1 BytecodeGeneratorOperation (org.whole.examples.lang.imp.visitors.BytecodeGeneratorOperation)1 ImpBytecodeGeneratorVisitor (org.whole.examples.lang.imp.visitors.ImpBytecodeGeneratorVisitor)1 ImpDefUseValidatorVisitor (org.whole.examples.lang.imp.visitors.ImpDefUseValidatorVisitor)1 ImpInterpreterVisitor (org.whole.examples.lang.imp.visitors.ImpInterpreterVisitor)1 ImpPrettyPrinterVisitor (org.whole.examples.lang.imp.visitors.ImpPrettyPrinterVisitor)1 ImpResolverValidatorVisitor (org.whole.examples.lang.imp.visitors.ImpResolverValidatorVisitor)1 ReflectLibraryDeployer (org.whole.lang.ReflectLibraryDeployer)1 ViewDerivationLibraryDeployer (org.whole.lang.ViewDerivationLibraryDeployer)1