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;
}
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;
}
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));
}
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);
}
}
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);
}
}
}
}
}
Aggregations