Search in sources :

Example 1 with RouteNodePropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub 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 2 with RouteNodePropertyStub

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

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub in project legend-pure by finos.

the class RootRouteNodePostProcessor method resolveSimpleProperties.

private void resolveSimpleProperties(RouteNode treePathNode, Type _class, Matcher matcher, ProcessorState state, ProcessorSupport processorSupport) {
    RichIterable<? extends RouteNodePropertyStub> includedProperties = treePathNode._included();
    RichIterable<? extends RouteNodePropertyStub> excludedProperties = treePathNode._excluded();
    MutableList<CoreInstance> resolvedProperties = FastList.newList();
    if ("true".equals(treePathNode._includeAll())) {
        resolvedProperties.addAllIterable(getPrimitiveOrOfGivenTypeProperties(_class, processorSupport));
        resolvedProperties.addAllIterable(getPrimitiveOrOfGivenTypeQualifiedProperties(_class, processorSupport));
    } else if (includedProperties.notEmpty()) {
        for (RouteNodePropertyStub includedPropertyStub : includedProperties) {
            CoreInstance property = this.resolvePropertyStub(_class, includedPropertyStub, matcher, state, processorSupport);
            resolvedProperties.add(property);
        }
    } else if (excludedProperties.notEmpty()) {
        // TODO cannot handle simple and qualified properties with same name
        MapIterable<String, CoreInstance> simplePropertiesByName = processorSupport.class_getSimplePropertiesByName(_class);
        MapIterable<String, CoreInstance> qualifiedPropertiesByName = _Class.getQualifiedPropertiesByName(_class, processorSupport);
        resolvedProperties.addAllIterable(getPrimitiveOrOfGivenTypeProperties(_class, processorSupport));
        resolvedProperties.addAllIterable(getPrimitiveOrOfGivenTypeQualifiedProperties(_class, processorSupport));
        for (RouteNodePropertyStub excludedPropertyStub : excludedProperties) {
            AbstractProperty<?> property = this.resolvePropertyStub(_class, excludedPropertyStub, matcher, state, processorSupport);
            String name = Property.getPropertyId(property, processorSupport);
            if (simplePropertiesByName.containsKey(name)) {
                resolvedProperties.remove(simplePropertiesByName.get(name));
            }
            if (qualifiedPropertiesByName.containsKey(name)) {
                resolvedProperties.remove(qualifiedPropertiesByName.get(name));
            }
        }
    }
    treePathNode._resolvedPropertiesCoreInstance(FastList.<CoreInstance>newList(treePathNode._resolvedPropertiesCoreInstance().size() + resolvedProperties.size()).withAll(treePathNode._resolvedPropertiesCoreInstance()).withAll(resolvedProperties));
}
Also used : CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) RouteNodePropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub)

Example 4 with RouteNodePropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub 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)

Example 5 with RouteNodePropertyStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub in project legend-pure by finos.

the class RootRouteNodePostProcessor method populateReferenceUsages.

@Override
public void populateReferenceUsages(RootRouteNode treePathRoot, ModelRepository repository, ProcessorSupport processorSupport) {
    MutableSet<RouteNode> visited = Sets.mutable.empty();
    MutableStack<RouteNode> stack = Stacks.mutable.with(treePathRoot);
    while (stack.notEmpty()) {
        RouteNode node = stack.pop();
        if (visited.add(node)) {
            GenericTypeTraceability.addTraceForTreePath(node, repository, processorSupport);
            addReferenceUsagesForToManyProperty(node, node._resolvedPropertiesCoreInstance(), M3Properties.resolvedProperties, repository, processorSupport);
            if (node instanceof ExistingPropertyRouteNode) {
                GenericTypeTraceability.addTraceForTreePath(node, repository, processorSupport);
                RouteNodePropertyStub propertyStub = ((ExistingPropertyRouteNode) node)._property();
                // TODO Fix this: the reference usage should be to the RouteNodePropertyStub, not to the ExistingPropertyRouteNode
                // addReferenceUsageForToOneProperty(propertyStub, M3Properties.property, repository, context, processorSupport);
                AbstractProperty<?> property = (AbstractProperty<?>) ImportStub.withImportStubByPass(propertyStub._propertyCoreInstance().getFirst(), processorSupport);
                addReferenceUsage(node, property, M3Properties.property, 0, repository, processorSupport);
            } else if (node instanceof NewPropertyRouteNode) {
                NewPropertyRouteNodeFunctionDefinition<?, ?> functionDefinition = ((NewPropertyRouteNode) node)._functionDefinition();
                GenericTypeTraceability.addTraceForNewPropertyRouteNodeFunctionDefinition(functionDefinition, repository, processorSupport);
            }
            for (PropertyRouteNode child : node._children()) {
                if (!visited.contains(child)) {
                    stack.push(child);
                }
            }
        }
    }
}
Also used : ExistingPropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.ExistingPropertyRouteNode) PropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.PropertyRouteNode) NewPropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.NewPropertyRouteNode) ExistingPropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.ExistingPropertyRouteNode) PropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.PropertyRouteNode) RootRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RootRouteNode) RouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNode) NewPropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.NewPropertyRouteNode) ExistingPropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.ExistingPropertyRouteNode) NewPropertyRouteNodeFunctionDefinition(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.NewPropertyRouteNodeFunctionDefinition) NewPropertyRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.NewPropertyRouteNode) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty) RouteNodePropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub)

Aggregations

RouteNodePropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNodePropertyStub)10 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)5 PropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub)4 AbstractProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)4 ExistingPropertyRouteNode (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.ExistingPropertyRouteNode)3 InstanceValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)3 Multiplicity (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.multiplicity.Multiplicity)2 NewPropertyRouteNode (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.NewPropertyRouteNode)2 PropertyRouteNode (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.PropertyRouteNode)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 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)2 NewPropertyRouteNodeFunctionDefinition (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.NewPropertyRouteNodeFunctionDefinition)1 RootRouteNode (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RootRouteNode)1 RouteNode (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RouteNode)1 DataType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.DataType)1 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)1 TreePathPropertyParameterTypeContext (org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.TreePathPropertyParameterTypeContext)1 PureCompilationException (org.finos.legend.pure.m4.exception.PureCompilationException)1