use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree 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();
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.
the class GraphAntlrTreeWalker method visitRootGraphDefinition.
private String visitRootGraphDefinition(GraphDefinitionContext graphDefinitionContext, DefinitionContext definitionContext) {
SourceInformation definitionSourceInfo = this.sourceInformation.getPureSourceInformation(definitionContext.start, graphDefinitionContext.start, graphDefinitionContext.stop);
SourceInformation classSourceInfo = this.sourceInformation.getPureSourceInformation(definitionContext.qualifiedName().start, definitionContext.qualifiedName().identifier().start, definitionContext.qualifiedName().stop);
MutableList<String> subTrees = FastList.newList();
for (GraphPathContext graphPathContext : graphDefinitionContext.graphPaths().graphPath()) {
subTrees.add(this.visitGraphPathContext(graphPathContext));
}
return "^meta::pure::graphFetch::RootGraphFetchTree<" + definitionContext.qualifiedName().getText() + "> " + definitionSourceInfo.toM4String() + " (" + "class = " + "^meta::pure::metamodel::import::ImportStub " + classSourceInfo.toM4String() + " (importGroup = system::imports::" + this.importId._name() + ", idOrPath = '" + definitionContext.qualifiedName().getText() + "'), " + "subTrees = " + subTrees.makeString("[", ", ", "]") + ")";
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.
the class RootGraphFetchTreeProcessor method process.
@Override
public void process(RootGraphFetchTree<?> instance, ProcessorState state, Matcher matcher, ModelRepository repository, Context context, ProcessorSupport processorSupport) {
CoreInstance _class = ImportStub.withImportStubByPass(instance._classCoreInstance(), processorSupport);
PostProcessor.processElement(matcher, _class, state, processorSupport);
ClassInstance type = (ClassInstance) processorSupport.package_getByUserPath(M3GraphPaths.RootGraphFetchTree);
GenericType classifierGT = GenericTypeInstance.createPersistent(repository);
GenericType typeArg = GenericTypeInstance.createPersistent(repository);
typeArg._rawType((Type) _class);
classifierGT._rawType(type);
classifierGT._typeArgumentsAdd(typeArg);
instance._classifierGenericType(classifierGT);
for (GraphFetchTree subTree : instance._subTrees()) {
this.processPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, _class, state, matcher, repository, processorSupport);
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.
the class RootGraphFetchTreeUnbind method run.
@Override
public void run(RootGraphFetchTree instance, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
ProcessorSupport processorSupport = state.getProcessorSupport();
for (GraphFetchTree subTree : instance._subTrees()) {
this.unbindPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, instance, state, matcher);
}
ImportStub _class = (ImportStub) instance._classCoreInstance();
CoreInstance resolved = _class._resolvedNodeCoreInstance();
if (resolved != null) {
ReferenceUsage.removeReferenceUsagesForUser(resolved, instance, state.getProcessorSupport());
}
Shared.cleanImportStub(_class, processorSupport);
instance._classifierGenericTypeRemove();
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree in project legend-pure by finos.
the class RootGraphFetchTreeValidator method run.
@Override
public void run(RootGraphFetchTree instance, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
ValidatorState validatorState = (ValidatorState) state;
final ProcessorSupport processorSupport = validatorState.getProcessorSupport();
Function<CoreInstance, CoreInstance> extractGenericTypeFunction = new Function<CoreInstance, CoreInstance>() {
@Override
public CoreInstance valueOf(CoreInstance instance) {
return Instance.instanceOf(instance, M3Paths.ValueSpecification, processorSupport) ? Instance.getValueForMetaPropertyToOneResolved(instance, M3Properties.genericType, processorSupport) : Instance.extractGenericTypeFromInstance(instance, processorSupport);
}
};
for (GraphFetchTree child : instance._subTrees()) {
this.validatePropertyGraphFetchTrees((PropertyGraphFetchTree) child, processorSupport, extractGenericTypeFunction);
}
}
Aggregations