Search in sources :

Example 1 with ClassProjectionInstance

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassProjectionInstance in project legend-pure by finos.

the class AntlrContextToM3CoreInstance method projectionParser.

private CoreInstance projectionParser(ClassDefinitionContext ctx, ImportGroup importId, boolean addLines, ListIterable<CoreInstance> stereotypes, ListIterable<TaggedValue> tags) throws PureParserException {
    CoreInstance treePath = ctx.projection().dsl() != null ? this.dsl(ctx.projection().dsl(), importId).get(0) : this.treePath(ctx.projection().treePath(), importId);
    this.checkExists(ctx.qualifiedName().packagePath(), ctx.qualifiedName().identifier(), null);
    RootRouteNode rootNode = (RootRouteNode) treePath;
    String name = ctx.qualifiedName().identifier().getText();
    ClassProjectionInstance projection = ClassProjectionInstance.createPersistent(this.repository, name, this.sourceInformation.getPureSourceInformation(ctx.getStart(), ctx.qualifiedName().identifier().getStart(), ctx.getStop()), rootNode);
    projection._name(name);
    rootNode._owner(projection);
    PackageInstance packageInstance = this.buildPackage(ctx.qualifiedName().packagePath());
    projection._package(packageInstance);
    packageInstance._childrenAdd(projection);
    GenericTypeInstance classifierGT = GenericTypeInstance.createPersistent(this.repository);
    ClassInstance classType = (ClassInstance) this.processorSupport.package_getByUserPath(M3Paths.ClassProjection);
    classifierGT._rawTypeCoreInstance(classType);
    GenericTypeInstance classifierGTTA = GenericTypeInstance.createPersistent(this.repository);
    classifierGTTA._rawTypeCoreInstance(projection);
    classifierGT._typeArguments(Lists.mutable.<GenericType>of(classifierGTTA));
    projection._classifierGenericType(classifierGT);
    GenericTypeInstance superType = GenericTypeInstance.createPersistent(this.repository);
    superType._rawTypeCoreInstance(this.processorSupport.package_getByUserPath(M3Paths.Any));
    GeneralizationInstance generalizationInstance = GeneralizationInstance.createPersistent(this.repository, superType, projection);
    projection._generalizations(Lists.mutable.<Generalization>of(generalizationInstance));
    String fullName = this.getQualifiedNameString(ctx.qualifiedName());
    MutableList<Constraint> constraints = this.constraints(projection, ctx.constraints(), importId, new LambdaContext(fullName.replace("::", "_")), addLines);
    if (Iterate.notEmpty(stereotypes)) {
        projection._stereotypesCoreInstance(stereotypes);
    }
    if (Iterate.notEmpty(tags)) {
        projection._taggedValues(tags);
    }
    if (Iterate.notEmpty(constraints)) {
        projection._constraints(constraints);
    }
    return projection;
}
Also used : PackageInstance(org.finos.legend.pure.m3.coreinstance.PackageInstance) GenericTypeInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericTypeInstance) GeneralizationInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.GeneralizationInstance) RootRouteNode(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RootRouteNode) Constraint(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.constraint.Constraint) PrimitiveCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.PrimitiveCoreInstance) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) ClassProjectionInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassProjectionInstance) ClassInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance)

Aggregations

PackageInstance (org.finos.legend.pure.m3.coreinstance.PackageInstance)1 Constraint (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.constraint.Constraint)1 GeneralizationInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.GeneralizationInstance)1 RootRouteNode (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.treepath.RootRouteNode)1 ClassInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance)1 ClassProjectionInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassProjectionInstance)1 GenericTypeInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericTypeInstance)1 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)1 PrimitiveCoreInstance (org.finos.legend.pure.m4.coreinstance.primitive.PrimitiveCoreInstance)1