Search in sources :

Example 1 with InlineDSL

use of org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL in project legend-pure by finos.

the class GraphLoader method getProcessorsByType.

private MapIterable<CoreInstance, ? extends ListIterable<Processor>> getProcessorsByType() {
    MutableMap<CoreInstance, MutableList<Processor>> processorsByType = Maps.mutable.empty();
    RichIterable<Processor> processors = LazyIterate.concatenate(this.parserLibrary.getParsers().asLazy().flatCollect(Parser::getProcessors), this.inlineDSLLibrary.getInlineDSLs().asLazy().flatCollect(InlineDSL::getProcessors)).selectInstancesOf(Processor.class);
    for (Processor processor : processors) {
        CoreInstance type = getByUserPath(processor.getClassName());
        // Type may not be loaded yet, and that is ok.
        if (type != null) {
            processorsByType.getIfAbsentPut(type, Lists.mutable::empty).add(processor);
        }
    }
    return processorsByType;
}
Also used : Processor(org.finos.legend.pure.m3.compiler.postprocessing.processor.Processor) AnnotatedElementProcessor(org.finos.legend.pure.m3.compiler.postprocessing.processor.AnnotatedElementProcessor) SpecializationProcessor(org.finos.legend.pure.m3.compiler.postprocessing.SpecializationProcessor) MutableList(org.eclipse.collections.api.list.MutableList) Lists(org.eclipse.collections.api.factory.Lists) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) InlineDSL(org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser)

Example 2 with InlineDSL

use of org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL in project legend-pure by finos.

the class IncrementalCompiler_Old method walkTheGraphForUnload.

private SetIterable<CoreInstance> walkTheGraphForUnload() {
    WalkerState walkerState = new WalkerState(this.processorSupport);
    Matcher walkerMatcher = new Matcher(this.modelRepository, this.context, this.processorSupport);
    this.library.getParsers().asLazy().flatCollect(Parser::getUnLoadWalkers).concatenate(this.dslLibrary.getInlineDSLs().asLazy().flatCollect(InlineDSL::getUnLoadWalkers)).forEach(walkerMatcher::addMatchIfTypeIsKnown);
    this.toUnload.forEach(i -> walkerMatcher.match(i, walkerState));
    return walkerState.getInstances();
}
Also used : WalkerState(org.finos.legend.pure.m3.compiler.unload.walk.WalkerState) Matcher(org.finos.legend.pure.m3.tools.matcher.Matcher) InlineDSL(org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser) TopParser(org.finos.legend.pure.m3.serialization.grammar.top.TopParser)

Example 3 with InlineDSL

use of org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL in project legend-pure by finos.

the class Validator method validateM3.

public static void validateM3(Iterable<? extends CoreInstance> newInstancesConsolidated, ValidationType validationType, ParserLibrary parserLibrary, InlineDSLLibrary inlineDSLLibrary, Iterable<? extends MatchRunner> additionalValidators, CodeStorage codeStorage, ModelRepository modelRepository, Context context, ProcessorSupport processorSupport) throws PureCompilationException {
    // Post Process
    Matcher matcher = new Matcher(modelRepository, context, processorSupport);
    for (Parser parser : parserLibrary.getParsers()) {
        for (MatchRunner parserValidator : parser.getValidators()) {
            matcher.addMatchIfTypeIsKnown(parserValidator);
        }
    }
    for (InlineDSL dsl : inlineDSLLibrary.getInlineDSLs()) {
        for (MatchRunner dslValidator : dsl.getValidators()) {
            matcher.addMatchIfTypeIsKnown(dslValidator);
        }
    }
    for (MatchRunner validator : additionalValidators) {
        matcher.addMatchIfTypeIsKnown(validator);
    }
    ValidatorState validatorState = new ValidatorState(validationType, codeStorage, processorSupport);
    for (CoreInstance instance : newInstancesConsolidated) {
        validate(instance, validatorState, matcher, processorSupport);
    }
}
Also used : Matcher(org.finos.legend.pure.m3.tools.matcher.Matcher) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) MatchRunner(org.finos.legend.pure.m3.tools.matcher.MatchRunner) InlineDSL(org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser)

Example 4 with InlineDSL

use of org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL in project legend-pure by finos.

the class IncrementalCompiler_New method walkTheGraphForUnload.

private MutableSet<CoreInstance> walkTheGraphForUnload(MutableSet<CoreInstance> instances) {
    WalkerState walkerState = new WalkerState(this.processorSupport);
    Matcher walkerMatcher = new Matcher(this.modelRepository, this.context, this.processorSupport);
    this.library.getParsers().asLazy().flatCollect(Parser::getUnLoadWalkers).concatenate(this.dslLibrary.getInlineDSLs().asLazy().flatCollect(InlineDSL::getUnLoadWalkers)).forEach(walkerMatcher::addMatchIfTypeIsKnown);
    instances.forEach(i -> walkerMatcher.match(i, walkerState));
    return walkerState.getInstances().toSet();
}
Also used : WalkerState(org.finos.legend.pure.m3.compiler.unload.walk.WalkerState) Matcher(org.finos.legend.pure.m3.tools.matcher.Matcher) InlineDSL(org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL) Parser(org.finos.legend.pure.m3.serialization.grammar.Parser) TopParser(org.finos.legend.pure.m3.serialization.grammar.top.TopParser)

Example 5 with InlineDSL

use of org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL in project legend-pure by finos.

the class ParserService method inlineDSLs.

public ListIterable<InlineDSL> inlineDSLs() {
    MutableList<InlineDSL> inlineDSLS = Lists.mutable.of();
    Iterator<InlineDSL> it = this.dslsLoader.iterator();
    while (it.hasNext()) {
        try {
            InlineDSL dsl = it.next();
            inlineDSLS.add(dsl);
        } catch (Throwable e) {
        // Needs to be silent ... during the build process
        }
    }
    return inlineDSLS;
}
Also used : InlineDSL(org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL)

Aggregations

InlineDSL (org.finos.legend.pure.m3.serialization.grammar.m3parser.inlinedsl.InlineDSL)6 Parser (org.finos.legend.pure.m3.serialization.grammar.Parser)5 Matcher (org.finos.legend.pure.m3.tools.matcher.Matcher)4 WalkerState (org.finos.legend.pure.m3.compiler.unload.walk.WalkerState)2 TopParser (org.finos.legend.pure.m3.serialization.grammar.top.TopParser)2 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)2 Lists (org.eclipse.collections.api.factory.Lists)1 MutableList (org.eclipse.collections.api.list.MutableList)1 SpecializationProcessor (org.finos.legend.pure.m3.compiler.postprocessing.SpecializationProcessor)1 AnnotatedElementProcessor (org.finos.legend.pure.m3.compiler.postprocessing.processor.AnnotatedElementProcessor)1 Processor (org.finos.legend.pure.m3.compiler.postprocessing.processor.Processor)1 MatchRunner (org.finos.legend.pure.m3.tools.matcher.MatchRunner)1