This is defined on page 93 of the UML 2.5.1 specification under section 7.8.10.6 “Operations” for Namespace
. I have reformatted the body with my own indentation and line numbering of the body text for easier understanding (I hope!):
getNamesOfMember(element : NamedElement) : String [0..*]
The query getNamesOfMember() gives a set of all of the names that a member would have in a Namespace,
taking importing into account. In general a member can have multiple names in a Namespace if it is imported
more than once with different aliases.
body:
1 | if self.ownedMember ->includes(element)
2 | then Set{element.name}
3 | else
4 | let elementImports : Set(ElementImport)
5 | = self.elementImport->select(ei | ei.importedElement = element)
6 | in
7 | if elementImports->notEmpty() -- <== ???
8 | then
9 | elementImports->collect(el | el.getName())
10 | ->asSet()
11 | else
12 | self.packageImport->select(
13 | pi | pi.importedPackage.visibleMembers().oclAsType(NamedElement)
14 | ->includes(element))
15 | -> collect(pi | pi.importedPackage.getNamesOfMember(element))
16 | ->asSet()
17 | endif
18 | endif
It seems to me that if the Namespace
has any ElementImports
, none of the elements originating from any PackageImports
would be included in the output due to the innermost if..then..else
section starting at line 7?
As far as I understand, a Namespace
can have PackageImport
s and also ElementImport
s from a different Package
, possibly having name conflicts.
Perhaps there is an extra (or missing) parenthesis somewhere?
3