Search in sources :

Example 1 with RootGraphFetchTree

use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.

the class RootGraphFetchTreeUnbind method unbindPropertyGraphFetchTree.

private void unbindPropertyGraphFetchTree(PropertyGraphFetchTree propertyGraphFetchTree, RootGraphFetchTree mainTree, MatcherState state, Matcher matcher) {
    ProcessorSupport processorSupport = state.getProcessorSupport();
    PropertyStub property = (PropertyStub) propertyGraphFetchTree._propertyCoreInstance();
    CoreInstance resolved = property._resolvedPropertyCoreInstance();
    if (resolved != null) {
        ReferenceUsage.removeReferenceUsagesForUser(resolved, mainTree, state.getProcessorSupport());
    }
    Shared.cleanPropertyStub(property, processorSupport);
    property._ownerRemove();
    for (ValueSpecification vs : propertyGraphFetchTree._parameters()) {
        if (vs instanceof InstanceValue) {
            for (CoreInstance value : ((InstanceValue) vs)._valuesCoreInstance()) {
                Shared.cleanEnumStub(value, processorSupport);
            }
            vs._genericTypeRemove();
            vs._multiplicityRemove();
        }
        matcher.fullMatch(vs, state);
    }
    for (GraphFetchTree subTree : propertyGraphFetchTree._subTrees()) {
        this.unbindPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, mainTree, state, matcher);
    }
    ImportStub subTypeClass = (ImportStub) propertyGraphFetchTree._subTypeCoreInstance();
    if (subTypeClass != null) {
        CoreInstance resolvedSubTypeClass = subTypeClass._resolvedNodeCoreInstance();
        if (resolvedSubTypeClass != null) {
            ReferenceUsage.removeReferenceUsagesForUser(resolvedSubTypeClass, mainTree, state.getProcessorSupport());
        }
        Shared.cleanImportStub(subTypeClass, processorSupport);
    }
    propertyGraphFetchTree._classifierGenericTypeRemove();
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) RootGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree) GraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree) PropertyGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Example 2 with RootGraphFetchTree

use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.

the class GraphAntlrTreeWalker method visitRootGraphDefinition.

private String visitRootGraphDefinition(GraphDefinitionContext graphDefinitionContext, DefinitionContext definitionContext) {
    SourceInformation definitionSourceInfo = this.sourceInformation.getPureSourceInformation(definitionContext.start, graphDefinitionContext.start, graphDefinitionContext.stop);
    SourceInformation classSourceInfo = this.sourceInformation.getPureSourceInformation(definitionContext.qualifiedName().start, definitionContext.qualifiedName().identifier().start, definitionContext.qualifiedName().stop);
    MutableList<String> subTrees = FastList.newList();
    for (GraphPathContext graphPathContext : graphDefinitionContext.graphPaths().graphPath()) {
        subTrees.add(this.visitGraphPathContext(graphPathContext));
    }
    return "^meta::pure::graphFetch::RootGraphFetchTree<" + definitionContext.qualifiedName().getText() + "> " + definitionSourceInfo.toM4String() + " (" + "class = " + "^meta::pure::metamodel::import::ImportStub " + classSourceInfo.toM4String() + " (importGroup = system::imports::" + this.importId._name() + ", idOrPath = '" + definitionContext.qualifiedName().getText() + "'), " + "subTrees = " + subTrees.makeString("[", ", ", "]") + ")";
}
Also used : GraphPathContext(org.finos.legend.pure.m3.inlinedsl.graph.serialization.grammar.GraphParser.GraphPathContext) AntlrSourceInformation(org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation)

Example 3 with RootGraphFetchTree

use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.

the class RootGraphFetchTreeProcessor method process.

@Override
public void process(RootGraphFetchTree<?> instance, ProcessorState state, Matcher matcher, ModelRepository repository, Context context, ProcessorSupport processorSupport) {
    CoreInstance _class = ImportStub.withImportStubByPass(instance._classCoreInstance(), processorSupport);
    PostProcessor.processElement(matcher, _class, state, processorSupport);
    ClassInstance type = (ClassInstance) processorSupport.package_getByUserPath(M3GraphPaths.RootGraphFetchTree);
    GenericType classifierGT = GenericTypeInstance.createPersistent(repository);
    GenericType typeArg = GenericTypeInstance.createPersistent(repository);
    typeArg._rawType((Type) _class);
    classifierGT._rawType(type);
    classifierGT._typeArgumentsAdd(typeArg);
    instance._classifierGenericType(classifierGT);
    for (GraphFetchTree subTree : instance._subTrees()) {
        this.processPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, _class, state, matcher, repository, processorSupport);
    }
}
Also used : GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) RootGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree) GraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree) PropertyGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree) ClassInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance)

Example 4 with RootGraphFetchTree

use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.

the class RootGraphFetchTreeUnbind method run.

@Override
public void run(RootGraphFetchTree instance, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
    ProcessorSupport processorSupport = state.getProcessorSupport();
    for (GraphFetchTree subTree : instance._subTrees()) {
        this.unbindPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, instance, state, matcher);
    }
    ImportStub _class = (ImportStub) instance._classCoreInstance();
    CoreInstance resolved = _class._resolvedNodeCoreInstance();
    if (resolved != null) {
        ReferenceUsage.removeReferenceUsagesForUser(resolved, instance, state.getProcessorSupport());
    }
    Shared.cleanImportStub(_class, processorSupport);
    instance._classifierGenericTypeRemove();
}
Also used : ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) RootGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree) GraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree) PropertyGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree) ImportStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.ImportStub)

Example 5 with RootGraphFetchTree

use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.

the class RootGraphFetchTreeValidator method run.

@Override
public void run(RootGraphFetchTree instance, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
    ValidatorState validatorState = (ValidatorState) state;
    final ProcessorSupport processorSupport = validatorState.getProcessorSupport();
    Function<CoreInstance, CoreInstance> extractGenericTypeFunction = new Function<CoreInstance, CoreInstance>() {

        @Override
        public CoreInstance valueOf(CoreInstance instance) {
            return Instance.instanceOf(instance, M3Paths.ValueSpecification, processorSupport) ? Instance.getValueForMetaPropertyToOneResolved(instance, M3Properties.genericType, processorSupport) : Instance.extractGenericTypeFromInstance(instance, processorSupport);
        }
    };
    for (GraphFetchTree child : instance._subTrees()) {
        this.validatePropertyGraphFetchTrees((PropertyGraphFetchTree) child, processorSupport, extractGenericTypeFunction);
    }
}
Also used : Function(org.eclipse.collections.api.block.function.Function) ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) RootGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree) GraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree) PropertyGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree) ValidatorState(org.finos.legend.pure.m3.compiler.validation.ValidatorState)

Aggregations

GraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree)4 PropertyGraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree)4 RootGraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree)4 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)4 ProcessorSupport (org.finos.legend.pure.m3.navigation.ProcessorSupport)3 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 RichIterable (org.eclipse.collections.api.RichIterable)1 Function (org.eclipse.collections.api.block.function.Function)1 MutableList (org.eclipse.collections.api.list.MutableList)1 ImmutableSet (org.eclipse.collections.api.set.ImmutableSet)1 Pair (org.eclipse.collections.api.tuple.Pair)1 Lists (org.eclipse.collections.impl.factory.Lists)1 Maps (org.eclipse.collections.impl.factory.Maps)1