Search in sources :

Example 46 with IVisitor

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

the class Matcher method find.

@SuppressWarnings("unchecked")
public static <E extends IEntity> E find(E pattern, IEntity model, IBindingManager bindings, boolean includeAdjacents) {
    GenericMatcherFactory mf = GenericMatcherFactory.instance;
    IVisitor mv = mf.matchInScope(pattern);
    mv.setBindings(bindings);
    return (E) find(mv, model, includeAdjacents);
}
Also used : IVisitor(org.whole.lang.visitors.IVisitor)

Example 47 with IVisitor

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

the class GrammarsUIDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    platform.addEditorKit(GrammarsEditorKit.ID);
    platform.addEditorKit(GrammarsParserEditorKit.ID);
    platform.addEditorKit(GrammarsUnparserEditorKit.ID);
    platform.addOperationFactory(GrammarsLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new GrammarsUIInterpreterVisitor();
            else
                return null;
        }
    });
}
Also used : IOperation(org.whole.lang.operations.IOperation) IVisitor(org.whole.lang.visitors.IVisitor) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) GrammarsUIInterpreterVisitor(org.whole.lang.grammars.visitors.GrammarsUIInterpreterVisitor)

Example 48 with IVisitor

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

the class ArtifactsLanguageDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    platform.addLanguageKit(new ArtifactsLanguageKit());
    platform.addOperationFactory(ArtifactsLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {

        public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
            return new ArtifactsGenericBuilderAdapter((IArtifactsBuilder) strategy, entityContext);
        }
    });
    platform.addOperationFactory(ArtifactsLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {

        public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
            return new ArtifactsSpecificBuilderAdapter(strategy, entityContext);
        }
    });
    platform.addOperationFactory(ArtifactsLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return new ResourceArtifactsGeneratorVisitor();
        }
    });
    platform.addOperationFactory(ArtifactsLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            if (stage == 0)
                return new ArtifactsInterpreterVisitor();
            else
                return null;
        }
    });
}
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) ResourceArtifactsGeneratorVisitor(org.whole.lang.artifacts.visitors.ResourceArtifactsGeneratorVisitor) ArtifactsGenericBuilderAdapter(org.whole.lang.artifacts.builders.ArtifactsGenericBuilderAdapter) ArtifactsInterpreterVisitor(org.whole.lang.artifacts.visitors.ArtifactsInterpreterVisitor) IBuilderFactory(org.whole.lang.builders.IBuilderFactory) IArtifactsBuilder(org.whole.lang.artifacts.builders.IArtifactsBuilder) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) ArtifactsSpecificBuilderAdapter(org.whole.lang.artifacts.builders.ArtifactsSpecificBuilderAdapter)

Example 49 with IVisitor

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

the class EnvironmentLanguageDeployer method deploy.

public void deploy(ReflectionFactory platform) {
    platform.addLanguageKit(new EnvironmentLanguageKit());
    platform.addOperationFactory(EnvironmentLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {

        public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
            return new EnvironmentGenericBuilderAdapter((IEnvironmentBuilder) strategy, entityContext);
        }
    });
    platform.addOperationFactory(EnvironmentLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {

        public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
            return new EnvironmentSpecificBuilderAdapter(strategy, entityContext);
        }
    });
    platform.addOperationFactory(EnvironmentLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return stage == 0 ? new EnvironmentInterpreterVisitor() : null;
        }
    });
    platform.addOperationFactory(EnvironmentLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return stage == 0 ? new EnvironmentInterpreterVisitor() : null;
        }
    });
    platform.addOperationFactory(EnvironmentLanguageKit.URI, PrettyPrinterOperation.ID, new IVisitorFactory() {

        public IVisitor create(IOperation operation, int stage) {
            return new EnvironmentPrettyPrinterVisitor((PrettyPrinterOperation) operation);
        }
    });
}
Also used : IBuilder(org.whole.lang.builders.IBuilder) IOperation(org.whole.lang.operations.IOperation) EnvironmentPrettyPrinterVisitor(org.whole.lang.environment.visitors.EnvironmentPrettyPrinterVisitor) PrettyPrinterOperation(org.whole.lang.operations.PrettyPrinterOperation) EnvironmentInterpreterVisitor(org.whole.lang.environment.visitors.EnvironmentInterpreterVisitor) IVisitor(org.whole.lang.visitors.IVisitor) IEntityContext(org.whole.lang.contexts.IEntityContext) IBuilderFactory(org.whole.lang.builders.IBuilderFactory) IVisitorFactory(org.whole.lang.visitors.IVisitorFactory) EnvironmentGenericBuilderAdapter(org.whole.lang.environment.builders.EnvironmentGenericBuilderAdapter) EnvironmentSpecificBuilderAdapter(org.whole.lang.environment.builders.EnvironmentSpecificBuilderAdapter) IEnvironmentBuilder(org.whole.lang.environment.builders.IEnvironmentBuilder)

Example 50 with IVisitor

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

the class AbstractOperation method getVisitor.

public IVisitor getVisitor(IEntity entity, int absoluteStage) {
    int normalizedStage = absoluteStage <= 0 ? 0 : 1;
    String uri = ReflectionFactory.getLanguageKit(entity).getURI();
    IVisitor[] stagedVisitors = stagedVisitorsMap.get(uri);
    if (stagedVisitors == null)
        stagedVisitorsMap.put(uri, stagedVisitors = new IVisitor[2]);
    IVisitor visitor = stagedVisitors[normalizedStage];
    if (visitor == null) {
        visitor = stagedVisitors[normalizedStage] = initVisitor(entity, normalizedStage);
        visitor.setOperation(this);
    }
    return visitor;
}
Also used : IVisitor(org.whole.lang.visitors.IVisitor)

Aggregations

IVisitor (org.whole.lang.visitors.IVisitor)63 IOperation (org.whole.lang.operations.IOperation)34 IVisitorFactory (org.whole.lang.visitors.IVisitorFactory)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 IEntity (org.whole.lang.model.IEntity)9 ILanguageKit (org.whole.lang.reflect.ILanguageKit)4 MethodInvocation (org.eclipse.jdt.core.dom.MethodInvocation)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 Test (org.junit.Test)2 ITransactionScope (org.whole.lang.bindings.ITransactionScope)2 GenericMatcherFactory (org.whole.lang.matchers.GenericMatcherFactory)2 AbstractOperation (org.whole.lang.operations.AbstractOperation)2 PrettyPrinterOperation.toPrettyPrintString (org.whole.lang.operations.PrettyPrinterOperation.toPrettyPrintString)2 VisitException (org.whole.lang.visitors.VisitException)2 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1