Opened 6 years ago

Last modified 5 years ago

#5408 new defect

GUI annotations are not inherited correctly

Reported by: Francesco Casella Owned by: somebody
Priority: blocker Milestone: 2.0.0
Component: Interactive Environment Version:
Keywords: Cc: Adrian Pop

Description

Please consider the attached test package. The DataType record has a defaultComponentName and a defaultPrefixes annotation. The MyData record extends DataType, so it should also have them.

However, if I open M and drag and drop DataType into it, I get the correct name and prefix, while if I drag and drop MyData I get the default name and no prefixes.

I tried to flatten MyData with both OF and NF, using --showAnnotations, but I didn't see the annotation in either case. According to Sect. 7.1 of the Specification

The elements of the flattened base class become elements of the flattened enclosing class, and are added at the place of the extends-clause: specifically components and classes, the equation sections, algorithm sections, optional external clause, and the contents of the annotation at the end of the class.

I guess the underlying API suffers the same issue. I'm not sure whether it just needs to be fixed in the NF or if the API shoud also be fixed.

Attachments (1)

TestAnnotation.mo (329 bytes ) - added by Francesco Casella 6 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by Per Östlund, 6 years ago

You forgot to attach something.

However, one issue is that the specification doesn't really say how annotations should be inherited. What does it mean to add the contents of the annotation at the end of the class?

There's also the section about graphical annotations, 18.6, which states:

First baseclass contents is drawn according to the order of the extends-clauses, and then graphical primitives are drawn according to the order such that later objects can cover earlier ones.

This seems to suggest that at least the graphical annotations shouldn't simply be merged like modifiers, since merging would cause the order of inherited annotations to be lost.

by Francesco Casella, 6 years ago

Attachment: TestAnnotation.mo added

in reply to:  1 comment:2 by Francesco Casella, 6 years ago

Replying to perost:

You forgot to attach something.

Done, sorry :)

However, one issue is that the specification doesn't really say how annotations should be inherited. What does it mean to add the contents of the annotation at the end of the class?

In the use case of the attachment, it seems pretty obvious to me. You have a base class defining a data record, and then you derive actual data records deriving from it and adding modifiers with actual values. When you drag and drop the data records into a model, they should be automatically declared as parameters. Why should you re-add the defaultPrefixes annotation on each derived data record? That's really awkward.

In this case the derived record has no annotation at all, so inheriting the annotations from the base class is absolutely straightforward.

There's also the section about graphical annotations, 18.6, which states:

First baseclass contents is drawn according to the order of the extends-clauses, and then graphical primitives are drawn according to the order such that later objects can cover earlier ones.

This seems to suggest that at least the graphical annotations shouldn't simply be merged like modifiers, since merging would cause the order of inherited annotations to be lost.

True. I guess we need to make progress on the MAP-LANG discussion item #2314. So far we mainly had Hans raising new questions. We should try to come up with a proposal :)

comment:3 by Per Östlund, 6 years ago

Component: New InstantiationInteractive Environment
Owner: changed from Per Östlund to somebody

Ok, I'm changing the ticket to the interactive API in that case, since "fixing" this in the NF wouldn't change OMEdit behaviour at all.

What needs to be fixed is rather API calls such as getDefaultComponentName and getDefaultComponentPrefixes (need to check which calls OMEdit actually uses to fetch the information). Those calls currently just checks the annotation of the given class without doing any instantiation whatsoever, so they need to be changed to also look in the base classes.

Doing so efficiently might require using the NF, but inheriting annotations in such a way that they're visible in the flat model is not required for that. It's more efficient to just look in the base classes if the parent class doesn't have the annotation, than to merge everything and then check the annotation.

comment:4 by Per Östlund, 6 years ago

Cc: Adrian Pop added

in reply to:  3 comment:5 by Francesco Casella, 6 years ago

Replying to perost:
Sounds good. I guess this could also be the case for experiment annotations.

comment:6 by Martin Sjölund, 6 years ago

So that's isExperiment and the corresponding getter. Note that we tend to run isExperiment on every single class in package so it needs to be very fast :)

comment:7 by Francesco Casella, 5 years ago

Milestone: 1.14.02.0.0

We'll try to sort this out in 2.0.0

Note: See TracTickets for help on using tickets.