Search in sources :

Example 1 with ElementWithTaggedValues

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();
            }
        }
    }
}
Also used : ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) TaggedValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) Tag(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag) ElementWithTaggedValues(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithTaggedValues) PureCompilationException(org.finos.legend.pure.m4.exception.PureCompilationException)

Example 2 with ElementWithTaggedValues

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;
}
Also used : TaggedValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue) PrimitiveCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.PrimitiveCoreInstance) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance)

Example 3 with ElementWithTaggedValues

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);
    }
}
Also used : ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) TaggedValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue) ElementWithTaggedValues(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithTaggedValues) ValidatorState(org.finos.legend.pure.m3.compiler.validation.ValidatorState)

Aggregations

TaggedValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.TaggedValue)3 ElementWithTaggedValues (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.ElementWithTaggedValues)2 ProcessorSupport (org.finos.legend.pure.m3.navigation.ProcessorSupport)2 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)2 ValidatorState (org.finos.legend.pure.m3.compiler.validation.ValidatorState)1 Tag (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.extension.Tag)1 PrimitiveCoreInstance (org.finos.legend.pure.m4.coreinstance.primitive.PrimitiveCoreInstance)1 PureCompilationException (org.finos.legend.pure.m4.exception.PureCompilationException)1