use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithTaggedValues in project legend-pure by finos.
the class ElementWithTaggedValuesUnbind method run.
@Override
public void run(CoreInstance element, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
ElementWithTaggedValues elementWithTaggedValues = ElementWithTaggedValuesCoreInstanceWrapper.toElementWithTaggedValues(element);
UnbindState unbindState = (UnbindState) state;
ProcessorSupport processorSupport = unbindState.getProcessorSupport();
for (TaggedValue taggedValue : elementWithTaggedValues._taggedValues()) {
unbindState.freeValidated(taggedValue);
CoreInstance embeddedTag = taggedValue._tagCoreInstance();
Tag tag;
try {
tag = (Tag) ImportStub.withImportStubByPass(embeddedTag, processorSupport);
} catch (PureCompilationException e) {
// Exception is ok here
tag = null;
}
if (tag != null) {
Shared.cleanImportStub(embeddedTag, processorSupport);
tag._modelElementsRemove(AnnotatedElementCoreInstanceWrapper.toAnnotatedElement(elementWithTaggedValues));
if (tag._modelElements().isEmpty()) {
tag._modelElementsRemove();
}
}
}
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithTaggedValues in project legend-pure by finos.
the class AntlrContextToM3CoreInstance method enumValue.
private CoreInstance enumValue(EnumValueContext ctx, CoreInstance enumeration, ImportGroup importId) {
ListIterable<CoreInstance> stereotypes = null;
ListIterable<TaggedValue> tags = null;
if (ctx.stereotypes() != null) {
stereotypes = this.stereotypes(ctx.stereotypes(), importId);
}
if (ctx.taggedValues() != null) {
tags = this.taggedValues(ctx.taggedValues(), importId);
}
CoreInstance enumValue = this.repository.newCoreInstance(ctx.identifier().getText(), enumeration, this.sourceInformation.getPureSourceInformation(ctx.identifier().getStart()), true);
enumValue.addKeyValue(Lists.immutable.of("Root", "children", "meta", "children", "pure", "children", "metamodel", "children", "type", "children", "Enum", "properties", "name"), this.repository.newStringCoreInstance_cached(ctx.identifier().getText()));
if (stereotypes != null) {
enumValue.setKeyValues(Lists.immutable.of("Root", "children", "meta", "children", "pure", "children", "metamodel", "children", "extension", "children", "ElementWithStereotypes", "properties", "stereotypes"), Lists.mutable.withAll(stereotypes));
}
if (tags != null) {
enumValue.setKeyValues(Lists.immutable.of("Root", "children", "meta", "children", "pure", "children", "metamodel", "children", "extension", "children", "ElementWithTaggedValues", "properties", "taggedValues"), Lists.mutable.<CoreInstance>withAll(tags));
}
return enumValue;
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithTaggedValues in project legend-pure by finos.
the class ElementWithTaggedValueValidator method run.
@Override
public void run(CoreInstance instanceValue, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
ElementWithTaggedValues elementWithTaggedValues = ElementWithTaggedValuesCoreInstanceWrapper.toElementWithTaggedValues(instanceValue);
ValidatorState validatorState = (ValidatorState) state;
ProcessorSupport processorSupport = validatorState.getProcessorSupport();
for (TaggedValue taggedValue : elementWithTaggedValues._taggedValues()) {
Validator.validate(taggedValue, validatorState, matcher, processorSupport);
}
}
Aggregations