Search in sources :

Example 1 with PropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub in project legend-pure by finos.

the class NavigationGraphBuilder method visitPropertyWithParametersBlock.

private void visitPropertyWithParametersBlock(PropertyWithParametersContext ctx, MutableList<PathElement> props, Token firstChar) {
    MutableList<ValueSpecification> parameters = FastList.newList();
    Token property = ctx.VALID_STRING().getSymbol();
    ClassInstance ppeType = (ClassInstance) this.processorSupport.package_getByUserPath(M3Paths.PropertyPathElement);
    PropertyPathElement propertyPathElement = (PropertyPathElement) this.repository.newAnonymousCoreInstance(this.sourceInformation.getPureSourceInformation(property), ppeType, true);
    GenericType classifierGT = GenericTypeInstance.createPersistent(this.repository);
    classifierGT._rawTypeCoreInstance(ppeType);
    propertyPathElement._classifierGenericType(classifierGT);
    PropertyStub propStub = PropertyStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(property), null, property.getText());
    propertyPathElement._propertyCoreInstance(propStub);
    if (ctx.parameter() != null) {
        for (ParameterContext parameterContext : ctx.parameter()) {
            parameters.add(visitParameterBlock(parameterContext));
        }
    }
    if (!parameters.isEmpty()) {
        propertyPathElement._parameters(parameters);
    }
    props.add(propertyPathElement);
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) Token(org.antlr.v4.runtime.Token) ParameterContext(org.finos.legend.pure.m3.inlinedsl.path.serialization.grammar.NavigationParser.ParameterContext) ClassInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance) PropertyPathElement(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement)

Example 2 with PropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub 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 3 with PropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub in project legend-pure by finos.

the class AntlrContextToM3CoreInstance method propertyRef.

private RouteNodePropertyStub propertyRef(PropertyRefContext ctx, ImportGroup importId, String space, RouteNode routeNode) {
    RouteNodePropertyStub routeNodePropertyStub = RouteNodePropertyStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(ctx.getStart(), ctx.identifier().getStart(), ctx.getStop()), routeNode);
    String propertyName = ctx.identifier().getText();
    PropertyStub propertyStub = PropertyStubInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(ctx.identifier().getStart()), null, propertyName);
    routeNodePropertyStub._propertyCoreInstance(Lists.mutable.<CoreInstance>with(propertyStub));
    if (ctx.treePathPropertyParameterType() != null) {
        MutableList<InstanceValue> params = Lists.mutable.of();
        for (TreePathPropertyParameterTypeContext fCtx : ctx.treePathPropertyParameterType()) {
            GenericType type = this.type(fCtx.type(), Lists.mutable.empty(), spacePlusTabs(space, 3), importId, true);
            Multiplicity multiplicity = this.buildMultiplicity(fCtx.multiplicity().multiplicityArgument());
            InstanceValue iv = InstanceValueInstance.createPersistent(this.repository, type, multiplicity);
            params.add(iv);
        }
        routeNodePropertyStub._parameters(params);
    }
    return routeNodePropertyStub;
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) RouteNodePropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Multiplicity(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.multiplicity.Multiplicity) RouteNodePropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) TreePathPropertyParameterTypeContext(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.TreePathPropertyParameterTypeContext)

Example 4 with PropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub in project legend-pure by finos.

the class RootRouteNodePostProcessor method resolvePropertyStub.

private AbstractProperty<?> resolvePropertyStub(Type _class, RouteNodePropertyStub routeNodePropertyStub, Matcher matcher, ProcessorState state, ProcessorSupport processorSupport) {
    PropertyStub propertyStubNonResolved = (PropertyStub) routeNodePropertyStub._propertyCoreInstance().getFirst();
    propertyStubNonResolved._ownerCoreInstance(_class);
    AbstractProperty<?> property = (AbstractProperty<?>) ImportStub.withImportStubByPass(routeNodePropertyStub._propertyCoreInstance().getFirst(), processorSupport);
    ListIterable<? extends VariableExpression> parameters = ((FunctionType) processorSupport.function_getFunctionType(property))._parameters().toList();
    for (VariableExpression parameter : ListHelper.tail(parameters)) {
        // TODO match the parameters
        parameter._genericType();
    }
    PostProcessor.processElement(matcher, routeNodePropertyStub, state, processorSupport);
    return property;
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) RouteNodePropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression)

Example 5 with PropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub in project legend-pure by finos.

the class RootRouteNodeUnbind method cleanRouteNodePropertyStub.

public void cleanRouteNodePropertyStub(RouteNodePropertyStub routeNodePropertyStub, UnbindState state, ProcessorSupport processorSupport) {
    PropertyStub propertyStub = (PropertyStub) routeNodePropertyStub._propertyCoreInstance().getFirst();
    Shared.cleanPropertyStub(propertyStub, processorSupport);
    propertyStub._ownerRemove();
    for (InstanceValue parameter : routeNodePropertyStub._parameters()) {
        GenericType parameterGenericType = parameter._genericType();
        Shared.cleanUpGenericType(parameterGenericType, state, processorSupport);
    }
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) RouteNodePropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)

Aggregations

PropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub)9 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)7 InstanceValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)6 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)6 RouteNodePropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub)5 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)5 AbstractProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)3 PropertyPathElement (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement)3 RichIterable (org.eclipse.collections.api.RichIterable)2 MilestoningDates (org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates)2 GraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree)2 PropertyGraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree)2 RootGraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree)2 PathElement (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PathElement)2 ClassInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance)2 FunctionType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType)2 VariableExpression (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression)2 ProcessorSupport (org.finos.legend.pure.m3.navigation.ProcessorSupport)2 Token (org.antlr.v4.runtime.Token)1 MilestoningStereotype (org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotype)1