Metadata keyword short name

Hi,

I want to create a metadata keyword like this:

@metadata1;

for a metadata defined in another package:

 package metadataDefs {
       metadata def <metadata1> DefinedMetadata :> Metaobjects::SemanticMetadata;
  }

I used parent_element.heritage.insert(0,syside.FeatureTyping,metadata1) with parent_element as a MetadataUsage and this produces a metadata keyword like this:

@metadataDefs::metadata1;

how can I get the shortname of the metadata as a keyword dirctly?

Thank you!

Programmatic reference printing is currently limited, it only shortens inherited references. We will extend it to support imports as well but cannot promise when. In that case you would need to add a namespace import as <ancestor>.children.insert(0, syside.NamespaceImport, metadataDefs) in one of the ancestor namespaces.

Thank you! Looking forward to the new feature.

I also want to redefine an attribute from a namespace import. In the textual syntax it shows a β€œref” instead of β€œ:>>”. Is this related to the namespace import issue or is there a solution for it?

ref keyword is for referential usages which is modified through <usage>.is_reference property (opposite of is_composite property). Otherwise reference printing behaviour is the same.

Maybe as an example, I want to create a redefinition like this:

new_usage = parent_element.children.append(syside.FeatureMembership, syside.ReferenceUsage)[1]
redefinition = new_usage.heritage.insert(0, syside.Redefinition, redefined_attribute)

The output is :>> redefined_attribute , but for an attribute from a namespace import i get ref redefined_attribute. How can I create a redefinition from an imported attribute?

This may be a bug, printer should not be inserting ref. Can you provide a minimal script that reproduces this?

yes, where can I send you the file/folder?

Here is fine, another option is to send an email to syside.support@sensmetry.com.

Next release will have a basic support for shortening printed references with imports.

1 Like