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