Get subsetting feature from other file

I want to get the subsetting feature, but it is displayed as anonymous element.

I have file 1 with:

package package1 {

private import testPackage::*;

attribute attribute2 :> part1.attribute1;

}

and another file with:

package testPackage {

part part1 {

    attribute attribute1;

}

}

From file1 I extract attribute2 as element and try to get part1.attribute1 from it. As a result I get Structure::attribute2::(anonymous Subsetting)::(anonymous Feature). How can I get the subsetting feature or change it to a known element?

Hi Klara,

The subsetted chaining Feature is an owned element of the Subsetting without a name. In this case str(element) is an implementation that prints something instead of nothing compared to qualified_name. Chained segments can be retrieved by calling chaining_features.collect() on the subsetted Feature, otherwise it can be replaced with attribute2.heritage.replace_at(0, syside.Subsetting, <other feature>) or attribute2.heritage.replace_chain_at(0, syside.Subsetting, (<feature 1>, <feature 2>, …)).

Hi Daumantas,

thanks for your reply. For some reason the chaining_features.collect() did not work for me, but the last_chaining_feature worked.

print(
    list(
        str(feat)
        for feat in attribute2.heritage.elements[0]
        .cast(syside.Feature)
        .chaining_features.collect()
    )
)

prints

['testPackage::part1', 'testPackage::part1::attribute1']

Sorry, chaining_features will be in the next release, was somehow missed during initial implementation. In the meantime, you can use

print(
    list(
        map(
            lambda chaining: str(chaining.chaining_feature),
            (
                feat
                for feat in attribute2.heritage.elements[0]
                .cast(syside.Feature)
                .owned_feature_chainings.collect()
            ),
        )
    )
)

Hi @Klara, v0.8.0 has been released with adds Feature.chaining_features member.